Skip to content

Commit 4bae734

Browse files
authored
Update Ruff mdtest structure (#25246)
Summary -- While working on #25233, I realized that my suggestion to group multiple rules within the same Markdown file using top-level headings ran afoul of a markdownlint [rule] against having multiple top-level headings in the same file. I was a bit worried about the size of the resulting files if we followed this suggestion anyway, so I think the best course of action is to recommend directories for each linter with a separate file per rule. This PR updates our existing mdtests to this new structure and also updates the recommendation in the contributing docs. Test Plan -- Existing mdtests in new locations [rule]: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md025---multiple-top-level-headings-in-the-same-document
1 parent c189569 commit 4bae734

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ preserving the original rule name.
234234

235235
To test rules, Ruff uses the mdtest framework, initially developed for ty. Mdtests are written as
236236
Markdown files with Python code and TOML configuration blocks alongside prose
237-
descriptions. Generally, there will be one file per linter (e.g. `flake8-bandit.md` for the `S`
238-
rules) with top-level headings for each rule (e.g. `S704` for `unsafe-markup-use`). Within these
239-
top-level sections, you can define additional sections to group related tests and their settings
237+
descriptions. Generally, there will be one directory per linter (e.g. `flake8-bandit` for the `S`
238+
rules) with nested files for each rule (e.g. `unsafe-markup-use.md` for `S704`). Within these
239+
files, you can define additional Markdown sections to group related tests and their settings
240240
together.
241241

242242
You can see [the ty_test
@@ -252,7 +252,7 @@ For example, a minimal mdtest for `module-import-not-at-top-of-file` (`E402`) wo
252252
like this:
253253

254254
````markdown
255-
<!-- crates/ruff_linter/resources/mdtest/pycodestyle.md -->
255+
<!-- crates/ruff_linter/resources/mdtest/pycodestyle/module-import-not-at-top-of-file.md -->
256256

257257
# `module-import-not-at-top-of-file` (`E402`)
258258

crates/ruff_linter/resources/mdtest/flake8-bandit.md renamed to crates/ruff_linter/resources/mdtest/flake8-bandit/unsafe-markup-use.md

File renamed without changes.

crates/ruff_linter/resources/mdtest/test-rules.md renamed to crates/ruff_linter/resources/mdtest/test-rules/panicy-test-rule.md

File renamed without changes.

0 commit comments

Comments
 (0)