class YARD::Parser::RSpecParser
Parses the output from the RSpec::Illustrate::YARD
formatter (which is valid html) and inserts the nodes into the corresponding CodeObject.
Public Class Methods
new(source, filename)
click to toggle source
# File lib/rspec/illustrate/yard.rb, line 18 def initialize(source, filename) @source = source end
Public Instance Methods
enumerator()
click to toggle source
@see YARD::Parser::Base#enumerator
# File lib/rspec/illustrate/yard.rb, line 47 def enumerator nil end
parse()
click to toggle source
@see YARD::Parser::Base#parse
# File lib/rspec/illustrate/yard.rb, line 23 def parse document = REXML::Document.new(@source) document.elements.each("html/body/div") {|element| if (path = element.attributes["id"].sub(/^rspec_/, '')) then if codeobject = YARD::Registry.at(path) then # only grab the <div> that contains the child elements, and omit # caption since we already gave a Specification header. examples = element.elements["div[@class='rspec_example_group_children']"] (codeobject[:rspec] ||= []).concat(examples.to_a) else log.warn "Could not find code object for #{path}, adding it to top level namespace." (YARD::Registry.root[:rspec] ||= []).concat(element.to_a) end end } self end
tokenize()
click to toggle source
@see YARD::Parser::Base#tokenize
# File lib/rspec/illustrate/yard.rb, line 42 def tokenize [] end