Class: Jazzy::SourceDeclaration::Type
- Inherits:
-
Object
- Object
- Jazzy::SourceDeclaration::Type
- Defined in:
- lib/jazzy/source_declaration/type.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- TYPES =
{ # Markdown 'document.markdown' => { jazzy: 'Guide', dash: 'Guide', }.freeze, # Objective-C 'sourcekitten.source.lang.objc.decl.unexposed' => { jazzy: 'Unexposed', dash: 'Unexposed', }.freeze, 'sourcekitten.source.lang.objc.decl.category' => { jazzy: 'Category', dash: 'Extension', }.freeze, 'sourcekitten.source.lang.objc.decl.class' => { jazzy: 'Class', dash: 'Class', }.freeze, 'sourcekitten.source.lang.objc.decl.constant' => { jazzy: 'Constant', dash: 'Constant', }.freeze, 'sourcekitten.source.lang.objc.decl.enum' => { jazzy: 'Enum', dash: 'Enum', }.freeze, 'sourcekitten.source.lang.objc.decl.enumcase' => { jazzy: 'Enum Case', dash: 'Case', }.freeze, 'sourcekitten.source.lang.objc.decl.initializer' => { jazzy: 'Initializer', dash: 'Initializer', }.freeze, 'sourcekitten.source.lang.objc.decl.method.class' => { jazzy: 'Class Method', dash: 'Method', }.freeze, 'sourcekitten.source.lang.objc.decl.method.instance' => { jazzy: 'Instance Method', dash: 'Method', }.freeze, 'sourcekitten.source.lang.objc.decl.property' => { jazzy: 'Property', dash: 'Property', }.freeze, 'sourcekitten.source.lang.objc.decl.protocol' => { jazzy: 'Protocol', dash: 'Protocol', }.freeze, 'sourcekitten.source.lang.objc.decl.typedef' => { jazzy: 'Type Definition', dash: 'Alias', }.freeze, 'sourcekitten.source.lang.objc.mark' => { jazzy: 'Mark', dash: 'Mark', }.freeze, 'sourcekitten.source.lang.objc.decl.function' => { jazzy: 'Function', dash: 'Function', }.freeze, 'sourcekitten.source.lang.objc.decl.struct' => { jazzy: 'Struct', dash: 'Struct', }.freeze, 'sourcekitten.source.lang.objc.decl.field' => { jazzy: 'Field', dash: 'Field', }.freeze, 'sourcekitten.source.lang.objc.decl.ivar' => { jazzy: 'Ivar', dash: 'Ivar', }.freeze, 'sourcekitten.source.lang.objc.module.import' => { jazzy: 'Module', dash: 'Module', }.freeze, # Swift 'source.lang.swift.decl.function.accessor.address' => { jazzy: 'Address Accessor', dash: 'Function', }.freeze, 'source.lang.swift.decl.function.accessor.didset' => { jazzy: 'DidSet Accessor', dash: 'Function', }.freeze, 'source.lang.swift.decl.function.accessor.getter' => { jazzy: 'Getter Accessor', dash: 'Function', }.freeze, 'source.lang.swift.decl.function.accessor.mutableaddress' => { jazzy: 'Mutable Address Accessor', dash: 'Function', }.freeze, 'source.lang.swift.decl.function.accessor.setter' => { jazzy: 'Setter Accessor', dash: 'Function', }.freeze, 'source.lang.swift.decl.function.accessor.willset' => { jazzy: 'WillSet Accessor', dash: 'Function', }.freeze, 'source.lang.swift.decl.function.operator' => { jazzy: 'Operator', dash: 'Function', }.freeze, 'source.lang.swift.decl.function.operator.infix' => { jazzy: 'Infix Operator', dash: 'Function', }.freeze, 'source.lang.swift.decl.function.operator.postfix' => { jazzy: 'Postfix Operator', dash: 'Function', }.freeze, 'source.lang.swift.decl.function.operator.prefix' => { jazzy: 'Prefix Operator', dash: 'Function', }.freeze, 'source.lang.swift.decl.function.method.class' => { jazzy: 'Class Method', dash: 'Method', }.freeze, 'source.lang.swift.decl.var.class' => { jazzy: 'Class Variable', dash: 'Variable', }.freeze, 'source.lang.swift.decl.class' => { jazzy: 'Class', dash: 'Class', }.freeze, 'source.lang.swift.decl.function.constructor' => { jazzy: 'Constructor', dash: 'Constructor', }.freeze, 'source.lang.swift.decl.function.destructor' => { jazzy: 'Destructor', dash: 'Method', }.freeze, 'source.lang.swift.decl.var.global' => { jazzy: 'Global Variable', dash: 'Global', }.freeze, 'source.lang.swift.decl.enumcase' => { jazzy: 'Enum Case', dash: 'Case', }.freeze, 'source.lang.swift.decl.enumelement' => { jazzy: 'Enum Element', dash: 'Element', }.freeze, 'source.lang.swift.decl.enum' => { jazzy: 'Enum', dash: 'Enum', }.freeze, 'source.lang.swift.decl.extension' => { jazzy: 'Extension', dash: 'Extension', }.freeze, 'source.lang.swift.decl.extension.class' => { jazzy: 'Class Extension', dash: 'Extension', }.freeze, 'source.lang.swift.decl.extension.enum' => { jazzy: 'Enum Extension', dash: 'Extension', }.freeze, 'source.lang.swift.decl.extension.protocol' => { jazzy: 'Protocol Extension', dash: 'Extension', }.freeze, 'source.lang.swift.decl.extension.struct' => { jazzy: 'Struct Extension', dash: 'Extension', }.freeze, 'source.lang.swift.decl.function.free' => { jazzy: 'Function', dash: 'Function', }.freeze, 'source.lang.swift.decl.function.method.instance' => { jazzy: 'Instance Method', dash: 'Method', }.freeze, 'source.lang.swift.decl.var.instance' => { jazzy: 'Instance Variable', dash: 'Property', }.freeze, 'source.lang.swift.decl.var.local' => { jazzy: 'Local Variable', dash: 'Variable', }.freeze, 'source.lang.swift.decl.var.parameter' => { jazzy: 'Parameter', dash: 'Parameter', }.freeze, 'source.lang.swift.decl.protocol' => { jazzy: 'Protocol', dash: 'Protocol', }.freeze, 'source.lang.swift.decl.function.method.static' => { jazzy: 'Static Method', dash: 'Method', }.freeze, 'source.lang.swift.decl.var.static' => { jazzy: 'Static Variable', dash: 'Variable', }.freeze, 'source.lang.swift.decl.struct' => { jazzy: 'Struct', dash: 'Struct', }.freeze, 'source.lang.swift.decl.function.subscript' => { jazzy: 'Subscript', dash: 'Method', }.freeze, 'source.lang.swift.decl.typealias' => { jazzy: 'Typealias', dash: 'Alias', }.freeze, 'source.lang.swift.decl.generic_type_param' => { jazzy: 'Generic Type Parameter', dash: 'Parameter', }.freeze, 'source.lang.swift.decl.associatedtype' => { jazzy: 'Associated Type', dash: 'Alias', }.freeze, }.freeze
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #dash_type ⇒ Object
- #declaration? ⇒ Boolean
- #equals ⇒ Object
- #extension? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(kind) ⇒ Type
constructor
A new instance of Type.
- #mark? ⇒ Boolean
- #name ⇒ Object
- #objc_category? ⇒ Boolean
- #objc_class? ⇒ Boolean
- #objc_enum? ⇒ Boolean
- #objc_typedef? ⇒ Boolean
- #objc_unexposed? ⇒ Boolean
- #param? ⇒ Boolean
- #plural_name ⇒ Object
- #should_document? ⇒ Boolean
- #swift_enum_case? ⇒ Boolean
- #swift_enum_element? ⇒ Boolean
- #swift_extensible? ⇒ Boolean
- #swift_extension? ⇒ Boolean
- #swift_protocol? ⇒ Boolean
Constructor Details
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
11 12 13 |
# File 'lib/jazzy/source_declaration/type.rb', line 11 def kind @kind end |
Class Method Details
.all ⇒ Object
7 8 9 |
# File 'lib/jazzy/source_declaration/type.rb', line 7 def self.all TYPES.keys.map { |k| new(k) } end |
Instance Method Details
#==(other) ⇒ Object
104 105 106 |
# File 'lib/jazzy/source_declaration/type.rb', line 104 def ==(other) other && kind == other.kind end |
#dash_type ⇒ Object
18 19 20 |
# File 'lib/jazzy/source_declaration/type.rb', line 18 def dash_type @type && @type[:dash] end |
#declaration? ⇒ Boolean
63 64 65 66 |
# File 'lib/jazzy/source_declaration/type.rb', line 63 def declaration? kind.start_with?('source.lang.swift.decl', 'sourcekitten.source.lang.objc.decl') end |
#equals ⇒ Object
103 |
# File 'lib/jazzy/source_declaration/type.rb', line 103 alias equals == |
#extension? ⇒ Boolean
68 69 70 |
# File 'lib/jazzy/source_declaration/type.rb', line 68 def extension? swift_extension? || objc_category? end |
#hash ⇒ Object
99 100 101 |
# File 'lib/jazzy/source_declaration/type.rb', line 99 def hash kind.hash end |
#mark? ⇒ Boolean
30 31 32 33 |
# File 'lib/jazzy/source_declaration/type.rb', line 30 def mark? kind == 'source.lang.swift.syntaxtype.comment.mark' || kind == 'sourcekitten.source.lang.objc.mark' end |
#name ⇒ Object
22 23 24 |
# File 'lib/jazzy/source_declaration/type.rb', line 22 def name @type && @type[:jazzy] end |
#objc_category? ⇒ Boolean
43 44 45 |
# File 'lib/jazzy/source_declaration/type.rb', line 43 def objc_category? kind == 'sourcekitten.source.lang.objc.decl.category' end |
#objc_class? ⇒ Boolean
47 48 49 |
# File 'lib/jazzy/source_declaration/type.rb', line 47 def objc_class? kind == 'sourcekitten.source.lang.objc.decl.class' end |
#objc_enum? ⇒ Boolean
35 36 37 |
# File 'lib/jazzy/source_declaration/type.rb', line 35 def objc_enum? kind == 'sourcekitten.source.lang.objc.decl.enum' end |
#objc_typedef? ⇒ Boolean
39 40 41 |
# File 'lib/jazzy/source_declaration/type.rb', line 39 def objc_typedef? kind == 'sourcekitten.source.lang.objc.decl.typedef' end |
#objc_unexposed? ⇒ Boolean
91 92 93 |
# File 'lib/jazzy/source_declaration/type.rb', line 91 def objc_unexposed? kind == 'sourcekitten.source.lang.objc.decl.unexposed' end |
#param? ⇒ Boolean
84 85 86 87 88 89 |
# File 'lib/jazzy/source_declaration/type.rb', line 84 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 ⇒ Object
26 27 28 |
# File 'lib/jazzy/source_declaration/type.rb', line 26 def plural_name name.pluralize end |
#should_document? ⇒ Boolean
59 60 61 |
# File 'lib/jazzy/source_declaration/type.rb', line 59 def should_document? declaration? && !param? end |
#swift_enum_case? ⇒ Boolean
51 52 53 |
# File 'lib/jazzy/source_declaration/type.rb', line 51 def swift_enum_case? kind == 'source.lang.swift.decl.enumcase' end |
#swift_enum_element? ⇒ Boolean
55 56 57 |
# File 'lib/jazzy/source_declaration/type.rb', line 55 def swift_enum_element? kind == 'source.lang.swift.decl.enumelement' end |
#swift_extensible? ⇒ Boolean
76 77 78 |
# File 'lib/jazzy/source_declaration/type.rb', line 76 def swift_extensible? kind =~ /^source\.lang\.swift\.decl\.(class|struct|protocol|enum)$/ end |
#swift_extension? ⇒ Boolean
72 73 74 |
# File 'lib/jazzy/source_declaration/type.rb', line 72 def swift_extension? kind =~ /^source\.lang\.swift\.decl\.extension.*/ end |
#swift_protocol? ⇒ Boolean
80 81 82 |
# File 'lib/jazzy/source_declaration/type.rb', line 80 def swift_protocol? kind == 'source.lang.swift.decl.protocol' end |