Class: Decode::Definition
Overview
A symbol with attached documentation.
Direct Known Subclasses
Language::Ruby::Attribute, Language::Ruby::Class, Language::Ruby::Constant, Language::Ruby::Definition, Language::Ruby::Method, Language::Ruby::Module, Language::Ruby::Singleton
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
The comment lines which directly preceeded the definition.
Attributes inherited from Symbol
#kind, #language, #name, #parent
Instance Method Summary collapse
-
#container? ⇒ Boolean
Whether this definition can contain nested definitions.
-
#documentation ⇒ Documentation | Nil
Structured access to the definitions comments.
-
#initialize(kind, name, comments, **options) ⇒ Definition
constructor
A new instance of Definition.
-
#long_form ⇒ String | nil
A long form of the definition.
-
#multiline? ⇒ Boolean
Whether the definition spans multiple lines.
-
#nested? ⇒ Boolean
Whether this represents a single entity to be documented (along with it’s contents).
-
#qualified_form ⇒ String | nil
A long form which uses the qualified name if possible.
-
#short_form ⇒ String | nil
A short form of the definition.
-
#text ⇒ String | nil
The full text of the definition.
Methods inherited from Symbol
#inspect, #key, #lexical_path, #path, #qualified_name
Constructor Details
#initialize(kind, name, comments, **options) ⇒ Definition
Returns a new instance of Definition.
26 27 28 29 30 31 |
# File 'lib/decode/definition.rb', line 26 def initialize(kind, name, comments, **) super(kind, name, **) @comments = comments @documentation = nil end |
Instance Attribute Details
#comments ⇒ Object (readonly)
The comment lines which directly preceeded the definition.
35 36 37 |
# File 'lib/decode/definition.rb', line 35 def comments @comments end |
Instance Method Details
#container? ⇒ Boolean
Whether this definition can contain nested definitions.
76 77 78 |
# File 'lib/decode/definition.rb', line 76 def container? false end |
#documentation ⇒ Documentation | Nil
Structured access to the definitions comments.
90 91 92 93 94 |
# File 'lib/decode/definition.rb', line 90 def documentation if @comments&.any? @documentation ||= Documentation.new(@comments) end end |
#long_form ⇒ String | nil
A long form of the definition. e.g. ‘def initialize(kind, name, comments, **options)`.
48 49 50 |
# File 'lib/decode/definition.rb', line 48 def long_form self.short_form end |
#multiline? ⇒ Boolean
Whether the definition spans multiple lines.
63 64 65 |
# File 'lib/decode/definition.rb', line 63 def multiline? false end |
#nested? ⇒ Boolean
Whether this represents a single entity to be documented (along with it’s contents).
83 84 85 |
# File 'lib/decode/definition.rb', line 83 def nested? container? end |
#qualified_form ⇒ String | nil
A long form which uses the qualified name if possible. Defaults to #long_form.
56 57 58 |
# File 'lib/decode/definition.rb', line 56 def qualified_form self.long_form end |
#short_form ⇒ String | nil
A short form of the definition. e.g. ‘def short_form`.
41 42 |
# File 'lib/decode/definition.rb', line 41 def short_form end |
#text ⇒ String | nil
The full text of the definition.
70 71 |
# File 'lib/decode/definition.rb', line 70 def text end |