diff options
| author | Yuriy Andamasov <yuriy@vyos.io> | 2026-05-10 19:11:24 +0300 |
|---|---|---|
| committer | Yuriy Andamasov <yuriy@vyos.io> | 2026-05-10 19:11:24 +0300 |
| commit | 7a3aa29fc010c2604b84d6437ed87053947f3f27 (patch) | |
| tree | c241c2ba91c2dba370d915102405fb24e2c39178 /.github | |
| parent | 266acf2829fdcf809fe851203d8e34167075dd3f (diff) | |
| download | vyos-documentation-7a3aa29fc010c2604b84d6437ed87053947f3f27.tar.gz vyos-documentation-7a3aa29fc010c2604b84d6437ed87053947f3f27.zip | |
ci: extend doc-linter to MyST Markdown
Active docs are now MyST `.md`; the linter previously only inspected
`.rst` and `.txt`, so ~250 active pages were unchecked for IP usage and
line length on every PR.
scripts/doc-linter.py:
- Add `.md` to the extension filter (use `endswith` for correctness;
the prior 4-char slice silently skipped `.md` files).
- Track MyST/Markdown fenced code blocks (```` ``` ```` and `:::`) for
line-length exemption — same semantics as `.. code-block::` for RST.
- Recognize both suppression marker forms: `.. stop_vyoslinter` /
`.. start_vyoslinter` (RST and `.txt` includes) and `% stop_vyoslinter`
/ `% start_vyoslinter` (MyST). Both work in either context; pick the
form that matches the surrounding parser.
- Replace the brittle `try/finally: fp.close()` with a `with` block —
the previous form raised `UnboundLocalError` if `open()` itself
failed.
- Fix typo `forgett` → `forget`.
.github/instructions/rst-linter.instructions.md → doc-linter.instructions.md:
- Broaden `applyTo` from `**/*.rst` to `**/*.md,**/*.rst,**/*.txt`.
- Document MyST suppression syntax and fenced-code line-length
exemption.
- Note the parser-form rule for `{eval-rst}` blocks.
No regression on `.txt` includes: identical lint output verified
against the origin/rolling baseline on a sample of files.
Pre-existing IP violations exist in 14 `.md` files (e.g.
`configexamples/lac-lns.md` line 95 — a `8.8.8.8` already wrapped in
`% stop_vyoslinter`/`% start_vyoslinter`, correctly suppressed). PRs
touching unsuppressed violations will start failing CI; this is the
intent of enabling the check.
🤖 Generated by [robots](https://vyos.io)
Diffstat (limited to '.github')
| -rw-r--r-- | .github/instructions/doc-linter.instructions.md (renamed from .github/instructions/rst-linter.instructions.md) | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/.github/instructions/rst-linter.instructions.md b/.github/instructions/doc-linter.instructions.md index 419f094a..5e7d359e 100644 --- a/.github/instructions/rst-linter.instructions.md +++ b/.github/instructions/doc-linter.instructions.md @@ -1,10 +1,10 @@ --- -applyTo: "**/*.rst" +applyTo: "**/*.md,**/*.rst,**/*.txt" --- -## RST Linter Rules +## Doc Linter Rules -Every pull request is automatically linted by `doc-linter.py` (from the `vyos/.github` repository). It checks **only changed files** for two things: IP address usage and line length. +Every pull request is automatically linted by `scripts/doc-linter.py`. It checks **only changed files** for two things: IP address usage and line length. MyST Markdown (`.md`), legacy RST (`.rst`), and `.txt` includes are all linted. ### IP Address Rules @@ -39,11 +39,28 @@ The linter rejects public IP addresses that are not reserved for documentation. ### Line Length Rules -Maximum 80 characters per line. Lines inside `.. code-block::` directives are **exempt** from the line length limit (they render with `<pre>` tags and preserve source formatting). +Maximum 80 characters per line. The line-length check is **skipped** inside fenced code: + +- MyST / Markdown: ` ```...``` ` and `:::...:::` fenced blocks (any info string, including ` ```{eval-rst} `, ` ```{cfgcmd} `, etc.). +- RST: lines indented under `.. code-block::` directives. ### Suppression Syntax -When real public IPs or long lines are unavoidable, wrap the block: +When real public IPs or long lines are unavoidable, wrap the block. The marker form depends on the surrounding parser: + +**MyST Markdown (`.md`)** — use the MyST comment form: + +````md +% stop_vyoslinter + +``` +set system name-server '8.8.8.8' +``` + +% start_vyoslinter +```` + +**RST (`.rst`) and `.txt` includes** — use the RST comment form: ```rst .. stop_vyoslinter @@ -55,16 +72,19 @@ When real public IPs or long lines are unavoidable, wrap the block: .. start_vyoslinter ``` +**Inside a `{eval-rst}` block in MyST** — the embedded content is parsed as RST, so the RST form (`.. stop_vyoslinter`) matches the surrounding parser. The linter recognizes both forms regardless of context, but use the form that fits the parser of the enclosing block. + **Rules for suppression markers:** -- Place `.. stop_vyoslinter` on its own line, immediately before the content -- Place `.. start_vyoslinter` on its own line, immediately after the content -- Always re-enable the linter — never leave it stopped for the rest of the file -- Suppress the smallest possible region -- Do NOT use suppression for content that can use documentation-reserved addresses instead +- Place the stop marker on its own line, immediately before the content. +- Place the start marker on its own line, immediately after the content. +- Always re-enable the linter — never leave it stopped for the rest of the file. +- Suppress the smallest possible region. +- Do NOT use suppression for content that can use documentation-reserved addresses instead. ### Common Mistakes -- Removing `stop/start_vyoslinter` markers without fixing the underlying issue (exposes the line to the linter and fails CI) -- Using real public IPs when documentation addresses would work just as well -- Adding suppression markers around content that only has private (RFC 1918) addresses or `0.0.0.0/0` — these are allowed and don't need suppression +- Removing `stop/start_vyoslinter` markers without fixing the underlying issue (exposes the line to the linter and fails CI). +- Using real public IPs when documentation addresses would work just as well. +- Adding suppression markers around content that only has private (RFC 1918) addresses or `0.0.0.0/0` — these are allowed and don't need suppression. +- Mixing marker forms (using `% stop_vyoslinter` inside an `{eval-rst}` block, or `.. stop_vyoslinter` in plain MyST prose). |
