@@ -265,3 +265,56 @@ def test_every_relative_link_resolves_inside_the_published_site(page):
265265 + "\n Use 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