Class: Metanorma::Taste::Base
- Inherits:
-
Object
- Object
- Metanorma::Taste::Base
- Defined in:
- lib/metanorma/taste/base.rb,
lib/metanorma/taste/stage.rb,
lib/metanorma/taste/doctype.rb,
lib/metanorma/taste/committee.rb
Overview
Base processor for taste-specific document attribute handling
This class handles the processing of AsciiDoc attributes for taste-specific # document generation, including filename-based attributes, value-based attributes, and doctype-specific transformations.
Constant Summary collapse
- VALUE_ATTRIBUTE_MAPPINGS =
Mapping of value-based attribute configuration keys to AsciiDoc attribute names
This constant defines how base_override.value_attributes configuration properties are translated into AsciiDoc document attributes.
TODO: metaprogramming to extract these from value_attributes.rb
{ publisher: "publisher", publisher_abbr: "publisher_abbr", presentation_metadata_color_secondary: "presentation-metadata-color-secondary", presentation_metadata_backcover_text: "presentation-metadata-backcover-text", presentation_metadata_ul_label_list: "presentation-metadata-ul-label-list", presentation_metadata_annex_delim: "presentation-metadata-annex-delim", presentation_metadata_middle_title: "presentation-metadata-middle-title", presentation_metadata_ol_label_template_alphabet: "presentation-metadata-ol-label-template-alphabet", presentation_metadata_ol_label_template_alphabet_upper: "presentation-metadata-ol-label-template-alphabet_upper", presentation_metadata_ol_label_template_roman: "presentation-metadata-ol-label-template-roman", presentation_metadata_ol_label_template_roman_upper: "presentation-metadata-ol-label-template-roman_upper", presentation_metadata_ol_label_template_arabic: "presentation-metadata-ol-label-template-arabic", body_font: "body-font", header_font: "header-font", monospace_font: "monospace-font", fonts: "fonts", docidentifier: "docidentifier", output_extensions: "output-extensions", toclevels: "toclevels", htmltoclevels: "toclevels-html", doctoclevels: "toclevels-doc", pdftoclevels: "toclevels-pdf", toc_figures: "toc-figures", toc_tables: "toc-tables", toc_recommendations: "toc-recommendations", }.freeze
- VALUE_ATTR_ADDITIVE =
Additive value attributes: if the document already has a value for this attribute, add the taste config values to it
{ fonts: { delimiter: ";" }, }.freeze
Instance Attribute Summary collapse
-
#config ⇒ TasteConfig
readonly
The taste configuration object.
-
#directory ⇒ String
readonly
is stored, including file attributes.
-
#flavor ⇒ String, Symbol
readonly
The flavor identifier (e.g., :icc, :elf).
Instance Method Summary collapse
-
#build_all_attribute_overrides(attrs) ⇒ Array<Array<String>, Array<String>>
Build all attribute overrides from various sources.
-
#initialize(flavor, config, directory: Dir.pwd) ⇒ Base
constructor
Initialize a new Base processor.
-
#process_input_adoc_overrides(attrs, options) ⇒ Array<String>
Process input AsciiDoc attributes with taste-specific overrides.
Constructor Details
#initialize(flavor, config, directory: Dir.pwd) ⇒ Base
Initialize a new Base processor
94 95 96 97 98 |
# File 'lib/metanorma/taste/base.rb', line 94 def initialize(flavor, config, directory: Dir.pwd) @flavor = flavor @config = config @directory = directory end |
Instance Attribute Details
#config ⇒ TasteConfig (readonly)
Returns The taste configuration object.
34 35 36 |
# File 'lib/metanorma/taste/base.rb', line 34 def config @config end |
#directory ⇒ String (readonly)
is stored, including file attributes
38 39 40 |
# File 'lib/metanorma/taste/base.rb', line 38 def directory @directory end |
#flavor ⇒ String, Symbol (readonly)
Returns The flavor identifier (e.g., :icc, :elf).
31 32 33 |
# File 'lib/metanorma/taste/base.rb', line 31 def flavor @flavor end |
Instance Method Details
#build_all_attribute_overrides(attrs) ⇒ Array<Array<String>, Array<String>>
Build all attribute overrides from various sources
This method coordinates the building of attributes from:
-
Filename-based attributes (copyright, logo, i18n, stylesheets)
-
Value-based attributes (publisher, fonts, presentation metadata)
-
Doctype-specific overrides
-
Committee overrides
143 144 145 146 147 148 149 150 151 152 |
# File 'lib/metanorma/taste/base.rb', line 143 def build_all_attribute_overrides(attrs) override_attrs = [] # Add attributes from different sources add_file_based_overrides(override_attrs) add_base_configuration_overrides(override_attrs, attrs) apply_doctype_overrides(attrs, override_attrs) apply_stage_overrides(attrs, override_attrs) apply_committee_overrides(attrs, override_attrs) [attrs, override_attrs] end |
#process_input_adoc_overrides(attrs, options) ⇒ Array<String>
Process input AsciiDoc attributes with taste-specific overrides
This is the main entry point for attribute processing. It applies file-based overrides, base configuration overrides, and doctype transformations to the input attributes.
settings
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/metanorma/taste/base.rb', line 116 def process_input_adoc_overrides(attrs, ) # Insert new attributes after the second element # (or at the end if fewer elements) insertion_index = calculate_insertion_index(attrs) # Build and insert override attributes attrs, override_attrs = build_all_attribute_overrides(attrs) unless override_attrs.empty? attrs.insert(insertion_index, *override_attrs) end # Set boilerplate authority in options if copyright notice exists () attrs end |