Skip to content

Commit

Permalink
adds anchors to commands lists
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Klavens authored and Alex Klavens committed Apr 26, 2024
1 parent 8bffffd commit b6654fc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
10 changes: 5 additions & 5 deletions tests/assets/cli/multiapp-docs-title.md
Expand Up @@ -18,8 +18,8 @@ The end

**Commands**:

* `sub`
* `top`: Top command
* [`sub`](#multiapp-sub)
* [`top`](#multiapp-top): Top command

## `multiapp sub`

Expand All @@ -35,9 +35,9 @@ $ multiapp sub [OPTIONS] COMMAND [ARGS]...

**Commands**:

* `bye`: Say bye
* `hello`: Say Hello
* `hi`: Say Hi
* [`bye`](#multiapp-sub-bye): Say bye
* [`hello`](#multiapp-sub-hello): Say Hello
* [`hi`](#multiapp-sub-hi): Say Hi

### `multiapp sub bye`

Expand Down
10 changes: 5 additions & 5 deletions tests/assets/cli/multiapp-docs.md
Expand Up @@ -18,8 +18,8 @@ The end

**Commands**:

* `sub`
* `top`: Top command
* [`sub`](#multiapp-sub)
* [`top`](#multiapp-top): Top command

## `multiapp sub`

Expand All @@ -35,9 +35,9 @@ $ multiapp sub [OPTIONS] COMMAND [ARGS]...

**Commands**:

* `bye`: Say bye
* `hello`: Say Hello
* `hi`: Say Hi
* [`bye`](#multiapp-sub-bye): Say bye
* [`hello`](#multiapp-sub-hello): Say Hello
* [`hi`](#multiapp-sub-hi): Say Hi

### `multiapp sub bye`

Expand Down
3 changes: 2 additions & 1 deletion typer/cli.py
Expand Up @@ -244,7 +244,8 @@ def get_docs_for_click(
for command in commands:
command_obj = group.get_command(ctx, command)
assert command_obj
docs += f"* `{command_obj.name}`"
command_anchor = f"{command_name.lower().replace(' ', '-')}-{command_obj.name.lower().replace(' ', '-')}"
docs += f"* [`{command_obj.name}`](#{command_anchor})"
command_help = command_obj.get_short_help_str()
if command_help:
docs += f": {command_help}"
Expand Down

0 comments on commit b6654fc

Please sign in to comment.