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 =
{ '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.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.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, }.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
- #hash ⇒ Object
-
#initialize(kind) ⇒ Type
constructor
A new instance of Type.
- #mark? ⇒ Boolean
- #name ⇒ Object
- #param? ⇒ Boolean
- #plural_name ⇒ Object
- #should_document? ⇒ 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
58 59 60 |
# File 'lib/jazzy/source_declaration/type.rb', line 58 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
38 39 40 |
# File 'lib/jazzy/source_declaration/type.rb', line 38 def declaration? kind =~ /^source\.lang\.swift\.decl\..*/ end |
#equals ⇒ Object
57 |
# File 'lib/jazzy/source_declaration/type.rb', line 57 alias_method :equals, :== |
#hash ⇒ Object
53 54 55 |
# File 'lib/jazzy/source_declaration/type.rb', line 53 def hash kind.hash end |
#mark? ⇒ Boolean
30 31 32 |
# File 'lib/jazzy/source_declaration/type.rb', line 30 def mark? kind == 'source.lang.swift.syntaxtype.comment.mark' end |
#name ⇒ Object
22 23 24 |
# File 'lib/jazzy/source_declaration/type.rb', line 22 def name @type && @type[:jazzy] end |
#param? ⇒ Boolean
42 43 44 45 46 47 |
# File 'lib/jazzy/source_declaration/type.rb', line 42 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
34 35 36 |
# File 'lib/jazzy/source_declaration/type.rb', line 34 def should_document? declaration? && !param? end |