Match the ways a test names a path the classifier calls documentation. The patterns come from the classifier's own lists, so a path added there is covered here without a second edit.
()
| 32 | |
| 33 | |
| 34 | def doc_reference_pattern() -> re.Pattern[str]: |
| 35 | """Match the ways a test names a path the classifier calls documentation. |
| 36 | |
| 37 | The patterns come from the classifier's own lists, so a path added there is |
| 38 | covered here without a second edit. |
| 39 | """ |
| 40 | alternatives = sorted({re.escape(PurePosixPath(path.decode()).name) for path in DOC_FILES}) |
| 41 | for directory in sorted({PurePosixPath(prefix.decode()).name for prefix in DOC_PREFIXES}): |
| 42 | name = re.escape(directory) |
| 43 | # ``"docs/page.mdx"`` as one string, or ``root / "docs" / "page.mdx"``. |
| 44 | alternatives.append(rf"(?<![\w.-]){name}/") |
| 45 | alternatives.append(rf"""["']{name}["']""") |
| 46 | return re.compile("|".join(alternatives)) |
| 47 | |
| 48 | |
| 49 | def _is_test_file(path: Path) -> bool: |