Skip to content

Commit 8868fde

Browse files
authored
Merge pull request #18 from cellgeni/fix/document-every-command
Document every command, and check that we did
2 parents daa21dd + 2f713ae commit 8868fde

3 files changed

Lines changed: 55 additions & 1 deletion

File tree

‎docs/COMMANDS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Run `adata <command> --help` for the authoritative flag list.
1818
- [subset](#subset)
1919
- [split](#split)
2020
- [concat](#concat)
21+
- [convert](#convert)
2122
- [create](#create)
2223
- [export](#export)
2324
- [import](#import)

‎src/adata/cli.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
app = typer.Typer(
2828
help="Streaming CLI for huge AnnData .h5ad and .zarr stores "
29-
"(view, ls, subset, split, concat, export, import)."
29+
"(view, ls, create, subset, split, concat, convert, export, import)."
3030
)
3131
# Use stderr for status/progress to keep stdout clean for data output
3232
# force_terminal=True ensures Rich output is visible even in non-TTY environments

‎tests/test_docs_are_accurate.py‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,56 @@ def test_every_relative_link_resolves_inside_the_published_site(page):
265265
+ "\nUse an absolute https://github.com/... URL for anything outside "
266266
"docs/."
267267
)
268+
269+
270+
# ---------------------------------------------------------------------------
271+
# every command is documented
272+
#
273+
# The tests above check one direction: that everything the docs claim really
274+
# exists. They say nothing about the reverse, so `convert` shipped in 0.6.0
275+
# with a section in COMMANDS.md that the table of contents never listed, and
276+
# an app help string that named neither it nor `create`. Both were invisible
277+
# to a suite that only walks from the docs to the code.
278+
#
279+
# Derived from the Click tree rather than a hardcoded list, so a command
280+
# added tomorrow is covered without anyone remembering to add it here.
281+
282+
283+
def _visible_commands():
284+
import typer
285+
286+
command = typer.main.get_command(app)
287+
return sorted(
288+
name for name, sub in command.commands.items() if not sub.hidden
289+
)
290+
291+
292+
COMMANDS_MD = (REPO / "docs" / "COMMANDS.md").read_text()
293+
294+
295+
@pytest.mark.parametrize("name", _visible_commands())
296+
def test_every_command_has_a_section_in_the_reference(name):
297+
assert f"## `{name}`" in COMMANDS_MD, (
298+
f"`adata {name}` has no `## \\`{name}\\`` section in docs/COMMANDS.md"
299+
)
300+
301+
302+
@pytest.mark.parametrize("name", _visible_commands())
303+
def test_every_command_is_in_the_table_of_contents(name):
304+
contents = COMMANDS_MD.split("---", 1)[0]
305+
assert f"](#{name})" in contents, (
306+
f"`adata {name}` is missing from the table of contents in "
307+
"docs/COMMANDS.md. The link text has no backticks: `- [name](#name)`."
308+
)
309+
310+
311+
@pytest.mark.parametrize("name", _visible_commands())
312+
def test_every_command_is_named_in_the_app_help(name):
313+
"""`adata --help` opens with a list; a command absent from it is hidden
314+
in plain sight, since that line is the first thing anyone reads."""
315+
import typer
316+
317+
help_text = typer.main.get_command(app).help or ""
318+
assert name in help_text, (
319+
f"`{name}` is missing from the app help string in cli.py: {help_text!r}"
320+
)

0 commit comments

Comments
 (0)