diff --git a/mknodes/basenodes/mkclickdoc.py b/mknodes/basenodes/mkclickdoc.py index cc6587f7..bb541c5f 100644 --- a/mknodes/basenodes/mkclickdoc.py +++ b/mknodes/basenodes/mkclickdoc.py @@ -72,7 +72,7 @@ def _to_markdown(self) -> str: mod = importlib.import_module(attrs["module"]) instance = getattr(mod, attrs["command"]) info = clihelpers.get_typer_info(instance, command=attrs["prog_name"]) - return info.to_markdown() + return info.to_markdown(recursive=self.show_subcommands) @staticmethod def create_example_page(page): @@ -85,5 +85,5 @@ def create_example_page(page): if __name__ == "__main__": - docstrings = MkClickDoc.with_default_context("mknodes.cli:cli", prog_name="build") + docstrings = MkClickDoc.with_default_context("mknodes.cli:cli", prog_name="mkdocs") print(docstrings) diff --git a/mknodes/utils/clihelpers.py b/mknodes/utils/clihelpers.py index a443aa09..ae25b0ba 100644 --- a/mknodes/utils/clihelpers.py +++ b/mknodes/utils/clihelpers.py @@ -85,7 +85,7 @@ def get_typer_info( ctx = typer.Context(cmd) subcommands = getattr(cmd, "commands", {}) cmds = {k: get_command_info(v, parent=ctx) for k, v in subcommands.items()} - return cmds[command] + return cmds.get(command, info) return info @@ -129,5 +129,5 @@ def _make_usage(ctx: click.Context) -> str: import mkdocs.__main__ - info = get_typer_info(mkdocs.__main__.cli) + info = get_typer_info(mkdocs.__main__.cli, command="mkdocs") pprint(info.to_markdown(recursive=True))