pub struct Config { /* private fields */ }Expand description
Resolved project configuration. Construct with
Config::load_explicit (for --config PATH) or
Config::discover (for the ancestor walk from CWD).
Implementations§
Source§impl Config
impl Config
Sourcepub fn load_explicit(path: &Path) -> Result<Self, ConfigError>
pub fn load_explicit(path: &Path) -> Result<Self, ConfigError>
Load configuration from exactly path. Used for --config PATH.
§Errors
Returns ConfigError if the file is missing, unreadable,
malformed TOML, or fails schema validation (an unknown key or a
malformed value is an error, not a silent default).
Sourcepub fn discover(cwd: &Path) -> Result<Self, ConfigError>
pub fn discover(cwd: &Path) -> Result<Self, ConfigError>
Discover the nearest applicable config by walking upward from
cwd. At each directory, candidates are tried in precedence
order: .mdwright.toml, then mdwright.toml, then
pyproject.toml’s [tool.mdwright] table (a pyproject.toml
without that table does not stop the walk). The walk stops
at the filesystem root or the first directory containing a
.git/ entry (the workspace boundary).
Returns the all-defaults instance if no candidate is found. Absence of a config file is not an error.
§Errors
Returns ConfigError if a candidate file is found but cannot
be read, parsed as TOML, or matched against the schema.
Sourcepub fn source(&self) -> Option<&Path>
pub fn source(&self) -> Option<&Path>
Path of the configuration file this Config was loaded from,
or None if no file was used (the defaults instance).
Sourcepub fn source_dir(&self) -> Option<&Path>
pub fn source_dir(&self) -> Option<&Path>
Directory containing the configuration file, useful as the
base for resolving relative paths inside the config (e.g.
[lint] exclude globs). None when no file was loaded; in
that case callers typically use $PWD as the base.
Sourcepub fn lint_rule_selection(&self) -> &LintRuleSelection
pub fn lint_rule_selection(&self) -> &LintRuleSelection
Resolved lint rule selection from [lint].
Sourcepub fn exclude_globs(&self) -> &[String]
pub fn exclude_globs(&self) -> &[String]
Gitignore-style patterns from [lint] exclude. Files matching
any pattern are dropped from lint runs.
Sourcepub fn extra_info_strings(&self) -> &[String]
pub fn extra_info_strings(&self) -> &[String]
Project-specific allowlist extension for info-string-typo.
The stdlib default still applies; these are additions.
Sourcepub fn fmt_options(&self) -> &FmtOptions
pub fn fmt_options(&self) -> &FmtOptions
Resolved formatter knobs from [fmt]. Formatter sessions are
the first consumers; the lint side ignores these.
Sourcepub fn parse_options(&self) -> ParseOptions
pub fn parse_options(&self) -> ParseOptions
Resolved Markdown recognition policy.
Sourcepub fn render_options(&self) -> RenderOptions
pub fn render_options(&self) -> RenderOptions
Resolved HTML rendering policy.
Sourcepub fn defaults() -> Self
pub fn defaults() -> Self
The all-defaults Config — what Self::discover returns
when no .mdwright.toml / mdwright.toml / pyproject.toml
is found on the upward walk. Exposed for long-lived processes
(the LSP server) that need a synchronous fallback when
discover encounters an unreadable config file mid-walk.