class JsDuck::Exporter::Examples
Exporter
for inline examples.
It produces the following structure:
{
:type => :class, # can also be :guide :name => "Panel", :examples => [ {:code => "bla bla", :options => {}}, {:code => "bla bla", :options => {"raw" => true}}, ... ]
}
Public Class Methods
new(relations, opts)
click to toggle source
# File lib/jsduck/exporter/examples.rb, line 21 def initialize(relations, opts) # All params ignored, they're present to be compatible with # other exporters. @inline_examples = InlineExamples.new end
Public Instance Methods
export(cls)
click to toggle source
Returns hash of class name and inline examples
# File lib/jsduck/exporter/examples.rb, line 28 def export(cls) examples = @inline_examples.extract(cls[:doc]) if examples.length > 0 { :type => :class, :name => cls[:name], :examples => examples, } else nil end end
export_guide(guide)
click to toggle source
Returns hash of guide name and inline examples
# File lib/jsduck/exporter/examples.rb, line 42 def export_guide(guide) examples = @inline_examples.extract(guide[:html] || "") if examples.length > 0 { :type => :guide, :name => guide["name"], :examples => examples, } else nil end end