Class: DocGen::NamespaceBuilder

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

Overview

Builds a namespace tree from flat parsed contexts by merging on ‘::’ segments. e.g. ‘Site::Tlc::Alarm’ becomes Site -> Tlc -> Alarm in the tree.

Instance Method Summary collapse

Instance Method Details

#build(raw_contexts) ⇒ Object



97
98
99
100
101
102
# File 'lib/doc_gen/parser.rb', line 97

def build(raw_contexts)
  @node_map = {}
  sorted = raw_contexts.sort_by { |ctx| ctx.name.include?('::') ? 0 : 1 }
  sorted.each { |raw| process_raw_context(raw) }
  @node_map.values.select { |n| n.parent.nil? }
end