Files
claude-howto/.pre-commit-config.yaml
Luong NGUYEN c2f92c8fa7 feat(i18n): wire Persian (fa) into tooling and sync to v2.1.316 (#241)
Type: chore

## Summary

Follow-up to #208 (Persian translation). It wires `fa/` into the repo
tooling the same way #228 did for Korean, and syncs the translation from
v2.1.310 to v2.1.316.

## Changes

**Tooling** (`feat(i18n)`)
- `build_epub.py`: `--lang fa` builds `claude-howto-guide-fa.epub`.
- `build_website.py`: `--lang fa`; `fa` is in `EXCLUDE_DIRS`, so Persian
pages stay out of the English site.
- CI: the EPUB matrix in `test.yml` now includes `fa`. The
markdown-rendering docstring and test now list `fa`.
- Pre-commit: new `persian-markdown-lint`, `persian-cross-references`,
`persian-mermaid` and `persian-link-check` hooks. `persian-mermaid` is
added to the offline `SKIP=` lists in `.pre-commit-config.yaml`,
`CONTRIBUTING.md` and `CLAUDE.md`.
- `scripts/README.md`: usage text updated.
- Language switchers: `فارسی` added to `vi/`, `zh/`, `uk/`, `ja/` and
`ko/` READMEs and to the landing-page footer.

**Translation** (`docs(fa)`)
- Applies the English changes from #230 (v2.1.316) to the 15 affected
`fa/` files: 192 lines added, 104 removed.
- Moves the misplaced `دسترس‌پذیری (v2.1.310)` Monitor callout in
`fa/09-advanced-features/README.md` to the position it has in English.

## Verification

| Check | Result |
|---|---|
| `fa/` line counts, URLs and code-fence positions vs English `main` |
identical in all files |
| `pre-commit run --all-files`, including the new Persian hooks | pass |
| `pytest scripts/tests/` | 198 passed |
| ruff, mypy, bandit | clean |
| `build_epub.py --lang fa` + `check_epub_diagrams.py` | 61 diagrams, 0
placeholders |
| `build_website.py --lang fa` | builds; English site has no `fa/` pages
|

## Known limitations (not in this PR)

- The EPUB and website templates hard-code `lang="en"` and have no
`dir="rtl"`, so Persian pages render left-to-right. Fixing that means
passing the language into the HTML templates for every locale.
- `fa/.github/` has no `TESTING.md`, `SECURITY_REPORTING.md` or
`pull_request_template.md`; the other locales have all three.
2026-11-12 10:54:28 +01:00

261 lines
8.0 KiB
YAML

# Pre-commit hooks for claude-howto project
# Run `pre-commit install` to set up hooks
# Run `pre-commit run --all-files` to check all files
default_language_version:
python: python3.11
repos:
# Ruff - Fast Python linter and formatter
# Keep this in step with the `ruff` floor in scripts/requirements-dev.txt and
# the unpinned `uv pip install ruff` in the CI lint job. A stale pin here
# reformats files the newer ruff in CI then rejects, and vice versa.
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.10
hooks:
- id: ruff
name: ruff-lint
args: [--fix, --exit-non-zero-on-fix]
types_or: [python, pyi]
files: ^scripts/
- id: ruff-format
name: ruff-format
types_or: [python, pyi]
files: ^scripts/
# Bandit - Security linter
- repo: https://github.com/PyCQA/bandit
rev: 1.7.10
hooks:
- id: bandit
name: bandit-security
args: [-c, scripts/pyproject.toml]
additional_dependencies: ["bandit[toml]"]
types: [python]
files: ^scripts/
exclude: ^scripts/tests/
# Standard pre-commit hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
name: check-yaml
args: [--allow-multiple-documents]
- id: check-toml
name: check-toml
- id: end-of-file-fixer
name: fix-end-of-file
- id: trailing-whitespace
name: fix-trailing-whitespace
- id: check-added-large-files
name: check-large-files
args: [--maxkb=1000]
- id: check-merge-conflict
name: check-merge-conflict
# mypy - Type checking
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
name: mypy-type-check
args: [--config-file, scripts/pyproject.toml]
files: ^scripts/
exclude: ^scripts/tests/
additional_dependencies:
- types-Markdown
# Local doc quality hooks (mirrors CI checks — CI is a 2nd pass of these)
- repo: local
hooks:
- id: markdown-lint
name: markdown-lint
language: node
entry: markdownlint
args: ['--ignore', 'node_modules', '--ignore', '.venv', '--config', '.markdownlint.json']
types: [markdown]
additional_dependencies: ['markdownlint-cli']
- id: cross-references
name: cross-references
language: system
entry: python scripts/check_cross_references.py
pass_filenames: false
types: [markdown]
# The three *mermaid hooks render every diagram with the pinned Pele
# bundle. `language: node` makes pre-commit provision Node.js 22 for the
# hook (nodeenv), so no system Node is needed, and `--strict` makes a
# failed bundle download fail the hook instead of skipping it. The first
# run needs network access; offline, skip them with
# SKIP=mermaid,vietnamese-mermaid,japanese-mermaid,korean-mermaid,persian-mermaid.
- id: mermaid
name: mermaid-syntax
language: node
language_version: 22.12.0
entry: python scripts/check_mermaid.py --strict
pass_filenames: false
types: [markdown]
verbose: true
- id: link-check
name: link-check
language: system
entry: python scripts/check_links.py
pass_filenames: false
types: [markdown]
verbose: true
- id: markdown-rendering
name: markdown-rendering
language: system
entry: python scripts/check_markdown_rendering.py
pass_filenames: false
types: [markdown]
# The EPUB build is intentionally CI-only (see the `build-epub` job in
# .github/workflows/test.yml): it is a slow full-book build. The mermaid
# hooks above already render every diagram with the same Pele bundle
# the EPUB uses, so a broken diagram still fails at commit time.
# Vietnamese documentation checks
- repo: local
hooks:
- id: vietnamese-markdown-lint
name: vietnamese-markdown-lint
language: node
entry: markdownlint
args: ['--ignore', 'node_modules', '--ignore', '.venv', '--config', '.markdownlint.json']
files: ^vi/.*\.md$
additional_dependencies: ['markdownlint-cli']
- id: vietnamese-cross-references
name: vietnamese-cross-references
language: system
entry: python scripts/check_cross_references.py --lang vi
pass_filenames: false
files: ^vi/.*\.md$
- id: vietnamese-mermaid
name: vietnamese-mermaid-syntax
language: node
language_version: 22.12.0
entry: python scripts/check_mermaid.py --strict
pass_filenames: false
files: ^vi/.*\.md$
verbose: true
- id: vietnamese-link-check
name: vietnamese-link-check
language: system
entry: python scripts/check_links.py
pass_filenames: false
files: ^vi/.*\.md$
verbose: true
# Japanese documentation checks
- repo: local
hooks:
- id: japanese-markdown-lint
name: japanese-markdown-lint
language: node
entry: markdownlint
args: ['--ignore', 'node_modules', '--ignore', '.venv', '--config', '.markdownlint.json']
files: ^ja/.*\.md$
additional_dependencies: ['markdownlint-cli']
- id: japanese-cross-references
name: japanese-cross-references
language: system
entry: python scripts/check_cross_references.py
pass_filenames: false
files: ^ja/.*\.md$
- id: japanese-mermaid
name: japanese-mermaid-syntax
language: node
language_version: 22.12.0
entry: python scripts/check_mermaid.py --strict
pass_filenames: false
files: ^ja/.*\.md$
verbose: true
- id: japanese-link-check
name: japanese-link-check
language: system
entry: python scripts/check_links.py
pass_filenames: false
files: ^ja/.*\.md$
verbose: true
# Korean documentation checks
- repo: local
hooks:
- id: korean-markdown-lint
name: korean-markdown-lint
language: node
entry: markdownlint
args: ['--ignore', 'node_modules', '--ignore', '.venv', '--config', '.markdownlint.json']
files: ^ko/.*\.md$
additional_dependencies: ['markdownlint-cli']
- id: korean-cross-references
name: korean-cross-references
language: system
entry: python scripts/check_cross_references.py
pass_filenames: false
files: ^ko/.*\.md$
- id: korean-mermaid
name: korean-mermaid-syntax
language: node
language_version: 22.12.0
entry: python scripts/check_mermaid.py --strict
pass_filenames: false
files: ^ko/.*\.md$
verbose: true
- id: korean-link-check
name: korean-link-check
language: system
entry: python scripts/check_links.py
pass_filenames: false
files: ^ko/.*\.md$
verbose: true
# Persian documentation checks
- repo: local
hooks:
- id: persian-markdown-lint
name: persian-markdown-lint
language: node
entry: markdownlint
args: ['--ignore', 'node_modules', '--ignore', '.venv', '--config', '.markdownlint.json']
files: ^fa/.*\.md$
additional_dependencies: ['markdownlint-cli']
- id: persian-cross-references
name: persian-cross-references
language: system
entry: python scripts/check_cross_references.py
pass_filenames: false
files: ^fa/.*\.md$
- id: persian-mermaid
name: persian-mermaid-syntax
language: node
language_version: 22.12.0
entry: python scripts/check_mermaid.py --strict
pass_filenames: false
files: ^fa/.*\.md$
verbose: true
- id: persian-link-check
name: persian-link-check
language: system
entry: python scripts/check_links.py
pass_filenames: false
files: ^fa/.*\.md$
verbose: true