Class: DocGen::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/doc_gen/renderer.rb

Overview

Renders a tree of Context objects to Jekyll-compatible Markdown files.

Frontmatter fields produced:

layout, title, parmalink (sic - preserved from original for compatibility),
has_children, has_toc, parent, grand_parent (when applicable)

Jekyll nav hierarchy (just-the-docs):

depth 0  ->  parent: "Test Suite"  (no grand_parent)
depth 1  ->  parent: <root name>,  grand_parent: "Test Suite"
depth 2+ ->  parent: <direct parent name>,  grand_parent: <grandparent name or "Test Suite">

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output_dir:) ⇒ Renderer

Returns a new instance of Renderer.



23
24
25
# File 'lib/doc_gen/renderer.rb', line 23

def initialize(output_dir:)
  @output_dir = output_dir
end

Class Method Details

.render(contexts, output_dir:) ⇒ Object

Render an array of root Context objects to output_dir.



19
20
21
# File 'lib/doc_gen/renderer.rb', line 19

def self.render(contexts, output_dir:)
  new(output_dir: output_dir).render(contexts)
end

Instance Method Details

#render(contexts) ⇒ Object



27
28
29
30
# File 'lib/doc_gen/renderer.rb', line 27

def render(contexts)
  FileUtils.mkdir_p(@output_dir)
  contexts.each { |ctx| render_context(ctx) }
end