rumdl_lib/rules/md057_existing_relative_links/md057_config.rs
1use crate::rule_config_serde::RuleConfig;
2use serde::{Deserialize, Serialize};
3
4/// How to handle absolute links (paths starting with /)
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
6#[serde(rename_all = "snake_case")]
7pub enum AbsoluteLinksOption {
8 /// Ignore absolute links (don't validate them) - this is the default
9 #[default]
10 Ignore,
11 /// Warn about absolute links (they can't be validated as local paths)
12 Warn,
13 /// Resolve absolute links relative to MkDocs docs_dir and validate
14 RelativeToDocs,
15}
16
17/// Configuration for MD057 (relative link validation)
18///
19/// This rule validates that relative links point to existing files.
20#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
21#[serde(default, rename_all = "kebab-case")]
22pub struct MD057Config {
23 /// How to handle absolute links (paths starting with /)
24 /// - "ignore" (default): Skip validation for absolute links
25 /// - "warn": Report a warning for absolute links
26 /// - "relative_to_docs": Resolve relative to MkDocs docs_dir and validate
27 #[serde(alias = "absolute_links")]
28 pub absolute_links: AbsoluteLinksOption,
29
30 /// Warn when relative links contain unnecessary path traversal.
31 /// When enabled, `../sub_dir/file.md` from within `sub_dir/` warns
32 /// and suggests the shorter equivalent `file.md`.
33 #[serde(alias = "compact_paths")]
34 pub compact_paths: bool,
35}
36
37impl RuleConfig for MD057Config {
38 const RULE_NAME: &'static str = "MD057";
39}