docs(site): title Examples fences and auto-title file-scoped snippets
Function EXAMPLE blocks now render as their own fish fence titled "Examples" (matching the existing "Usage" title on the Synopsis fence), triggered by a flat Example: label line mirroring the Synopsis: prefix. Prose pages get two new generic titling signals in _render_para: a bare indented path ending in a known extension is titled by its basename, and a leading "# in <file>" / "# <file>" comment on a shell paragraph is promoted to the fence title and stripped from the body. This picks up local.fish/secrets.fish path displays and override examples in 07-customization.md for free, plus a bonus .logging_disabled hit. 10-personalization.md's secrets.fish block gets an explicit "# secrets.fish" comment to title it the same way. The four local.fish examples keep their existing descriptive comments rather than a redundant local.fish title.
This commit is contained in:
+24
-3
@@ -332,16 +332,19 @@ def test_prettify_splits_an_entry_block():
|
||||
"",
|
||||
" Falls back to /usr/bin/rm when trash is unavailable.",
|
||||
"",
|
||||
" Example:",
|
||||
" rm file.txt # moves to trash",
|
||||
" rm -e # empty trash",
|
||||
]
|
||||
)
|
||||
out = build_manual.prettify(body, "rm")
|
||||
|
||||
assert '```fish title="rm.fish"\nrm [-e | args...]\n```' in out, (
|
||||
"synopsis was not fenced as fish with a filename title"
|
||||
assert '```fish title="Usage"\nrm [-e | args...]\n```' in out, (
|
||||
"synopsis was not fenced as fish with a Usage title"
|
||||
)
|
||||
assert '```fish title="Examples"\nrm file.txt' in out, (
|
||||
"examples were not fenced as fish with an Examples title"
|
||||
)
|
||||
assert "```fish\nrm file.txt" in out, "examples were not fenced as fish"
|
||||
assert out.count("```") == 4, f"expected exactly two fences, got:\n{out}"
|
||||
assert "\nSafe rm wrapper routing to trash:" in out, "description stayed indented"
|
||||
assert "| `(no args)` | List current trash contents |" in out, (
|
||||
@@ -431,6 +434,24 @@ def test_prettify_leaves_reference_tables_alone():
|
||||
assert "```fish" in build_manual.prettify(shell), "a shell block was not fenced"
|
||||
|
||||
|
||||
def test_prettify_titles_paths_and_commented_examples():
|
||||
"""A bare file path or a leading '# in x.fish' comment become a title."""
|
||||
import build_manual
|
||||
|
||||
path = " $__fish_user_dots_path/local.fish"
|
||||
assert '```fish title="local.fish"\n$__fish_user_dots_path/local.fish\n```' in (
|
||||
build_manual.prettify(path)
|
||||
), "a bare file path was not titled"
|
||||
|
||||
commented = "\n".join(
|
||||
[" # in local.fish", " set -gx SCROLLBACK_HISTORY_MAX_FILES 200"]
|
||||
)
|
||||
out = build_manual.prettify(commented)
|
||||
assert '```fish title="local.fish"\nset -gx SCROLLBACK_HISTORY_MAX_FILES 200\n```' in out, (
|
||||
f"a filename comment was not promoted to the fence title:\n{out}"
|
||||
)
|
||||
|
||||
|
||||
def test_prettify_is_site_only():
|
||||
"""The SSOT keeps the indented form the man-page pipeline depends on."""
|
||||
import build_manual
|
||||
|
||||
Reference in New Issue
Block a user