Class: ApiDoc::HtmlWriter
- Inherits:
-
Object
- Object
- ApiDoc::HtmlWriter
- Defined in:
- lib/apidoc.rb
Instance Method Summary collapse
-
#initialize(runner) ⇒ HtmlWriter
constructor
A new instance of HtmlWriter.
- #resource_html(resource) ⇒ Object
- #write(stream) ⇒ Object
Constructor Details
#initialize(runner) ⇒ HtmlWriter
Returns a new instance of HtmlWriter.
98 99 100 |
# File 'lib/apidoc.rb', line 98 def initialize(runner) @runner = runner end |
Instance Method Details
#resource_html(resource) ⇒ Object
114 115 116 117 118 119 120 121 122 |
# File 'lib/apidoc.rb', line 114 def resource_html(resource) Mustache.to_html(File.read(File.dirname(__FILE__) + '/../templates/resource.mustache'), { method: resource.method, path: resource.path, desc: Kramdown::Document.new(resource.desc).to_html, params: resource.formatted_params, response: resource.formatted_response }) end |
#write(stream) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/apidoc.rb', line 102 def write(stream) @runner.run stream.write( Mustache.to_html(File.read(File.dirname(__FILE__) + '/../templates/layout.mustache'), { content: @runner.resources.map {|r| resource_html(r) }.join }) ) stream.rewind stream end |