Class: Chiridion::Engine::FrontmatterBuilder
- Inherits:
-
Object
- Object
- Chiridion::Engine::FrontmatterBuilder
- Defined in:
- lib/chiridion/engine/frontmatter_builder.rb
Overview
Builds enhanced YAML frontmatter for documentation files.
Generates Obsidian-compatible frontmatter with navigation aids, discovery metadata, and search-friendly fields. Each documentation file gets frontmatter that enables:
-
Navigation: parent links for breadcrumb traversal
-
Discovery: tags for filtering, related links for exploration
-
Search: aliases for finding by short name, description for preview
Instance Method Summary collapse
-
#build(obj) ⇒ Hash
Build frontmatter hash for a class or module.
-
#build_index ⇒ Hash
Build frontmatter for index page.
-
#initialize(class_linker, namespace_strip: nil, project_title: "API Documentation") ⇒ FrontmatterBuilder
constructor
A new instance of FrontmatterBuilder.
-
#register_inheritance(structure) ⇒ Object
Pre-compute inheritance relationships from full structure.
Constructor Details
#initialize(class_linker, namespace_strip: nil, project_title: "API Documentation") ⇒ FrontmatterBuilder
Returns a new instance of FrontmatterBuilder.
17 18 19 20 21 22 |
# File 'lib/chiridion/engine/frontmatter_builder.rb', line 17 def initialize(class_linker, namespace_strip: nil, project_title: "API Documentation") @class_linker = class_linker @namespace_strip = namespace_strip @project_title = project_title @inheritance_children = {} # Maps parent class path -> array of child class paths end |
Instance Method Details
#build(obj) ⇒ Hash
Build frontmatter hash for a class or module.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/chiridion/engine/frontmatter_builder.rb', line 45 def build(obj) { generated: Time.now.utc.iso8601, title: obj[:path], type: obj[:type].to_s, # :class or :module source: relative_path(obj[:file]), description: extract_description(obj[:docstring]), inherits: build_inherits_link(obj[:superclass]), parent: build_parent_link(obj[:path]), inherited_by: build_inherited_by_links(obj[:path]), includes: build_mixin_list(obj[:includes]), extends: build_mixin_list(obj[:extends]), rbs: obj[:rbs_file] ? relative_path(obj[:rbs_file]) : nil, tags: (obj[:path]), aliases: build_aliases(obj[:path]), constants: build_constant_list(obj[:constants]), methods: build_method_list(obj[:methods], obj[:path]), related: (obj) }.compact end |
#build_index ⇒ Hash
Build frontmatter for index page.
69 70 71 72 73 74 75 |
# File 'lib/chiridion/engine/frontmatter_builder.rb', line 69 def build_index { generated: Time.now.utc.iso8601, title: @project_title, tags: %w[index api-reference] } end |
#register_inheritance(structure) ⇒ Object
Pre-compute inheritance relationships from full structure.
Must be called before build() to populate inherited-by fields. Scans all classes to build parent->children mapping.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/chiridion/engine/frontmatter_builder.rb', line 30 def register_inheritance(structure) @inheritance_children = {} structure[:classes].each do |klass| parent = klass[:superclass] next unless parent && documentable_class?(parent) @inheritance_children[parent] ||= [] @inheritance_children[parent] << klass[:path] end end |