Class: Dox::HtmlRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/dox/html_renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(spec_path, output_path, adapter: Dox::RedoclyAdapter.new) ⇒ HtmlRenderer

Returns a new instance of HtmlRenderer.



3
4
5
6
7
# File 'lib/dox/html_renderer.rb', line 3

def initialize(spec_path, output_path, adapter: Dox::RedoclyAdapter.new)
  @spec_path = spec_path
  @output_path = output_path
  @adapter = adapter
end

Instance Method Details

#renderObject



9
10
11
12
13
14
15
16
# File 'lib/dox/html_renderer.rb', line 9

def render
  spec = JSON.load_file(spec_path)
  resolved = resolve_file_refs(spec, ::File.dirname(spec_path))
  title = resolved.dig('info', 'title') || Dox.config.title

  FileUtils.mkdir_p(::File.dirname(output_path))
  ::File.write(output_path, adapter.build_html(title, resolved))
end