Class: Yard::Yaml::Config
- Inherits:
-
Object
- Object
- Yard::Yaml::Config
- Defined in:
- lib/yard/yaml/config.rb
Overview
Configuration for the yard-yaml plugin.
Phase 0: This is a data holder only; wiring into YARD will happen in later phases.
Defaults are intentionally conservative and match the PRD/plan.
Nothing here modifies YARD behavior when merely required.
Constant Summary collapse
- DEFAULT_INCLUDE =
Default glob patterns to include during discovery.
[ "docs/**/*.y{a,}ml", "*.y{a,}ml", # CFF (Citation File Format) files are valid YAML; include them by default. "docs/**/*.cff", "*.cff", ].freeze
- DEFAULT_EXCLUDE =
Default glob patterns to exclude during discovery.
[ "**/_*.y{a,}ml", "**/_*.cff", ].freeze
- DEFAULT_OUT_DIR =
Directory (under YARD output) where converted pages will be written.
"yaml"- DEFAULT_INDEX =
Whether to generate an index page for YAML documents.
true- DEFAULT_TOC =
Table of contents generation strategy.
“auto” defers to converter/page size; additional options may be added later. "auto"- DEFAULT_CONVERTER_OPTIONS =
Options forwarded to yaml-converter.
{}.freeze
- DEFAULT_FRONT_MATTER =
Whether to respect YAML front matter for title/nav order.
true- DEFAULT_STRICT =
When true, errors are raised and should fail the build (later phases).
false- DEFAULT_ALLOW_ERB =
Whether to allow ERB processing inside YAML (disabled by default for safety).
false
Instance Attribute Summary collapse
-
#allow_erb ⇒ Object
Returns the value of attribute allow_erb.
-
#converter_options ⇒ Object
Returns the value of attribute converter_options.
-
#exclude ⇒ Object
Returns the value of attribute exclude.
-
#front_matter ⇒ Object
Returns the value of attribute front_matter.
-
#include ⇒ Object
Returns the value of attribute include.
-
#index ⇒ Object
Returns the value of attribute index.
-
#out_dir ⇒ Object
Returns the value of attribute out_dir.
-
#strict ⇒ Object
Returns the value of attribute strict.
-
#toc ⇒ Object
Returns the value of attribute toc.
Instance Method Summary collapse
-
#apply(hash) ⇒ self
Apply a set of overrides to this config instance.
-
#initialize(overrides = {}) ⇒ Config
constructor
Create a new Config with defaults, optionally overridden via a hash.
Constructor Details
#initialize(overrides = {}) ⇒ Config
Create a new Config with defaults, optionally overridden via a hash.
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/yard/yaml/config.rb', line 62 def initialize(overrides = {}) @include = DEFAULT_INCLUDE.dup @exclude = DEFAULT_EXCLUDE.dup @out_dir = DEFAULT_OUT_DIR.dup @index = DEFAULT_INDEX @toc = DEFAULT_TOC.dup @converter_options = DEFAULT_CONVERTER_OPTIONS.dup @front_matter = DEFAULT_FRONT_MATTER @strict = DEFAULT_STRICT @allow_erb = DEFAULT_ALLOW_ERB apply(overrides) unless overrides.nil? || overrides.empty? end |
Instance Attribute Details
#allow_erb ⇒ Object
Returns the value of attribute allow_erb.
49 50 51 |
# File 'lib/yard/yaml/config.rb', line 49 def allow_erb @allow_erb end |
#converter_options ⇒ Object
Returns the value of attribute converter_options.
49 50 51 |
# File 'lib/yard/yaml/config.rb', line 49 def @converter_options end |
#exclude ⇒ Object
Returns the value of attribute exclude.
49 50 51 |
# File 'lib/yard/yaml/config.rb', line 49 def exclude @exclude end |
#front_matter ⇒ Object
Returns the value of attribute front_matter.
49 50 51 |
# File 'lib/yard/yaml/config.rb', line 49 def front_matter @front_matter end |
#include ⇒ Object
Returns the value of attribute include.
49 50 51 |
# File 'lib/yard/yaml/config.rb', line 49 def include @include end |
#index ⇒ Object
Returns the value of attribute index.
49 50 51 |
# File 'lib/yard/yaml/config.rb', line 49 def index @index end |
#out_dir ⇒ Object
Returns the value of attribute out_dir.
49 50 51 |
# File 'lib/yard/yaml/config.rb', line 49 def out_dir @out_dir end |
#strict ⇒ Object
Returns the value of attribute strict.
49 50 51 |
# File 'lib/yard/yaml/config.rb', line 49 def strict @strict end |
#toc ⇒ Object
Returns the value of attribute toc.
49 50 51 |
# File 'lib/yard/yaml/config.rb', line 49 def toc @toc end |
Instance Method Details
#apply(hash) ⇒ self
Apply a set of overrides to this config instance.
Unknown keys are ignored in Phase 0 (later phases may warn).
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/yard/yaml/config.rb', line 81 def apply(hash) hash.each do |key, value| case key.to_sym when :include then @include = Array(value).map(&:to_s) when :exclude then @exclude = Array(value).map(&:to_s) when :out_dir then @out_dir = value.to_s when :index then @index = coerce_bool(value) when :toc then @toc = value.to_s when :converter_options then @converter_options = value || {} when :front_matter then @front_matter = coerce_bool(value) when :strict then @strict = coerce_bool(value) when :allow_erb then @allow_erb = coerce_bool(value) else # Intentionally ignore unknown keys in Phase 0 end end self end |