mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-31 15:47:41 +00:00
Move some MkDocs responsibilities around (#5542)
## Summary Note that I've also changed from `mkdocs serve` to `mkdocs serve -f mkdocs.generated.yml` to be clearer that this is a generated file.
This commit is contained in:
parent
cdb9fda3b8
commit
ea270da289
8 changed files with 19 additions and 25 deletions
|
@ -32,10 +32,6 @@ SECTIONS: list[Section] = [
|
|||
Section("Contributing", "contributing.md", generated=True),
|
||||
]
|
||||
|
||||
FATHOM_SCRIPT: str = (
|
||||
'<script src="https://cdn.usefathom.com/script.js" data-site="DUAEBFLB" defer>'
|
||||
"</script>"
|
||||
)
|
||||
|
||||
LINK_REWRITES: dict[str, str] = {
|
||||
"https://beta.ruff.rs/docs/": "index.md",
|
||||
|
@ -45,7 +41,6 @@ LINK_REWRITES: dict[str, str] = {
|
|||
),
|
||||
"https://beta.ruff.rs/docs/contributing/": "contributing.md",
|
||||
"https://beta.ruff.rs/docs/editor-integrations/": "editor-integrations.md",
|
||||
"https://beta.ruff.rs/docs/faq/": "faq.md",
|
||||
"https://beta.ruff.rs/docs/faq/#how-does-ruff-compare-to-flake8": (
|
||||
"faq.md#how-does-ruff-compare-to-flake8"
|
||||
),
|
||||
|
@ -53,7 +48,6 @@ LINK_REWRITES: dict[str, str] = {
|
|||
"https://beta.ruff.rs/docs/rules/": "rules.md",
|
||||
"https://beta.ruff.rs/docs/rules/#error-e": "rules.md#error-e",
|
||||
"https://beta.ruff.rs/docs/settings/": "settings.md",
|
||||
"https://beta.ruff.rs/docs/usage/": "usage.md",
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,7 +86,13 @@ def main() -> None:
|
|||
|
||||
# Rewrite links to the documentation.
|
||||
for src, dst in LINK_REWRITES.items():
|
||||
content = content.replace(f"({src})", f"({dst})")
|
||||
before = content
|
||||
after = content.replace(f"({src})", f"({dst})")
|
||||
if before == after:
|
||||
msg = f"Unexpected link rewrite in README.md: {src}"
|
||||
raise ValueError(msg)
|
||||
content = after
|
||||
|
||||
if m := re.search(r"\(https://beta.ruff.rs/docs/.*\)", content):
|
||||
msg = f"Unexpected absolute link to documentation: {m.group(0)}"
|
||||
raise ValueError(msg)
|
||||
|
@ -140,18 +140,8 @@ def main() -> None:
|
|||
with Path("mkdocs.template.yml").open(encoding="utf8") as fp:
|
||||
config = yaml.safe_load(fp)
|
||||
config["nav"] = [{section.title: section.filename} for section in SECTIONS]
|
||||
config["extra"] = {"analytics": {"provider": "fathom"}}
|
||||
|
||||
Path(".overrides/partials/integrations/analytics").mkdir(
|
||||
parents=True,
|
||||
exist_ok=True,
|
||||
)
|
||||
with Path(".overrides/partials/integrations/analytics/fathom.html").open(
|
||||
"w+",
|
||||
) as fp:
|
||||
fp.write(FATHOM_SCRIPT)
|
||||
|
||||
with Path("mkdocs.yml").open("w+") as fp:
|
||||
with Path("mkdocs.generated.yml").open("w+") as fp:
|
||||
yaml.safe_dump(config, fp)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue