mirror of
https://github.com/astral-sh/ruff.git
synced 2025-12-04 01:36:46 +00:00
Split MkDocs site into multiple pages (#2296)
This commit is contained in:
parent
dd79ec293a
commit
071e3fd196
5 changed files with 102 additions and 11 deletions
5
.github/workflows/docs.yaml
vendored
5
.github/workflows/docs.yaml
vendored
|
|
@ -23,9 +23,8 @@ jobs:
|
||||||
- name: "Copy README File"
|
- name: "Copy README File"
|
||||||
run: |
|
run: |
|
||||||
python scripts/transform_readme.py --target mkdocs
|
python scripts/transform_readme.py --target mkdocs
|
||||||
mkdir -p docs/
|
python scripts/generate_mkdocs.py
|
||||||
cp README.md docs/index.md
|
mkdocs build --strict
|
||||||
mkdocs build
|
|
||||||
- name: "Deploy to Cloudflare Pages"
|
- name: "Deploy to Cloudflare Pages"
|
||||||
if: ${{ env.CF_API_TOKEN_EXISTS == 'true' }}
|
if: ${{ env.CF_API_TOKEN_EXISTS == 'true' }}
|
||||||
uses: cloudflare/wrangler-action@2.0.0
|
uses: cloudflare/wrangler-action@2.0.0
|
||||||
|
|
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,7 +1,8 @@
|
||||||
# Local cache
|
# Local cache
|
||||||
.ruff_cache
|
.ruff_cache
|
||||||
resources/test/cpython
|
resources/test/cpython
|
||||||
docs/index.md
|
docs/
|
||||||
|
mkdocs.yml
|
||||||
|
|
||||||
###
|
###
|
||||||
# Rust.gitignore
|
# Rust.gitignore
|
||||||
|
|
|
||||||
36
README.md
36
README.md
|
|
@ -1,3 +1,5 @@
|
||||||
|
<!-- Begin section: Overview -->
|
||||||
|
|
||||||
# Ruff
|
# Ruff
|
||||||
|
|
||||||
[](https://github.com/charliermarsh/ruff)
|
[](https://github.com/charliermarsh/ruff)
|
||||||
|
|
@ -106,6 +108,8 @@ developer of [Zulip](https://github.com/zulip/zulip):
|
||||||
|
|
||||||
> This is just ridiculously fast... `ruff` is amazing.
|
> This is just ridiculously fast... `ruff` is amazing.
|
||||||
|
|
||||||
|
<!-- End section: Overview -->
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
1. [Installation and Usage](#installation-and-usage)
|
1. [Installation and Usage](#installation-and-usage)
|
||||||
|
|
@ -161,6 +165,8 @@ developer of [Zulip](https://github.com/zulip/zulip):
|
||||||
|
|
||||||
## Installation and Usage
|
## Installation and Usage
|
||||||
|
|
||||||
|
<!-- Begin section: Installation and Usage -->
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
Ruff is available as [`ruff`](https://pypi.org/project/ruff/) on PyPI:
|
Ruff is available as [`ruff`](https://pypi.org/project/ruff/) on PyPI:
|
||||||
|
|
@ -221,8 +227,12 @@ Ruff also works with [pre-commit](https://pre-commit.com):
|
||||||
- id: ruff
|
- id: ruff
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- End section: Installation and Usage -->
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
|
<!-- Begin section: Configuration -->
|
||||||
|
|
||||||
Ruff is configurable both via `pyproject.toml` and the command line. For a full list of configurable
|
Ruff is configurable both via `pyproject.toml` and the command line. For a full list of configurable
|
||||||
options, see the [API reference](#reference).
|
options, see the [API reference](#reference).
|
||||||
|
|
||||||
|
|
@ -426,8 +436,6 @@ line-length = 100
|
||||||
All of the above rules apply equivalently to `ruff.toml` files. If Ruff detects both a `ruff.toml`
|
All of the above rules apply equivalently to `ruff.toml` files. If Ruff detects both a `ruff.toml`
|
||||||
and `pyproject.toml` file, it will defer to the `ruff.toml`.
|
and `pyproject.toml` file, it will defer to the `ruff.toml`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Python file discovery
|
### Python file discovery
|
||||||
|
|
||||||
When passed a path on the command-line, Ruff will automatically discover all Python files in that
|
When passed a path on the command-line, Ruff will automatically discover all Python files in that
|
||||||
|
|
@ -503,8 +511,12 @@ Third, Ruff can _automatically add_ `noqa` directives to all failing lines. This
|
||||||
migrating a new codebase to Ruff. You can run `ruff /path/to/file.py --add-noqa` to automatically
|
migrating a new codebase to Ruff. You can run `ruff /path/to/file.py --add-noqa` to automatically
|
||||||
add `noqa` directives to all failing lines, with the appropriate rule codes.
|
add `noqa` directives to all failing lines, with the appropriate rule codes.
|
||||||
|
|
||||||
|
<!-- End section: Configuration -->
|
||||||
|
|
||||||
## Supported Rules
|
## Supported Rules
|
||||||
|
|
||||||
|
<!-- Begin section: Rules -->
|
||||||
|
|
||||||
Regardless of the rule's origin, Ruff re-implements every rule in Rust as a first-party feature.
|
Regardless of the rule's origin, Ruff re-implements every rule in Rust as a first-party feature.
|
||||||
|
|
||||||
By default, Ruff enables Flake8's `E` and `F` rules. Ruff supports all rules from the `F` category,
|
By default, Ruff enables Flake8's `E` and `F` rules. Ruff supports all rules from the `F` category,
|
||||||
|
|
@ -1248,8 +1260,12 @@ For more, see [tryceratops](https://pypi.org/project/tryceratops/1.1.0/) on PyPI
|
||||||
|
|
||||||
<!-- End auto-generated sections. -->
|
<!-- End auto-generated sections. -->
|
||||||
|
|
||||||
|
<!-- End section: Rules -->
|
||||||
|
|
||||||
## Editor Integrations
|
## Editor Integrations
|
||||||
|
|
||||||
|
<!-- Begin section: Editor Integrations -->
|
||||||
|
|
||||||
### VS Code (Official)
|
### VS Code (Official)
|
||||||
|
|
||||||
Download the [Ruff VS Code extension](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff),
|
Download the [Ruff VS Code extension](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff),
|
||||||
|
|
@ -1488,8 +1504,12 @@ jobs:
|
||||||
run: ruff --format=github .
|
run: ruff --format=github .
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!-- End section: Editor Integrations -->
|
||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
|
|
||||||
|
<!-- Begin section: FAQ -->
|
||||||
|
|
||||||
### Is Ruff compatible with Black?
|
### Is Ruff compatible with Black?
|
||||||
|
|
||||||
Yes. Ruff is compatible with [Black](https://github.com/psf/black) out-of-the-box, as long as
|
Yes. Ruff is compatible with [Black](https://github.com/psf/black) out-of-the-box, as long as
|
||||||
|
|
@ -1534,7 +1554,7 @@ natively, including:
|
||||||
- [`flake8-import-conventions`](https://github.com/joaopalmeiro/flake8-import-conventions)
|
- [`flake8-import-conventions`](https://github.com/joaopalmeiro/flake8-import-conventions)
|
||||||
- [`flake8-logging-format`](https://pypi.org/project/flake8-logging-format/)
|
- [`flake8-logging-format`](https://pypi.org/project/flake8-logging-format/)
|
||||||
- [`flake8-no-pep420`](https://pypi.org/project/flake8-no-pep420)
|
- [`flake8-no-pep420`](https://pypi.org/project/flake8-no-pep420)
|
||||||
- [`flake8-pie`](https://pypi.org/project/flake8-pie/) ([#1543](https://github.com/charliermarsh/ruff/issues/1543))
|
- [`flake8-pie`](https://pypi.org/project/flake8-pie/)
|
||||||
- [`flake8-print`](https://pypi.org/project/flake8-print/)
|
- [`flake8-print`](https://pypi.org/project/flake8-print/)
|
||||||
- [`flake8-pytest-style`](https://pypi.org/project/flake8-pytest-style/)
|
- [`flake8-pytest-style`](https://pypi.org/project/flake8-pytest-style/)
|
||||||
- [`flake8-quotes`](https://pypi.org/project/flake8-quotes/)
|
- [`flake8-quotes`](https://pypi.org/project/flake8-quotes/)
|
||||||
|
|
@ -1622,7 +1642,7 @@ Today, Ruff can be used to replace Flake8 when used with any of the following pl
|
||||||
- [`flake8-import-conventions`](https://github.com/joaopalmeiro/flake8-import-conventions)
|
- [`flake8-import-conventions`](https://github.com/joaopalmeiro/flake8-import-conventions)
|
||||||
- [`flake8-logging-format`](https://pypi.org/project/flake8-logging-format/)
|
- [`flake8-logging-format`](https://pypi.org/project/flake8-logging-format/)
|
||||||
- [`flake8-no-pep420`](https://pypi.org/project/flake8-no-pep420)
|
- [`flake8-no-pep420`](https://pypi.org/project/flake8-no-pep420)
|
||||||
- [`flake8-pie`](https://pypi.org/project/flake8-pie/) ([#1543](https://github.com/charliermarsh/ruff/issues/1543))
|
- [`flake8-pie`](https://pypi.org/project/flake8-pie/)
|
||||||
- [`flake8-print`](https://pypi.org/project/flake8-print/)
|
- [`flake8-print`](https://pypi.org/project/flake8-print/)
|
||||||
- [`flake8-pytest-style`](https://pypi.org/project/flake8-pytest-style/)
|
- [`flake8-pytest-style`](https://pypi.org/project/flake8-pytest-style/)
|
||||||
- [`flake8-quotes`](https://pypi.org/project/flake8-quotes/)
|
- [`flake8-quotes`](https://pypi.org/project/flake8-quotes/)
|
||||||
|
|
@ -1796,6 +1816,8 @@ unfixable = ["B", "SIM", "TRY", "RUF"]
|
||||||
|
|
||||||
If you find a case where Ruff's autofix breaks your code, please file an Issue!
|
If you find a case where Ruff's autofix breaks your code, please file an Issue!
|
||||||
|
|
||||||
|
<!-- End section: FAQ -->
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Contributions are welcome and hugely appreciated. To get started, check out the
|
Contributions are welcome and hugely appreciated. To get started, check out the
|
||||||
|
|
@ -1932,7 +1954,9 @@ Benchmark 1: find . -type f -name "*.py" | xargs -P 0 pyupgrade --py311-plus
|
||||||
|
|
||||||
## Reference
|
## Reference
|
||||||
|
|
||||||
### Options
|
<!-- Begin section: Settings -->
|
||||||
|
|
||||||
|
### Top-level
|
||||||
|
|
||||||
<!-- Sections automatically generated by `cargo dev generate-options`. -->
|
<!-- Sections automatically generated by `cargo dev generate-options`. -->
|
||||||
<!-- Begin auto-generated options sections. -->
|
<!-- Begin auto-generated options sections. -->
|
||||||
|
|
@ -3693,6 +3717,8 @@ keep-runtime-typing = true
|
||||||
|
|
||||||
<!-- End auto-generated options sections. -->
|
<!-- End auto-generated options sections. -->
|
||||||
|
|
||||||
|
<!-- End section: Settings -->
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT
|
MIT
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,6 @@ theme:
|
||||||
repo_url: https://github.com/charliermarsh/ruff
|
repo_url: https://github.com/charliermarsh/ruff
|
||||||
repo_name: ruff
|
repo_name: ruff
|
||||||
site_author: charliermarsh
|
site_author: charliermarsh
|
||||||
nav:
|
|
||||||
- Home: index.md
|
|
||||||
markdown_extensions:
|
markdown_extensions:
|
||||||
- toc:
|
- toc:
|
||||||
permalink: "#"
|
permalink: "#"
|
||||||
67
scripts/generate_mkdocs.py
Normal file
67
scripts/generate_mkdocs.py
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
"""Generate an MkDocs-compatible `docs` and `mkdocs.yml` from the README.md."""
|
||||||
|
import argparse
|
||||||
|
import shutil
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
SECTIONS: list[tuple[str, str]] = [
|
||||||
|
("Overview", "index.md"),
|
||||||
|
("Installation and Usage", "installation-and-usage.md"),
|
||||||
|
("Configuration", "configuration.md"),
|
||||||
|
("Rules", "rules.md"),
|
||||||
|
("Settings", "settings.md"),
|
||||||
|
("Editor Integrations", "editor-integrations.md"),
|
||||||
|
("FAQ", "faq.md"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
"""Generate an MkDocs-compatible `docs` and `mkdocs.yml`."""
|
||||||
|
with Path("README.md").open(encoding="utf8") as fp:
|
||||||
|
content = fp.read()
|
||||||
|
|
||||||
|
Path("docs").mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
# Split the README.md into sections.
|
||||||
|
for (title, filename) in SECTIONS:
|
||||||
|
with Path(f"docs/{filename}").open("w+") as f:
|
||||||
|
block = content.split(f"<!-- Begin section: {title} -->")
|
||||||
|
if len(block) != 2:
|
||||||
|
msg = f"Section {title} not found in README.md"
|
||||||
|
raise ValueError(msg)
|
||||||
|
|
||||||
|
block = block[1].split(f"<!-- End section: {title} -->")
|
||||||
|
if len(block) != 2:
|
||||||
|
msg = f"Section {title} not found in README.md"
|
||||||
|
raise ValueError(msg)
|
||||||
|
|
||||||
|
f.write(block[0])
|
||||||
|
|
||||||
|
# Copy the CONTRIBUTING.md.
|
||||||
|
shutil.copy("CONTRIBUTING.md", "docs/contributing.md")
|
||||||
|
|
||||||
|
# Add the nav section to mkdocs.yml.
|
||||||
|
with Path("mkdocs.template.yml").open(encoding="utf8") as fp:
|
||||||
|
config = yaml.safe_load(fp)
|
||||||
|
config["nav"] = [
|
||||||
|
{"Overview": "index.md"},
|
||||||
|
{"Installation and Usage": "installation-and-usage.md"},
|
||||||
|
{"Configuration": "configuration.md"},
|
||||||
|
{"Rules": "rules.md"},
|
||||||
|
{"Settings": "settings.md"},
|
||||||
|
{"Editor Integrations": "editor-integrations.md"},
|
||||||
|
{"FAQ": "faq.md"},
|
||||||
|
{"Contributing": "contributing.md"},
|
||||||
|
]
|
||||||
|
|
||||||
|
with Path("mkdocs.yml").open("w+") as fp:
|
||||||
|
yaml.safe_dump(config, fp)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Generate an MkDocs-compatible `docs` and `mkdocs.yml`.",
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue