Class: Docbook::Services::TocGenerator

Inherits:
Object
  • Object
show all
Includes:
ElementIdHelper
Defined in:
lib/docbook/services/toc_generator.rb

Overview

Generates hierarchical TOC from document sections

Instance Method Summary collapse

Methods included from ElementIdHelper

#element_id, #refentry_id, #resolve_refentry_title

Constructor Details

#initialize(document) ⇒ TocGenerator

Returns a new instance of TocGenerator.

Parameters:



10
11
12
# File 'lib/docbook/services/toc_generator.rb', line 10

def initialize(document)
  @document = document
end

Instance Method Details

#generateArray<Models::TocNode>

Build a tree of Models::TocNode from the document structure.

Returns:



16
17
18
19
# File 'lib/docbook/services/toc_generator.rb', line 16

def generate
  root_elements = get_root_elements
  root_elements.filter_map { |element| build_toc_node(element) }
end