Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect from rule codes to rule pages in docs #8636

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/requirements-insiders.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ PyYAML==6.0.1
black==23.10.0
mkdocs==1.5.0
git+ssh://git@github.com/astral-sh/mkdocs-material-insiders.git@38c0b8187325c3bab386b666daf3518ac036f2f4
mkdocs-redirects==1.2.1
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ PyYAML==6.0.1
black==23.10.0
mkdocs==1.5.0
mkdocs-material==9.1.18
mkdocs-redirects==1.2.1
3 changes: 0 additions & 3 deletions mkdocs.insiders.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
INHERIT: mkdocs.generated.yml
plugins:
- search
- typeset
1 change: 1 addition & 0 deletions mkdocs.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ markdown_extensions:
alternate_style: true
plugins:
- search
- typeset
extra_css:
- stylesheets/extra.css
not_in_nav: |
Expand Down
31 changes: 30 additions & 1 deletion scripts/generate_mkdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

import argparse
import json
import re
import shutil
import subprocess
Expand Down Expand Up @@ -138,9 +139,37 @@ def main() -> None:

f.write(clean_file_content(file_content, title))

# Add the nav section to mkdocs.yml.
with Path("mkdocs.template.yml").open(encoding="utf8") as fp:
config = yaml.safe_load(fp)

# Add the redirect section to mkdocs.yml.
rules = json.loads(
subprocess.check_output(
[
"cargo",
"run",
"-p",
"ruff_cli",
"--",
"rule",
"--all",
"--output-format",
"json",
],
),
)
config["plugins"].append(
{
"redirects": {
"redirect_maps": {
f'rules/{rule["code"]}.md': f'rules/{rule["name"]}.md'
for rule in rules
},
},
},
)

# Add the nav section to mkdocs.yml.
config["nav"] = [{section.title: section.filename} for section in SECTIONS]

with Path("mkdocs.generated.yml").open("w+") as fp:
Expand Down
Loading