Class: NanDoc::Filters::SeeTest

Inherits:
Object
  • Object
show all
Includes:
TagParseInstanceMethods
Defined in:
lib/nandoc/filters/builtin-tags/see-test.rb

Defined Under Namespace

Classes: MyStringScanner

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TagParseInstanceMethods

#unquote

Class Method Details

.=~(item_content) ⇒ Object



24
25
26
# File 'lib/nandoc/filters/builtin-tags/see-test.rb', line 24

def =~ item_content
  Re =~ item_content
end

Instance Method Details

#run(item_content) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/nandoc/filters/builtin-tags/see-test.rb', line 29

def run item_content
  scn = MyStringScanner.new(item_content)
  doc = NanDoc::Html::Tags.new
  while (match = scn.scan_until(Re))
    noparse, parse = Re2 =~ match && $1, $2
    doc.push_raw noparse
    scn2 = MyStringScanner.new(parse)
    scn2.skip(/\(see: */)
    path = scn2.scan_assert(/[-\w]+\.\w+/i, 'path')
    things = []
    loop do
      scn2.skip(%r<\s*(?:--?|/)\s*>)
      this = scn2.scan(/ '[^']*' | "[^"]*" | [^\s'"]+ /x) or
        fail("internal parse fail near #{scn2.rest.inspect}")
      things.push unquote(this)
      scn2.skip(/\)\s*/)
      scn2.eos? and break
    end
    playback = NanDoc::SpecDoc::Playback::Method.new(path, things)
    playback.make_html doc
  end
  doc.push_raw scn.rest
  html = doc.to_html
  html
end