Class: YARD::Tags::ParseDirective
- Defined in:
- lib/yard/tags/directives.rb
Overview
Parses a block of code as if it were present in the source file at that location. This directive is useful if a class has dynamic meta-programmed behaviour that cannot be recognized by YARD.
You can specify the language of the code block using the types specification list. By default, the code language is “ruby”.
Parser callbacks collapse
Constructor Details
This class inherits a constructor from YARD::Tags::Directive
Instance Method Details
#call ⇒ Object
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/yard/tags/directives.rb', line 545 def call existing = YARD::Registry.all.lazy.map(&:path).to_set if handler lang = tag.types ? tag.types.first.to_sym : (handler ? handler.parser.parser_type : :ruby) if handler && lang == handler.parser.parser_type pclass = Parser::SourceParser.parser_types[handler.parser.parser_type] pobj = pclass.new(tag.text, handler.parser.file) pobj.parse handler.parser.process(pobj.enumerator) else # initialize a new parse chain src_parser = Parser::SourceParser.new(lang, handler ? handler.globals : nil) src_parser.file = handler.parser.file if handler src_parser.parse(StringIO.new(tag.text)) end return unless handler YARD::Registry.all.each do |obj| next if existing.include? obj.path obj.files.each { |entry| entry[1] = handler.statement.line if entry[0] == handler.parser.file.to_s } obj.source = handler.statement.source end end |