Class: Chiridion::Config
- Inherits:
-
Object
- Object
- Chiridion::Config
- Defined in:
- lib/chiridion/config.rb
Overview
Configuration for documentation generation.
Chiridion can be configured globally or per-engine instance. All options have sensible defaults for common Ruby project layouts.
Instance Attribute Summary collapse
-
#github_branch ⇒ String
Git branch for source links.
-
#github_repo ⇒ String?
GitHub repository for source links (e.g., “user/repo”).
-
#include_specs ⇒ Boolean
Whether to extract examples from spec files.
-
#inline_source_threshold ⇒ Integer?
Maximum body lines for inline source display.
-
#logger ⇒ #info, ...
Logger for output messages.
-
#namespace_filter ⇒ String?
Namespace prefix to filter (e.g., “MyProject::”) Only classes/modules starting with this prefix are documented.
-
#namespace_strip ⇒ Object
Namespace prefix to strip from output paths.
-
#output ⇒ String
Output directory for generated docs.
-
#output_mode ⇒ Symbol
Output organization strategy (:per_class or :per_file).
-
#rbs_path ⇒ String
Path to RBS signatures directory (relative to root).
-
#root ⇒ String
Root directory of the project (defaults to current directory).
-
#source_path ⇒ String
Source directory to document (relative to root).
-
#spec_path ⇒ String
Path to test directory (relative to root).
-
#verbose ⇒ Boolean
Verbose output during generation.
Instance Method Summary collapse
-
#full_output_path ⇒ String
Full path to output directory.
-
#full_rbs_path ⇒ String
Full path to RBS directory.
-
#full_source_path ⇒ String
Full path to source directory.
-
#full_spec_path ⇒ String
Full path to spec directory.
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#load_file(path) ⇒ Config
Load configuration from a YAML file.
-
#load_hash(data) ⇒ Config
Load configuration from a hash.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/chiridion/config.rb', line 71 def initialize @root = Dir.pwd @source_path = "lib" @output = "docs/sys" @namespace_filter = nil @namespace_strip = nil @github_repo = nil @github_branch = "main" @include_specs = false @spec_path = "test" @rbs_path = "sig" @verbose = false @logger = nil @inline_source_threshold = 10 @output_mode = :per_file end |
Instance Attribute Details
#github_branch ⇒ String
Returns Git branch for source links.
46 47 48 |
# File 'lib/chiridion/config.rb', line 46 def github_branch @github_branch end |
#github_repo ⇒ String?
Returns GitHub repository for source links (e.g., “user/repo”).
43 44 45 |
# File 'lib/chiridion/config.rb', line 43 def github_repo @github_repo end |
#include_specs ⇒ Boolean
Returns Whether to extract examples from spec files.
49 50 51 |
# File 'lib/chiridion/config.rb', line 49 def include_specs @include_specs end |
#inline_source_threshold ⇒ Integer?
Returns Maximum body lines for inline source display. Methods with body <= this many lines show their implementation inline. Set to nil or 0 to disable inline source. Default: 10.
66 67 68 |
# File 'lib/chiridion/config.rb', line 66 def inline_source_threshold @inline_source_threshold end |
#logger ⇒ #info, ...
Returns Logger for output messages.
61 62 63 |
# File 'lib/chiridion/config.rb', line 61 def logger @logger end |
#namespace_filter ⇒ String?
Returns Namespace prefix to filter (e.g., “MyProject::”) Only classes/modules starting with this prefix are documented. If nil, all classes are included.
36 37 38 |
# File 'lib/chiridion/config.rb', line 36 def namespace_filter @namespace_filter end |
#namespace_strip ⇒ Object
Namespace prefix to strip from output paths. Defaults to namespace_filter if not explicitly set.
90 |
# File 'lib/chiridion/config.rb', line 90 def namespace_strip = @namespace_strip || @namespace_filter |
#output ⇒ String
Returns Output directory for generated docs.
31 32 33 |
# File 'lib/chiridion/config.rb', line 31 def output @output end |
#output_mode ⇒ Symbol
Returns Output organization strategy (:per_class or :per_file).
69 70 71 |
# File 'lib/chiridion/config.rb', line 69 def output_mode @output_mode end |
#rbs_path ⇒ String
Returns Path to RBS signatures directory (relative to root).
55 56 57 |
# File 'lib/chiridion/config.rb', line 55 def rbs_path @rbs_path end |
#root ⇒ String
Returns Root directory of the project (defaults to current directory).
25 26 27 |
# File 'lib/chiridion/config.rb', line 25 def root @root end |
#source_path ⇒ String
Returns Source directory to document (relative to root).
28 29 30 |
# File 'lib/chiridion/config.rb', line 28 def source_path @source_path end |
#spec_path ⇒ String
Returns Path to test directory (relative to root).
52 53 54 |
# File 'lib/chiridion/config.rb', line 52 def spec_path @spec_path end |
#verbose ⇒ Boolean
Returns Verbose output during generation.
58 59 60 |
# File 'lib/chiridion/config.rb', line 58 def verbose @verbose end |
Instance Method Details
#full_output_path ⇒ String
Returns Full path to output directory.
120 |
# File 'lib/chiridion/config.rb', line 120 def full_output_path = File.join(root, output) |
#full_rbs_path ⇒ String
Returns Full path to RBS directory.
126 |
# File 'lib/chiridion/config.rb', line 126 def full_rbs_path = File.join(root, rbs_path) |
#full_source_path ⇒ String
Returns Full path to source directory.
117 |
# File 'lib/chiridion/config.rb', line 117 def full_source_path = File.join(root, source_path) |
#full_spec_path ⇒ String
Returns Full path to spec directory.
123 |
# File 'lib/chiridion/config.rb', line 123 def full_spec_path = File.join(root, spec_path) |
#load_file(path) ⇒ Config
Load configuration from a YAML file.
96 97 98 99 100 101 102 |
# File 'lib/chiridion/config.rb', line 96 def load_file(path) return self unless File.exist?(path) require "yaml" data = YAML.safe_load_file(path, symbolize_names: true) load_hash(data) end |
#load_hash(data) ⇒ Config
Load configuration from a hash.
108 109 110 111 112 113 114 |
# File 'lib/chiridion/config.rb', line 108 def load_hash(data) data.each do |key, value| setter = :"#{key}=" public_send(setter, value) if respond_to?(setter) end self end |