tenseleyflow/loader / b5700b2

Browse files

Generalize guide label matching

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
b5700b2151fe35103dcf5df8713b50b4f6a0149a
Parents
84d7acd
Tree
064fa46

2 changed files

StatusFile+-
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:
11651165
         "",
11661166
         text,
11671167
     )
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
+    )
11691174
     text = re.sub(r"[^a-z0-9]+", " ", text)
11701175
     return " ".join(text.split())
11711176
 
tests/test_workflow.pymodified
@@ -1019,6 +1019,35 @@ def test_infer_pending_todo_output_target_maps_broad_setup_to_planned_directory(
10191019
     assert target == chapters.resolve(strict=False)
10201020
 
10211021
 
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
+
10221051
 def test_infer_pending_todo_output_target_maps_aggregate_chapter_step_to_next_declared_file(
10231052
     tmp_path: Path,
10241053
 ) -> None: