Class: Jdoc::Generator
- Inherits:
-
Object
- Object
- Jdoc::Generator
- Defined in:
- lib/jdoc/generator.rb
Constant Summary collapse
- DEFAULT_HTML_TEMPLATE_PATH =
File.("../../../template.html.erb", __FILE__)
- DEFAULT_MARKDOWN_TEMPLATE_PATH =
File.("../../../template.md.erb", __FILE__)
Class Method Summary collapse
-
.call(*args) ⇒ String
Utility wrapper for Jdoc::Generator#call.
Instance Method Summary collapse
-
#call ⇒ String
Generates Markdown or HTML documentation from JSON schema.
-
#initialize(schema, html: false, html_template_path: nil, markdown_template_path: nil) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(schema, html: false, html_template_path: nil, markdown_template_path: nil) ⇒ Generator
Returns a new instance of Generator.
16 17 18 19 20 21 |
# File 'lib/jdoc/generator.rb', line 16 def initialize(schema, html: false, html_template_path: nil, markdown_template_path: nil) @raw_schema = schema @html = html @html_template_path = html_template_path @markdown_template_path = markdown_template_path end |
Class Method Details
.call(*args) ⇒ String
Utility wrapper for Jdoc::Generator#call
8 9 10 |
# File 'lib/jdoc/generator.rb', line 8 def self.call(*args) new(*args).call end |
Instance Method Details
#call ⇒ String
Note:
Add some fix to adapt to GitHub anchor style
Generates Markdown or HTML documentation from JSON schema
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jdoc/generator.rb', line 26 def call markdown = markdown_renderer.result(schema: schema) if @html html = markdown_parser.render(markdown) html = html_renderer.result(body: html) html.gsub(/id="(.+)"/) {|text| text.tr("/:", "") } else markdown end rescue Jdoc::Link::ExampleNotFound => exception abort("Error: #{exception.to_s}") end |