Class: Solargraph::YardMap::Macro
- Inherits:
-
Object
- Object
- Solargraph::YardMap::Macro
- Defined in:
- lib/solargraph/yard_map/macro.rb
Constant Summary collapse
- PROCESSABLE_DIRECTIVES =
%w[method attribute parse].freeze
Instance Attribute Summary collapse
- #directive ⇒ YARD::Tags::MacroDirective readonly
- #macro_object ⇒ YARD::CodeObjects::MacroObject readonly
Class Method Summary collapse
Instance Method Summary collapse
- #generate_pins_from(chain, pin, source_map) ⇒ Array<Pin::Base>
-
#initialize(macro_object, method_pin, directive) ⇒ Macro
constructor
A new instance of Macro.
- #name ⇒ String
- #tag ⇒ YARD::Tags::Tag
- #text ⇒ String
Constructor Details
#initialize(macro_object, method_pin, directive) ⇒ Macro
Returns a new instance of Macro.
49 50 51 52 53 |
# File 'lib/solargraph/yard_map/macro.rb', line 49 def initialize macro_object, method_pin, directive @macro_object = macro_object @method_pin = method_pin @directive = directive end |
Instance Attribute Details
#directive ⇒ YARD::Tags::MacroDirective (readonly)
42 43 44 |
# File 'lib/solargraph/yard_map/macro.rb', line 42 def directive @directive end |
#macro_object ⇒ YARD::CodeObjects::MacroObject (readonly)
44 45 46 |
# File 'lib/solargraph/yard_map/macro.rb', line 44 def macro_object @macro_object end |
Class Method Details
.from_directive(directive, method_pin) ⇒ Macro
12 13 14 15 16 17 18 |
# File 'lib/solargraph/yard_map/macro.rb', line 12 def from_directive directive, method_pin macro_name = directive.tag.name.empty? ? method_pin.path.downcase : directive.tag.name method_object = method_object_from_pin(method_pin) code = directive.tag.text.to_s.gsub(/\n(?!@!|\s)/, "\n ") macro_object = YARD::CodeObjects::MacroObject.create(macro_name.to_s, code, method_object) new(macro_object, method_pin, directive) end |
Instance Method Details
#generate_pins_from(chain, pin, source_map) ⇒ Array<Pin::Base>
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/solargraph/yard_map/macro.rb', line 74 def generate_pins_from chain, pin, source_map call_location = Solargraph::Location.from_node(chain.node) # @param generated_pins [Array<Pin::Base>] generate_yardoc_from(chain, source_map).reduce([]) do |generated_pins, directive| directive_processor = YardMap::Directives.for(directive) next generated_pins unless directive_processor && call_location generated_pins + directive_processor.process_directive( source_map.source, source_map.pins, call_location.range.start, call_location.range.start, directive ) end end |
#name ⇒ String
56 57 58 |
# File 'lib/solargraph/yard_map/macro.rb', line 56 def name @directive.tag.name.to_s end |
#tag ⇒ YARD::Tags::Tag
66 67 68 |
# File 'lib/solargraph/yard_map/macro.rb', line 66 def tag @directive.tag end |
#text ⇒ String
61 62 63 |
# File 'lib/solargraph/yard_map/macro.rb', line 61 def text @directive.tag.text.to_s end |