fix(docs): scope aside regression test to its contents, reject nested file trees
- test_customization_notes_render_as_aside now asserts the four NOTE bullets live inside the <Aside> tags, not merely anywhere on the page — a re-wrapped bullet previously still passed because the bullet text leaked into an untouched sibling paragraph. - TREE_BRANCH_RE no longer matches an indented/continuation branch line (dropped the leading `[│ ]*`), so a second-level tree falls through to verbatim rendering instead of being silently flattened to one level. Added test_as_file_tree_rejects_deeper_trees to guard it.
This commit is contained in:
@@ -315,7 +315,7 @@ def _as_ruled_table(para: list[str]) -> str | None:
|
||||
|
||||
|
||||
TREE_ROOT_RE = re.compile(r"^[~$][\w./{}-]*/$")
|
||||
TREE_BRANCH_RE = re.compile(r"^[│ ]*[├└]──\s*(\S+)\s*(.*)$")
|
||||
TREE_BRANCH_RE = re.compile(r"^[├└]──\s*(\S+)\s*(.*)$")
|
||||
|
||||
|
||||
def _as_file_tree(para: list[str]) -> str | None:
|
||||
|
||||
+19
-5
@@ -665,6 +665,19 @@ def test_as_file_tree_rejects_non_trees():
|
||||
assert build_manual._as_file_tree(para) is None, f"{label} was wrongly treed"
|
||||
|
||||
|
||||
def test_as_file_tree_rejects_deeper_trees():
|
||||
"""A tree with a second-level (indented) branch line is not detected — falls through to verbatim rendering."""
|
||||
import build_manual
|
||||
|
||||
para = [
|
||||
"~/proj/",
|
||||
"├── src/",
|
||||
"│ └── main.fish",
|
||||
"└── README.md",
|
||||
]
|
||||
assert build_manual._as_file_tree(para) is None
|
||||
|
||||
|
||||
def test_customization_notes_render_as_aside():
|
||||
"""The real 07-customization.md NOTE paragraph converts to one intact <Aside>."""
|
||||
import build_manual
|
||||
@@ -673,11 +686,12 @@ def test_customization_notes_render_as_aside():
|
||||
_, body = mt.parse(path)
|
||||
out = build_manual.prettify(body)
|
||||
assert out.count('<Aside type="note" title="Note">') == 1, f"expected exactly one Note aside:\n{out}"
|
||||
assert "- Command shadows (rm, cat, ls, ...) react immediately" in out
|
||||
assert "- With aliases disabled, rm falls back to bare `command rm`" in out
|
||||
assert "- Disabled integration commands (spwin, tab, split, hist, logs, upgrade)" in out
|
||||
assert "- On CachyOS, the distro fish config's own aliases" in out
|
||||
assert "</Aside>" in out
|
||||
aside = out.split('<Aside type="note" title="Note">')[1].split("</Aside>")[0]
|
||||
assert aside.count(" - ") == 4, f"expected exactly 4 bullets inside the aside:\n{aside}"
|
||||
assert "- Command shadows (rm, cat, ls, ...) react immediately" in aside
|
||||
assert "- With aliases disabled, rm falls back to bare `command rm`" in aside
|
||||
assert "- Disabled integration commands (spwin, tab, split, hist, logs, upgrade)" in aside
|
||||
assert "- On CachyOS, the distro fish config's own aliases" in aside
|
||||
|
||||
|
||||
def test_site_promotes_pages_with_asides_or_filetrees_to_mdx():
|
||||
|
||||
Reference in New Issue
Block a user