Class: Docbook::Output::Formats::DomFormat
Constant Summary
Constants inherited
from BaseFormat
BaseFormat::DEFAULT_DIST_DIR
Instance Attribute Summary
Attributes inherited from BaseFormat
#dist_dir
Instance Method Summary
collapse
Methods inherited from BaseFormat
default_dist_dir, #initialize
Instance Method Details
#write(output_path, guide, title: "DocBook", _manifest: nil) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/docbook/output/formats/dom_format.rb', line 11
def write(output_path, guide, title: "DocBook", _manifest: nil)
FileUtils.mkdir_p(File.dirname(output_path))
renderer = HtmlRenderer.new(guide)
content_html = renderer.render
body = <<~HTML
<div id="docbook-content">#{content_html}</div>
<div id="docbook-app"></div>
HTML
data_script = "window.DOCBOOK_DATA = #{safe_json(guide)}; window.DOCBOOK_FORMAT = 'dom';"
html = html_boilerplate(title: title, body_content: body,
script_data: data_script)
File.write(output_path, html)
output_path
end
|
#write_library(output_path, guides, manifest:, title: nil) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/docbook/output/formats/dom_format.rb', line 28
def write_library(output_path, guides, manifest:, title: nil)
title ||= manifest.name || "DocBook Library"
collection_data = build_collection_data(guides, manifest)
data_script = "window.DOCBOOK_COLLECTION = #{safe_json(collection_data)}; window.DOCBOOK_FORMAT = 'dom';"
html = html_boilerplate(title: title, body_content: '<div id="docbook-app"></div>',
script_data: data_script)
FileUtils.mkdir_p(File.dirname(output_path))
File.write(output_path, html)
output_path
end
|