Class: Metanorma::Plugin::Glossarist::SectionRenderer
- Inherits:
-
Object
- Object
- Metanorma::Plugin::Glossarist::SectionRenderer
- Defined in:
- lib/metanorma/plugin/glossarist/section_renderer.rb
Overview
Renders concepts grouped by section, with cascading membership and configurable sort order.
Extracted from DatasetPreprocessor to keep section rendering as a single MECE concern: it owns section → concepts resolution, heading depth, and per-section rendering. Callers retain ownership of the rendered-concept accumulator (passed via the block) so the preprocessor’s global state stays in one place.
Constant Summary collapse
- DEFAULT_SORT_BY =
"term"
Instance Method Summary collapse
-
#initialize(dataset:, register:, renderer:, depth:, **options) ⇒ SectionRenderer
constructor
A new instance of SectionRenderer.
-
#render(sections) {|Array<ManagedConcept>| ... } ⇒ Array<String>
One rendered block per non-empty section.
Constructor Details
#initialize(dataset:, register:, renderer:, depth:, **options) ⇒ SectionRenderer
Returns a new instance of SectionRenderer.
22 23 24 25 26 27 28 29 |
# File 'lib/metanorma/plugin/glossarist/section_renderer.rb', line 22 def initialize(dataset:, register:, renderer:, depth:, **) @dataset = dataset @register = register @renderer = renderer @depth = depth @sort_by = [:sort_by] || DEFAULT_SORT_BY @anchor_prefix = [:anchor_prefix] end |
Instance Method Details
#render(sections) {|Array<ManagedConcept>| ... } ⇒ Array<String>
Returns one rendered block per non-empty section.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/metanorma/plugin/glossarist/section_renderer.rb', line 34 def render(sections) sections.filter_map do |section| concepts = concepts_for(section) next if concepts.empty? yield concepts if block_given? block_for(section, concepts) end end |