Skip to content

Commit 784f15c

Browse files
committed
fix(cli): Rename "Machine-readable output" to end with "examples"
The pretty_argparse extension only transforms definition list sections into separate code blocks when the section heading ends with "examples". Renamed the section in ls, search, and debug_info commands so they get properly formatted in documentation. Added regression test to verify category example sections create separate code blocks per command line.
1 parent 9b68daa commit 784f15c

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

src/tmuxp/cli/debug_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
],
3232
),
3333
(
34-
"Machine-readable output",
34+
"Machine-readable output examples",
3535
[
3636
"tmuxp debug-info --json",
3737
],

src/tmuxp/cli/ls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
],
6161
),
6262
(
63-
"Machine-readable output",
63+
"Machine-readable output examples",
6464
[
6565
"tmuxp ls --json",
6666
"tmuxp ls --json --full",

src/tmuxp/cli/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ def output_result(result: WorkspaceSearchResult, show_path: bool) -> None:
10671067
],
10681068
),
10691069
(
1070-
"Machine-readable output",
1070+
"Machine-readable output examples",
10711071
[
10721072
"tmuxp search --json dev",
10731073
"tmuxp search --ndjson dev | jq '.name'",

tests/docs/_ext/test_pretty_argparse.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,29 @@ def test_transform_definition_list_code_blocks_created() -> None:
586586
assert code_blocks[2].astext() == "$ cmd3"
587587

588588

589+
def test_transform_definition_list_machine_readable_code_blocks() -> None:
590+
"""Machine-readable output examples creates separate code blocks per line.
591+
592+
Regression test: Ensures category example sections like "Machine-readable
593+
output examples:" split multi-line commands into separate code blocks,
594+
not clumped together as a single block.
595+
"""
596+
dl = nodes.definition_list()
597+
dl += _make_dl_item(
598+
"Machine-readable output examples:",
599+
"tmuxp ls --json\ntmuxp ls --json --full\ntmuxp ls --ndjson",
600+
)
601+
602+
result = transform_definition_list(dl)
603+
604+
section = result[0]
605+
code_blocks = [c for c in section.children if isinstance(c, nodes.literal_block)]
606+
assert len(code_blocks) == 3, "Each command should be a separate code block"
607+
assert code_blocks[0].astext() == "$ tmuxp ls --json"
608+
assert code_blocks[1].astext() == "$ tmuxp ls --json --full"
609+
assert code_blocks[2].astext() == "$ tmuxp ls --ndjson"
610+
611+
589612
# --- _is_usage_block tests ---
590613

591614

0 commit comments

Comments
 (0)