Skip to content

Commit

Permalink
docs: Format CLI reference code block
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Aug 19, 2023
1 parent 5d459e6 commit c7bd4ce
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions docs/cli_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,15 @@ from griffe.cli import get_parser
parser = get_parser()


def render_parser(
parser: argparse.ArgumentParser, title: str, heading_level: int = 2
) -> str:
def render_parser(parser: argparse.ArgumentParser, title: str, heading_level: int = 2) -> str:
"""Render the parser help documents as a string."""
result = [f"{'#' * heading_level} {title}\n"]
if parser.description and title != "pdm":
result.append("> " + parser.description + "\n")

for group in sorted(
parser._action_groups, key=lambda g: g.title.lower(), reverse=True
):
for group in sorted(parser._action_groups, key=lambda g: g.title.lower(), reverse=True):
if not any(
bool(action.option_strings or action.dest)
or isinstance(action, argparse._SubParsersAction)
bool(action.option_strings or action.dest) or isinstance(action, argparse._SubParsersAction)
for action in group._group_actions
):
continue
Expand Down

0 comments on commit c7bd4ce

Please sign in to comment.