Class: RSpecDocumentation::PageTree

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_documentation/page_tree.rb

Overview

A hierarchical structure of all pages in the documentation tree. Used for rendering a navigation section.

Instance Method Summary collapse

Constructor Details

#initialize(page_paths:, current_path:) ⇒ PageTree

Returns a new instance of PageTree.



6
7
8
9
10
11
# File 'lib/rspec_documentation/page_tree.rb', line 6

def initialize(page_paths:, current_path:)
  @page_paths = page_paths
  @current_path = current_path
  @structure = {}
  @nodes = []
end

Instance Method Details

#elementsObject



13
14
15
16
17
18
19
# File 'lib/rspec_documentation/page_tree.rb', line 13

def elements
  build_nodes(
    root: tree['rspec-documentation']['pages'],
    path: root_path.join('rspec-documentation/pages')
  )
  nodes.flatten.compact
end