Skip to content

Commit

Permalink
chore: cli work
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Sep 19, 2023
1 parent bbc24f5 commit 245e331
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions mknodes/basenodes/mkclickdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
4 changes: 2 additions & 2 deletions mknodes/utils/clihelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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))

0 comments on commit 245e331

Please sign in to comment.