Class: Yard::Yaml::Emitter
- Inherits:
-
Object
- Object
- Yard::Yaml::Emitter
- Defined in:
- lib/yard/yaml/emitter.rb
Overview
Writes converted YAML pages to the YARD output directory.
Phase 4 scope:
-
Emits per-page HTML files under <output>/<config.out_dir>/
-
Optionally emits an index.html when config.index is true
-
Keeps implementation independent of YARD internals; caller passes output_dir
-
Deterministic filenames and ordering
This class purposefully uses a tiny built-in template to keep behavior deterministic for tests. In a later phase, we can wire ERB templates via YARD::Templates::Engine and theme hooks.
Class Method Summary collapse
-
.emit!(pages:, output_dir:, config: Yard::Yaml.config) ⇒ Array<String>
Emit all pages to disk.
-
.slug_for(page) ⇒ String
Public: derive a stable slug for a page hash.
Class Method Details
.emit!(pages:, output_dir:, config: Yard::Yaml.config) ⇒ Array<String>
Emit all pages to disk.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/yard/yaml/emitter.rb', line 26 def emit!(pages:, output_dir:, config: Yard::Yaml.config) pages = Array(pages) written = [] base = File.join(output_dir.to_s, config.out_dir.to_s) FileUtils.mkdir_p(base) # Write per-page files pages.each do |page| slug = page_slug(page) path = File.join(base, "#{slug}.html") html = render_page_html(page) atomic_write(path, html, strict: config.strict) written << path end # Index (optional) if config.index index_path = File.join(base, "index.html") html = render_index_html(pages) atomic_write(index_path, html, strict: config.strict) written << index_path end written end |
.slug_for(page) ⇒ String
Public: derive a stable slug for a page hash. Shared by templates.
55 56 57 |
# File 'lib/yard/yaml/emitter.rb', line 55 def slug_for(page) page_slug(page) end |