class Jazzy::SourceDeclaration::Type
rubocop:disable Metrics/ClassLength
Constants
- MARKDOWN_KIND
- OVERVIEW_KIND
- TYPES
Attributes
kind[R]
Public Class Methods
all()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 10 def self.all TYPES.keys.map { |k| new(k) }.reject { |t| t.name.nil? } end
markdown()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 179 def self.markdown Type.new(MARKDOWN_KIND) end
new(kind, declaration = nil)
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 16 def initialize(kind, declaration = nil) kind = fixup_kind(kind, declaration) if declaration @kind = kind @type = TYPES[kind] end
overview()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 169 def self.overview Type.new(OVERVIEW_KIND) end
Public Instance Methods
==(other)
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 192 def ==(other) other && kind == other.kind end
Also aliased as: equals
dash_type()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 34 def dash_type @type && @type[:dash] end
declaration?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 118 def declaration? kind.start_with?('source.lang.swift.decl', 'sourcekitten.source.lang.objc.decl') end
extension?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 123 def extension? swift_extension? || objc_category? end
fixup_kind(kind, declaration)
click to toggle source
Improve kind from full declaration
# File lib/jazzy/source_declaration/type.rb, line 23 def fixup_kind(kind, declaration) if kind == 'source.lang.swift.decl.class' && declaration.include?( '<syntaxtype.keyword>actor</syntaxtype.keyword>', ) 'source.lang.swift.decl.actor' else kind end end
generic_type_param?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 155 def generic_type_param? kind == 'source.lang.swift.decl.generic_type_param' end
global?()
click to toggle source
kinds that are ‘global’ and should get their own pages with –separate-global-declarations
# File lib/jazzy/source_declaration/type.rb, line 44 def global? @type && @type[:global] end
hash()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 187 def hash kind.hash end
mark?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 77 def mark? objc_mark? || swift_mark? end
markdown?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 183 def markdown? kind == MARKDOWN_KIND end
name()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 38 def name @type && @type[:jazzy] end
name_controlled_manually?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 53 def name_controlled_manually? !kind.start_with?('source') # "'source'.lang..." for Swift # or "'source'kitten.source..." for Objective-C # but not "Overview" for navigation groups. end
objc_category?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 94 def objc_category? kind == 'sourcekitten.source.lang.objc.decl.category' end
objc_class?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 98 def objc_class? kind == 'sourcekitten.source.lang.objc.decl.class' end
objc_enum?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 86 def objc_enum? kind == 'sourcekitten.source.lang.objc.decl.enum' end
objc_mark?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 68 def objc_mark? kind == 'sourcekitten.source.lang.objc.mark' end
objc_typedef?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 90 def objc_typedef? kind == 'sourcekitten.source.lang.objc.decl.typedef' end
objc_unexposed?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 163 def objc_unexposed? kind == 'sourcekitten.source.lang.objc.decl.unexposed' end
overview?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 173 def overview? kind == OVERVIEW_KIND end
param?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 148 def param? # SourceKit strangely categorizes initializer parameters as local # variables, so both kinds represent a parameter in jazzy. kind == 'source.lang.swift.decl.var.parameter' || kind == 'source.lang.swift.decl.var.local' end
plural_name()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 60 def plural_name name.pluralize end
plural_url_name()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 64 def plural_url_name url_name.pluralize end
should_document?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 114 def should_document? declaration? && !param? && !generic_type_param? end
swift_enum_case?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 106 def swift_enum_case? kind == 'source.lang.swift.decl.enumcase' end
swift_enum_element?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 110 def swift_enum_element? kind == 'source.lang.swift.decl.enumelement' end
swift_extensible?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 131 def swift_extensible? kind =~ /^source\.lang\.swift\.decl\.(class|struct|protocol|enum|actor)$/ end
swift_extension?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 127 def swift_extension? kind =~ /^source\.lang\.swift\.decl\.extension.*/ end
swift_global_function?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 144 def swift_global_function? kind == 'source.lang.swift.decl.function.free' end
swift_mark?()
click to toggle source
covers MARK: TODO: FIXME: comments
# File lib/jazzy/source_declaration/type.rb, line 73 def swift_mark? kind == 'source.lang.swift.syntaxtype.comment.mark' end
swift_protocol?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 136 def swift_protocol? kind == 'source.lang.swift.decl.protocol' end
swift_type?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 102 def swift_type? kind.include? 'swift' end
swift_typealias?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 140 def swift_typealias? kind == 'source.lang.swift.decl.typealias' end
swift_variable?()
click to toggle source
# File lib/jazzy/source_declaration/type.rb, line 159 def swift_variable? kind.start_with?('source.lang.swift.decl.var') end
task_mark?(name)
click to toggle source
mark that should start a new task section
# File lib/jazzy/source_declaration/type.rb, line 82 def task_mark?(name) objc_mark? || (swift_mark? && name.start_with?('MARK: ')) end
url_name()
click to toggle source
name to use for type subdirectory in URLs for back-compatibility
# File lib/jazzy/source_declaration/type.rb, line 49 def url_name @type && (@type[:url] || @type[:jazzy]) end