Generalize guide label matching
Authored by
mfwolffe <wolffemf@dukes.jmu.edu>
- SHA
b5700b2151fe35103dcf5df8713b50b4f6a0149a- Parents
-
84d7acd - Tree
064fa46
b5700b2
b5700b2151fe35103dcf5df8713b50b4f6a0149a84d7acd
064fa46| Status | File | + | - |
|---|---|---|---|
| M |
src/loader/runtime/workflow.py
|
6 | 1 |
| M |
tests/test_workflow.py
|
29 | 0 |
src/loader/runtime/workflow.pymodified@@ -1165,7 +1165,12 @@ def _normalize_pending_output_label(value: str) -> str: | ||
| 1165 | 1165 | "", |
| 1166 | 1166 | text, |
| 1167 | 1167 | ) |
| 1168 | - text = re.sub(r"\bfor nginx guide\b", "", text) | |
| 1168 | + text = re.sub( | |
| 1169 | + r"\bfor\s+(?:the\s+)?[a-z0-9][a-z0-9\s_-]{0,60}?\s+" | |
| 1170 | + r"(?:guide|tutorial|docs|documentation|manual|website|site)\b", | |
| 1171 | + "", | |
| 1172 | + text, | |
| 1173 | + ) | |
| 1169 | 1174 | text = re.sub(r"[^a-z0-9]+", " ", text) |
| 1170 | 1175 | return " ".join(text.split()) |
| 1171 | 1176 | |
tests/test_workflow.pymodified@@ -1019,6 +1019,35 @@ def test_infer_pending_todo_output_target_maps_broad_setup_to_planned_directory( | ||
| 1019 | 1019 | assert target == chapters.resolve(strict=False) |
| 1020 | 1020 | |
| 1021 | 1021 | |
| 1022 | +def test_infer_pending_todo_output_target_ignores_topic_specific_guide_suffixes( | |
| 1023 | + tmp_path: Path, | |
| 1024 | +) -> None: | |
| 1025 | + dod = create_definition_of_done("Create a multi-file postgres guide.") | |
| 1026 | + guide_root = tmp_path / "Loader" / "guides" / "postgres" | |
| 1027 | + index_path = guide_root / "index.html" | |
| 1028 | + implementation_plan = tmp_path / "implementation.md" | |
| 1029 | + implementation_plan.write_text( | |
| 1030 | + "\n".join( | |
| 1031 | + [ | |
| 1032 | + "# Implementation Plan", | |
| 1033 | + "", | |
| 1034 | + "## File Changes", | |
| 1035 | + f"- `{index_path}`", | |
| 1036 | + "", | |
| 1037 | + ] | |
| 1038 | + ) | |
| 1039 | + ) | |
| 1040 | + dod.implementation_plan = str(implementation_plan) | |
| 1041 | + | |
| 1042 | + target = infer_pending_todo_output_target( | |
| 1043 | + dod, | |
| 1044 | + "Create index.html for the postgres administration guide", | |
| 1045 | + project_root=tmp_path, | |
| 1046 | + ) | |
| 1047 | + | |
| 1048 | + assert target == index_path.resolve(strict=False) | |
| 1049 | + | |
| 1050 | + | |
| 1022 | 1051 | def test_infer_pending_todo_output_target_maps_aggregate_chapter_step_to_next_declared_file( |
| 1023 | 1052 | tmp_path: Path, |
| 1024 | 1053 | ) -> None: |