From 68706b08aaa28d62b483a95ce71254cc31cfdc3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Maj?= Date: Sat, 26 Sep 2026 17:00:44 +0200 Subject: [PATCH] chore: add Markdown linting --- .github/pull_request_template.md | 4 +- .github/workflows/ci.yml | 3 + .gitignore | 1 + .pre-commit-config.yaml | 8 +++ CONTRIBUTING.md | 8 ++- README.md | 7 +- docs/02_uv.md | 1 + docs/03_pyproject_toml.md | 14 +++- docs/06_github_actions.md | 16 ++++- docs/07_git_commits_branches_prs.md | 5 +- docs/08_common_mistakes.md | 1 + docs/09_checklist.md | 22 +++++- docs/13_pre_commit_hooks.md | 5 +- docs/14_markdown_linting.md | 105 ++++++++++++++++++++++++++++ docs/ROADMAP.md | 2 + docs/cheatsheet.md | 12 ++++ docs/common_questions.md | 17 +++++ docs/example_pull_request.md | 1 + docs/from_script_to_project.md | 12 +++- docs/github_actions_logs.md | 36 ++++++++++ docs/glossary.md | 13 ++++ docs/markdown_review.md | 5 +- docs/quickstart_clone_and_ci.md | 21 +++++- docs/quickstart_uv.md | 29 ++++++-- docs/troubleshooting.md | 41 +++++++++++ pyproject.toml | 8 +++ uv.lock | 16 +++++ 27 files changed, 390 insertions(+), 23 deletions(-) create mode 100644 docs/14_markdown_linting.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 0d9d031..e8830c1 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,9 +8,7 @@ Explain why this change is needed. ## Changes -- -- -- +List the most important changes. ## Type of change diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ac9ce1..89ffd2f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,9 @@ jobs: - name: Check formatting run: uv run ruff format --check . + - name: Lint Markdown + run: uv run rumdl check . + - name: Run tests with coverage run: uv run pytest --cov=text_toolkit --cov-report=term-missing diff --git a/.gitignore b/.gitignore index 68df92c..3877b02 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ htmlcov/ # Tool caches .ruff_cache/ .mypy_cache/ +.rumdl_cache/ # IDE settings .vscode/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e8dcc90..a1a27d6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,14 @@ repos: - id: check-toml - id: check-merge-conflict + - repo: local + hooks: + - id: rumdl + name: lint Markdown with rumdl + entry: uv run rumdl check + language: system + types: [markdown] + - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.15.12 hooks: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 40c9a29..92c9bca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -171,9 +171,9 @@ Delete the corresponding local branch after updating `main`. ## Documentation terminology -Use the official spelling of tool names: `uv`, pytest, mypy, and `pre-commit` -are lowercase, while Ruff is capitalized in prose. Keep command names and -configuration keys in code format. +Use the official spelling of tool names: `uv`, pytest, mypy, `rumdl`, and +`pre-commit` are lowercase, while Ruff is capitalized in prose. Keep command +names and configuration keys in code format. Call the ordered set of core chapters the **main learning path**. Call the supporting quickstarts, troubleshooting pages, and focused guides @@ -203,6 +203,7 @@ Before opening a pull request with code changes, run the local quality checks: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -219,6 +220,7 @@ Then repeat the checks: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources diff --git a/README.md b/README.md index 2174fcb..6957f0b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![CI](https://github.com/michalmaj/modern-python-project-guide/actions/workflows/ci.yml/badge.svg)](https://github.com/michalmaj/modern-python-project-guide/actions/workflows/ci.yml) A practical, beginner-friendly guide to building a clean Python project with -`uv`, `pytest`, Ruff, mypy, `pyproject.toml`, GitHub Actions, and a +`uv`, `pytest`, Ruff, mypy, `rumdl`, `pyproject.toml`, GitHub Actions, and a pull-request-based workflow with `pre-commit` hooks. This repository is both a tutorial and a working example. It introduces each @@ -32,6 +32,7 @@ By following the guide, you will learn how to: - inspect statement and branch coverage with pytest-cov, - lint and format code with Ruff, - check type annotations with mypy, +- lint Markdown documentation with `rumdl`, - automate fast checks with `pre-commit` hooks, - run automated quality checks in GitHub Actions, - work with branches, commits, and pull requests. @@ -57,7 +58,8 @@ understand why each tool and file is introduced. 11. [Static type checking with mypy](docs/11_type_checking_with_mypy.md) 12. [Test coverage with pytest-cov](docs/12_test_coverage.md) 13. [`pre-commit` hooks](docs/13_pre_commit_hooks.md) -14. [Project checklist](docs/09_checklist.md) +14. [Markdown linting with rumdl](docs/14_markdown_linting.md) +15. [Project checklist](docs/09_checklist.md) ## Reference material @@ -124,6 +126,7 @@ Run the same quality checks used by CI: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources diff --git a/docs/02_uv.md b/docs/02_uv.md index 893be2a..ce9b230 100644 --- a/docs/02_uv.md +++ b/docs/02_uv.md @@ -148,6 +148,7 @@ How do I run the code? How do I run the tests? How do I check code quality? ``` + If the project answers these questions clearly, the tooling is doing its job. ## Continue diff --git a/docs/03_pyproject_toml.md b/docs/03_pyproject_toml.md index 4d9b917..6ff8c55 100644 --- a/docs/03_pyproject_toml.md +++ b/docs/03_pyproject_toml.md @@ -44,6 +44,7 @@ dev = [ "pytest>=9.0.3", "pytest-cov>=7.1.0", "ruff>=0.15.12", + "rumdl>=0.2.77", ] [tool.pytest.ini_options] @@ -61,6 +62,13 @@ source = ["text_toolkit"] [tool.coverage.report] show_missing = true +[tool.rumdl] +disable = ["MD013"] + +[tool.rumdl.per-file-ignores] +".github/pull_request_template.md" = ["MD041"] +"docs/markdown_review.md" = ["MD014"] + [tool.ruff] line-length = 88 target-version = "py312" @@ -77,8 +85,8 @@ select = [ ``` This describes the project, its build system, its development dependencies, and -the settings used by pytest, mypy, Coverage.py, and Ruff. `pre-commit` is a -development dependency, but its hooks use the separate +the settings used by pytest, mypy, Coverage.py, Ruff, and `rumdl`. `pre-commit` +is a development dependency, but its hooks use the separate `.pre-commit-config.yaml` file. ## The `[project]` section @@ -147,7 +155,7 @@ This is intentional. The example package starts with standard library code only. -Development tools such as `pytest`, pytest-cov, mypy, and Ruff are stored +Development tools such as `pytest`, pytest-cov, mypy, Ruff, and `rumdl` are stored separately in the `dev` dependency group. ## The `[build-system]` section diff --git a/docs/06_github_actions.md b/docs/06_github_actions.md index 49570f5..84857eb 100644 --- a/docs/06_github_actions.md +++ b/docs/06_github_actions.md @@ -47,6 +47,7 @@ In this project, the local checks are: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -171,7 +172,8 @@ The `--group dev` option installs development dependencies such as: - `pytest`, - `pytest-cov`, - `mypy`, -- `ruff`. +- `ruff`, +- `rumdl`. These tools are needed for checks, but they are not runtime dependencies of the package. @@ -214,6 +216,18 @@ The developer can fix formatting locally with: uv run ruff format . ``` +## Markdown linting + +The workflow checks Markdown structure and consistency: + +```yaml +- name: Lint Markdown + run: uv run rumdl check . +``` + +The command uses the `[tool.rumdl]` configuration in `pyproject.toml`. It does +not replace the pytest check for local documentation links or human review. + ## Tests and coverage The workflow runs tests and prints a coverage report: diff --git a/docs/07_git_commits_branches_prs.md b/docs/07_git_commits_branches_prs.md index dc191a4..f01868a 100644 --- a/docs/07_git_commits_branches_prs.md +++ b/docs/07_git_commits_branches_prs.md @@ -269,7 +269,7 @@ A good pull request description may include: Example: -```markdown +````markdown ## Summary Adds tests for the text statistics utilities. @@ -292,7 +292,7 @@ Local check: ```bash uv run pytest ``` -``` +```` ## Review mindset @@ -334,6 +334,7 @@ For code changes, run: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` diff --git a/docs/08_common_mistakes.md b/docs/08_common_mistakes.md index b984a9e..6bb4c42 100644 --- a/docs/08_common_mistakes.md +++ b/docs/08_common_mistakes.md @@ -145,6 +145,7 @@ For code changes, run: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` diff --git a/docs/09_checklist.md b/docs/09_checklist.md index b72ada6..dd28576 100644 --- a/docs/09_checklist.md +++ b/docs/09_checklist.md @@ -176,6 +176,22 @@ uv run pre-commit install uv run pre-commit run --all-files ``` +## Markdown linting + +Documentation should have lightweight automated checks: + +- [ ] `rumdl` is installed as a development dependency +- [ ] Markdown rules are configured deliberately +- [ ] project-specific exceptions are narrow and explained +- [ ] linting runs locally, in pre-commit, and in CI +- [ ] link checking and human review remain separate checks + +In this guide, Markdown linting runs with: + +```bash +uv run rumdl check . +``` + ## Continuous integration The project should run checks automatically in CI: @@ -186,6 +202,7 @@ The project should run checks automatically in CI: - [ ] CI installs dependencies from the lockfile - [ ] CI runs linting - [ ] CI checks formatting +- [ ] CI lints Markdown - [ ] CI runs tests with coverage reporting - [ ] CI runs type checking - [ ] CI builds a wheel and source distribution @@ -234,6 +251,7 @@ For code changes, run: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -250,6 +268,7 @@ Then repeat: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -288,6 +307,7 @@ Where are the tests? How do I run the tests? How do I inspect test coverage? How do I check formatting and linting? +How do I lint Markdown documentation? How do I check type annotations? How do I build distribution files? What happens before code is merged? @@ -311,5 +331,5 @@ Let the project grow gradually. ## Continue -- [Previous: `pre-commit` Hooks](13_pre_commit_hooks.md) +- [Previous: Markdown Linting with rumdl](14_markdown_linting.md) - [Back to README](../README.md) diff --git a/docs/13_pre_commit_hooks.md b/docs/13_pre_commit_hooks.md index 324495c..2a7250f 100644 --- a/docs/13_pre_commit_hooks.md +++ b/docs/13_pre_commit_hooks.md @@ -60,6 +60,9 @@ The Ruff hooks: - apply safe lint fixes, - format changed Python files. +The local `rumdl` hook lints changed Markdown files using the project's locked +development environment. + These checks are deliberately fast. Tests, coverage, mypy, and distribution builds remain part of the complete local and CI checks. @@ -113,5 +116,5 @@ Keep the complete quality checks visible and understandable. ## Continue - [Previous: Test Coverage with pytest-cov](12_test_coverage.md) -- [Next: Project Checklist](09_checklist.md) +- [Next: Markdown Linting with rumdl](14_markdown_linting.md) - [Back to README](../README.md) diff --git a/docs/14_markdown_linting.md b/docs/14_markdown_linting.md new file mode 100644 index 0000000..16b076c --- /dev/null +++ b/docs/14_markdown_linting.md @@ -0,0 +1,105 @@ +# Markdown Linting with rumdl + +Documentation benefits from automated checks just like Python code does. + +This project uses `rumdl` to find structural and consistency problems in +Markdown files without turning documentation review into a formatting exercise. + +## What a Markdown linter checks + +A Markdown linter can find issues such as: + +- skipped heading levels, +- missing blank lines around lists and code fences, +- code fences without language identifiers, +- inconsistent list markers, +- malformed links and images, +- trailing punctuation or spacing patterns covered by configured rules. + +These checks make documents easier to maintain and render consistently. + +## Install the tool + +`rumdl` is a development dependency, so the normal project sync installs it: + +```bash +uv sync +``` + +No separate Node.js environment is required. + +## Run the check + +Lint all Markdown files in the repository: + +```bash +uv run rumdl check . +``` + +A successful run prints a summary with no reported issues and exits with status +code zero. + +## Configuration + +The project keeps its `rumdl` settings in `pyproject.toml`: + +```toml +[tool.rumdl] +disable = ["MD013"] + +[tool.rumdl.per-file-ignores] +".github/pull_request_template.md" = ["MD041"] +"docs/markdown_review.md" = ["MD014"] +``` + +The line-length rule `MD013` is disabled. Long URLs, commands, and examples can +make a strict limit noisy, while the repository's writing conventions already +encourage short, readable paragraphs. + +The pull request template intentionally starts with a level-two heading because +GitHub inserts it into the pull request form. The Markdown review guide also +contains an intentional shell-prompt anti-example. These focused exceptions are +recorded instead of weakening the rules for every file. + +## Fixing reported issues + +Read the rule identifier and inspect the reported line before editing it. + +Some issues can be fixed automatically: + +```bash +uv run rumdl check --fix . +``` + +Always review the resulting diff. A technically valid rewrite may still make an +explanation less clear. + +## How it fits with existing checks + +The pre-commit hook runs `rumdl` on changed Markdown files for fast feedback. +The `Quality checks` job runs it across the whole repository so the check cannot +be bypassed before merging. + +The existing pytest link test has a different responsibility: it verifies local +file paths and heading anchors. `rumdl` does not replace that test. + +Neither tool can confirm that an explanation is accurate, complete, or helpful. +Human review remains necessary. + +## Why not add a documentation site yet? + +Linting improves the Markdown files directly and keeps them readable on GitHub. +A generated site would add navigation, themes, deployment, and another layer of +configuration. That should be introduced only when the project needs it. + +## Rule of thumb + +Use automation for structural mistakes. + +Use human review for meaning, teaching quality, and tone. + +## Continue + +- [Previous: `pre-commit` Hooks](13_pre_commit_hooks.md) +- [Next: Project Checklist](09_checklist.md) +- [Back to README](../README.md) diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 61bdf42..90aea42 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -136,6 +136,8 @@ These parts are already included in the repository. - [x] Avoid treating coverage percentage as a quality guarantee - [x] Add fast `pre-commit` hooks - [x] Explain how local hooks complement complete checks and CI +- [x] Add focused Markdown linting locally and in CI +- [x] Keep Markdown linting separate from link checks and human review ## Next diff --git a/docs/cheatsheet.md b/docs/cheatsheet.md index 64d1b1b..2576e22 100644 --- a/docs/cheatsheet.md +++ b/docs/cheatsheet.md @@ -64,6 +64,7 @@ uv add --group dev ruff uv add --group dev mypy uv add --group dev pytest-cov uv add --group dev pre-commit +uv add --group dev rumdl ``` Sync the local environment: @@ -116,6 +117,12 @@ Format files: uv run ruff format . ``` +Lint Markdown files: + +```bash +uv run rumdl check . +``` + Install pre-commit hooks in the current clone: ```bash @@ -139,6 +146,7 @@ Run all local checks: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -162,6 +170,7 @@ If formatting fails: uv run ruff format . uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -180,6 +189,7 @@ Then run: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -276,6 +286,7 @@ uv python install uv sync --locked --group dev uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -331,6 +342,7 @@ git status uv sync uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` diff --git a/docs/common_questions.md b/docs/common_questions.md index e0e4981..0751f2b 100644 --- a/docs/common_questions.md +++ b/docs/common_questions.md @@ -193,6 +193,21 @@ If a rule is too strict only for tests, prefer a narrow exception: The important thing is to know why a rule is disabled. +## Why use rumdl instead of formatting every Markdown file? + +`rumdl` can report structural and consistency problems without rewriting the +documentation by default. + +That suits this guide because prose layout is part of the teaching material. A +fully opinionated formatter could create a large diff without improving the +meaning of the text. + +The project disables the noisy line-length rule and keeps two narrow per-file +exceptions for intentional examples. All other default checks remain active. + +The local link test and human review still have separate responsibilities. +Linting cannot confirm that an explanation is correct or useful. + ## Why not add Docker? Docker is useful in many projects. @@ -224,6 +239,7 @@ This guide first teaches the commands directly: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -306,6 +322,7 @@ Then run the local checks: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` diff --git a/docs/example_pull_request.md b/docs/example_pull_request.md index e3c8aa8..d306002 100644 --- a/docs/example_pull_request.md +++ b/docs/example_pull_request.md @@ -289,6 +289,7 @@ For code changes, run: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` diff --git a/docs/from_script_to_project.md b/docs/from_script_to_project.md index 72b3ab7..c5b60ba 100644 --- a/docs/from_script_to_project.md +++ b/docs/from_script_to_project.md @@ -252,6 +252,7 @@ dev = [ "pytest>=9.0.3", "pytest-cov>=7.1.0", "ruff>=0.15.12", + "rumdl>=0.2.77", ] [tool.pytest.ini_options] @@ -269,6 +270,13 @@ source = ["text_toolkit"] [tool.coverage.report] show_missing = true +[tool.rumdl] +disable = ["MD013"] + +[tool.rumdl.per-file-ignores] +".github/pull_request_template.md" = ["MD041"] +"docs/markdown_review.md" = ["MD014"] + [tool.ruff] line-length = 88 target-version = "py312" @@ -319,6 +327,7 @@ In this guide, the main local checks are: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -359,6 +368,7 @@ uv python install uv sync --locked --group dev uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -440,7 +450,7 @@ The project now has: - documentation in `docs/`, - dependencies described in `pyproject.toml`, - exact dependency versions in `uv.lock`, -- local checks with Ruff, pytest-cov, and mypy, +- local checks with Ruff, `rumdl`, pytest-cov, and mypy, - fast `pre-commit` hooks before commits, - CI with GitHub Actions, - a branch and pull request workflow. diff --git a/docs/github_actions_logs.md b/docs/github_actions_logs.md index f0eb565..0c0295e 100644 --- a/docs/github_actions_logs.md +++ b/docs/github_actions_logs.md @@ -71,6 +71,7 @@ jobs: - name: Install dependencies - name: Run Ruff linting - name: Check formatting + - name: Lint Markdown - name: Run tests with coverage - name: Run type checking - name: Build distributions @@ -288,6 +289,7 @@ After fixing, run: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -326,6 +328,7 @@ Then run all checks again: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -339,6 +342,35 @@ git commit -m "style: format files" If the formatting change is part of another small documentation or code PR, it may be better to amend the existing commit instead of adding a separate formatting-only commit. +## Step: Lint Markdown + +### What it does + +This step runs: + +```bash +uv run rumdl check . +``` + +It checks Markdown structure and consistency using the project configuration. + +### If it fails + +The log shows the file, line, rule identifier, and a short explanation. Read the +rule before changing the document; some project-specific patterns may need a +narrow configuration exception. + +### How to fix it + +Run the check locally: + +```bash +uv run rumdl check . +``` + +Some issues can be fixed with `uv run rumdl check --fix .`, but always review +the resulting diff before committing it. + ## Step: Run tests with coverage ### What it does @@ -405,6 +437,7 @@ Then run: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -491,6 +524,7 @@ git status uv sync uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -621,6 +655,7 @@ Run quality checks: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -724,6 +759,7 @@ A green CI run means: - dependencies installed, - Ruff linting passed, - formatting check passed, +- Markdown linting passed, - tests and coverage reporting passed, - type checking passed, - wheel and source distribution builds passed. diff --git a/docs/glossary.md b/docs/glossary.md index b87d1f8..48592f8 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -40,6 +40,7 @@ The CI workflow runs: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -269,6 +270,18 @@ The tests live in: tests/ ``` +## rumdl + +`rumdl` is the Markdown linter used in this guide. + +It checks documentation structure and consistency with: + +```bash +uv run rumdl check . +``` + +It complements the local link test and human documentation review. + ## Runtime dependency A runtime dependency is needed by the project when the project code runs. diff --git a/docs/markdown_review.md b/docs/markdown_review.md index 9108564..a03b230 100644 --- a/docs/markdown_review.md +++ b/docs/markdown_review.md @@ -169,6 +169,7 @@ Good: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -366,6 +367,7 @@ Before asking for review, check: - [ ] Headings are readable - [ ] Code fences are closed - [ ] Commands are copy-paste friendly +- [ ] `uv run rumdl check .` passes - [ ] Links work - [ ] File paths are correct - [ ] The rendered Markdown looks good on GitHub @@ -373,7 +375,7 @@ Before asking for review, check: - [ ] No unrelated files are included - [ ] The PR description explains what changed and why -Useful local checks +## Useful local checks For documentation-only changes, code checks may not always be necessary. @@ -382,6 +384,7 @@ However, if the repository has existing quality checks, it is still fine to run: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` diff --git a/docs/quickstart_clone_and_ci.md b/docs/quickstart_clone_and_ci.md index cc6488b..d2e1329 100644 --- a/docs/quickstart_clone_and_ci.md +++ b/docs/quickstart_clone_and_ci.md @@ -214,6 +214,12 @@ Check formatting: uv run ruff format --check . ``` +Lint Markdown: + +```bash +uv run rumdl check . +``` + Run type checking: ```bash @@ -225,6 +231,7 @@ A useful local check sequence is: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -240,6 +247,7 @@ Then repeat: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -250,6 +258,7 @@ If the project is set up correctly: - Ruff linting should pass, - Ruff formatting check should pass, +- Markdown linting should pass, - pytest and coverage reporting should pass, - mypy should report no issues. @@ -384,6 +393,9 @@ jobs: - name: Check formatting run: uv run ruff format --check . + - name: Lint Markdown + run: uv run rumdl check . + - name: Run tests with coverage run: uv run pytest --cov=text_toolkit --cov-report=term-missing @@ -425,6 +437,7 @@ The CI workflow should run the same checks that developers run locally: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -441,7 +454,9 @@ A green CI check means: - dependencies installed successfully, - Ruff linting passed, - formatting check passed, -- tests passed, +- Markdown linting passed, +- tests and coverage reporting passed, +- type checking passed, - package distributions built successfully. It does not mean the pull request is automatically good. @@ -514,6 +529,7 @@ git status uv sync uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -532,6 +548,7 @@ uv run pre-commit install uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -544,6 +561,7 @@ uv python install uv sync --locked --group dev uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy uv build --no-sources @@ -562,6 +580,7 @@ Before opening a pull request, run: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` diff --git a/docs/quickstart_uv.md b/docs/quickstart_uv.md index 1541c62..d1c7fa4 100644 --- a/docs/quickstart_uv.md +++ b/docs/quickstart_uv.md @@ -107,7 +107,7 @@ def add(left: int, right: int) -> int: return left + right ``` -## 4. Add pytest, pytest-cov, Ruff, and mypy as development dependencies +## 4. Add pytest, pytest-cov, Ruff, mypy, and rumdl as development dependencies Add `pytest`: @@ -133,6 +133,12 @@ Add `pytest-cov`: uv add --group dev pytest-cov ``` +Add `rumdl`: + +```bash +uv add --group dev rumdl +``` + ### Expected result The project should now contain development dependencies in `pyproject.toml`. @@ -167,8 +173,8 @@ This adds `rich` to the project dependencies. The runtime dependency should appear in the `[project]` dependencies section of `pyproject.toml`. -Development tools such as `pytest`, pytest-cov, Ruff, and mypy should stay in -the development dependency group. +Development tools such as `pytest`, pytest-cov, Ruff, mypy, and `rumdl` should +stay in the development dependency group. This separation keeps runtime dependencies and development tools easy to understand. @@ -176,7 +182,7 @@ Use runtime dependencies only when the actual package needs them. Do not add test or linting tools as runtime dependencies. -## 6. Configure pytest, coverage, Ruff, and mypy +## 6. Configure pytest, coverage, Ruff, mypy, and rumdl Open `pyproject.toml`. @@ -201,6 +207,7 @@ dev = [ "pytest>=9.0.3", "pytest-cov>=7.1.0", "ruff>=0.15.12", + "rumdl>=0.2.77", ] [tool.pytest.ini_options] @@ -218,6 +225,9 @@ source = ["example_project"] [tool.coverage.report] show_missing = true +[tool.rumdl] +disable = ["MD013"] + [tool.ruff] line-length = 88 target-version = "py312" @@ -323,6 +333,12 @@ Check formatting: uv run ruff format --check . ``` +Lint Markdown: + +```bash +uv run rumdl check . +``` + Run type checking: ```bash @@ -342,6 +358,7 @@ If everything is configured correctly: - `uv run pytest --cov=example_project --cov-report=term-missing` should pass, - `uv run ruff check .` should pass, - `uv run ruff format --check .` should pass, +- `uv run rumdl check .` should pass, - `uv run mypy` should report no issues. If the formatting check fails, run: @@ -381,6 +398,7 @@ For everyday development, use: uv sync uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=example_project --cov-report=term-missing uv run mypy ``` @@ -391,6 +409,7 @@ If formatting fails: uv run ruff format . uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=example_project --cov-report=term-missing uv run mypy ``` @@ -435,12 +454,14 @@ uv add --group dev pytest uv add --group dev ruff uv add --group dev mypy uv add --group dev pytest-cov +uv add --group dev rumdl uv add rich uv sync uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=example_project --cov-report=term-missing uv run mypy ``` diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 656b742..d682bf6 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -14,6 +14,7 @@ uv --version uv sync uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -261,6 +262,7 @@ Then check again: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -302,6 +304,7 @@ Then run all checks again: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -388,6 +391,7 @@ Then run: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -422,6 +426,39 @@ Check that `pyproject.toml` contains pytest-cov and the `[tool.coverage.run]` section. A lower percentage by itself does not fail this project because no `fail_under` threshold is configured. +## Markdown linting fails + +### Problem + +This command reports one or more rule violations: + +```bash +uv run rumdl check . +``` + +### Possible causes + +- a heading level was skipped, +- a list or code fence is missing surrounding blank lines, +- a fenced code block has no language identifier, +- Markdown structure or style is inconsistent, +- a deliberate project pattern needs a narrow exception. + +### Fix + +Read the rule identifier and inspect the reported line. Fix the structure when +it is genuinely inconsistent. + +For automatically fixable issues, you may run: + +```bash +uv run rumdl check --fix . +git diff +``` + +Review every automatic change. Configure an exception only when the existing +Markdown is intentional and the reason can be explained. + ## A pre-commit hook fails or changes files ### Problem @@ -498,6 +535,7 @@ Run checks again: ```bash uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -689,6 +727,7 @@ git status uv sync uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -727,6 +766,7 @@ Run: uv sync uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` @@ -827,6 +867,7 @@ git status uv sync uv run ruff check . uv run ruff format --check . +uv run rumdl check . uv run pytest --cov=text_toolkit --cov-report=term-missing uv run mypy ``` diff --git a/pyproject.toml b/pyproject.toml index d43a671..d7d5153 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,6 +15,7 @@ dev = [ "pytest>=9.0.3", "pytest-cov>=7.1.0", "ruff>=0.15.12", + "rumdl>=0.2.77", ] [tool.pytest.ini_options] @@ -32,6 +33,13 @@ source = ["text_toolkit"] [tool.coverage.report] show_missing = true +[tool.rumdl] +disable = ["MD013"] + +[tool.rumdl.per-file-ignores] +".github/pull_request_template.md" = ["MD041"] +"docs/markdown_review.md" = ["MD014"] + [tool.ruff] line-length = 88 target-version = "py312" diff --git a/uv.lock b/uv.lock index e26e663..227853e 100644 --- a/uv.lock +++ b/uv.lock @@ -570,6 +570,20 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/c0/98/6beb4b351e472e5f4c4613f7c35a5290b8be2497e183825310c4c3a3984b/ruff-0.15.12-py3-none-win_arm64.whl", hash = "sha256:a538f7a82d061cee7be55542aca1d86d1393d55d81d4fcc314370f4340930d4f", size = 11120821, upload-time = "2026-04-24T18:16:57.979Z" }, ] +[[package]] +name = "rumdl" +version = "0.2.77" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c8/c0/15494f04e84fb67a76b5889c9fefe46b96e79aac9757a9f55d2af0c31bc2/rumdl-0.2.77-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:46a86c67dbfc8d4ec7643c0696e69bd0672d4105584b55e436e43982f6e74ab5", size = 6911721, upload-time = "2026-09-23T13:25:47.365Z" }, + { url = "https://files.pythonhosted.org/packages/9e/d2/23708cdeadd1b352e988a277d050478eba9504a96b55149e6531990004ea/rumdl-0.2.77-py3-none-macosx_11_0_arm64.whl", hash = "sha256:cef5890e4995e968bf87f1d6b3ec129092204987242fe68c55781c9c90829552", size = 6449218, upload-time = "2026-09-23T13:25:41.335Z" }, + { url = "https://files.pythonhosted.org/packages/fa/89/fab16f413fdb5c15b48be6362798e41f448eba4d986274acff0ee496da05/rumdl-0.2.77-py3-none-manylinux_2_28_aarch64.whl", hash = "sha256:fa89db42f35981346400cfbb88a64a01444783e9c5671147e055e16224a9444e", size = 6703647, upload-time = "2026-09-23T13:25:43.728Z" }, + { url = "https://files.pythonhosted.org/packages/d4/f7/77dcc844f2218645dcb2488bc1642440d4012a992b49c6136153ddccbc44/rumdl-0.2.77-py3-none-manylinux_2_28_x86_64.whl", hash = "sha256:ebd62903ee486c36a5ea4c6f19da33b2d5a77b47a93f2dce3c1c5682cc891a00", size = 7183055, upload-time = "2026-09-23T13:25:50.74Z" }, + { url = "https://files.pythonhosted.org/packages/e8/ba/2bab2995cb71efcc74d99d669a53f1242b1fed6b87f5d18748057c1b5ab3/rumdl-0.2.77-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:89843a11f89a15a599ec3487469e368c0c9ade73117ceb9ba821d4e402c0a061", size = 6686480, upload-time = "2026-09-23T13:25:45.589Z" }, + { url = "https://files.pythonhosted.org/packages/35/e6/e90062fc89693d0681ee496f92d84ef9e539b759a263dc677a143175ffed/rumdl-0.2.77-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:69c8165230339ad3f19b7b27ef1e9d5d55fe5495da724da593244f8facca3998", size = 7160415, upload-time = "2026-09-23T13:25:52.284Z" }, + { url = "https://files.pythonhosted.org/packages/39/98/6bf56e1b68eb447cbafd6ab378af818eea8ef4f362246cf003b805de9f0f/rumdl-0.2.77-py3-none-win_amd64.whl", hash = "sha256:5d9d4292daa063238bb379262375b60d0ddffb49f99a9b75beb87993f13918d5", size = 7279786, upload-time = "2026-09-23T13:25:48.96Z" }, +] + [[package]] name = "text-toolkit" version = "0.1.0" @@ -582,6 +596,7 @@ dev = [ { name = "pytest" }, { name = "pytest-cov" }, { name = "ruff" }, + { name = "rumdl" }, ] [package.metadata] @@ -593,6 +608,7 @@ dev = [ { name = "pytest", specifier = ">=9.0.3" }, { name = "pytest-cov", specifier = ">=7.1.0" }, { name = "ruff", specifier = ">=0.15.12" }, + { name = "rumdl", specifier = ">=0.2.77" }, ] [[package]]