Skip to content

Commit

Permalink
[docs] fix truncated cli sub commands (#27994)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmpadden authored Feb 22, 2025
1 parent f5dba1d commit e3ce424
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions docs/sphinx/_ext/sphinx-click/sphinx_click/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,31 @@ def _format_envvars(ctx: click.Context) -> ty.Generator[str, None, None]:

def _format_subcommand(command: click.Command) -> ty.Generator[str, None, None]:
"""Format a sub-command of a `click.Command` or `click.Group`."""
yield f".. object:: {command.name}"
# yield f".. object:: {command.name}"

# short_help = command.get_short_help_str()
#
# if short_help:
# yield ""
# for line in statemachine.string2lines(short_help, tab_width=4, convert_whitespace=True):
# yield _indent(line)

short_help = command.get_short_help_str()
# NOTE: this was overriden from the default implementation to show the entirety of the help
# text, similar to the formatting logic for `.. option`s. The commented code above was the
# original implementation using `get_short_help_str()`. See open issue here:
#
# https://github.com/click-contrib/sphinx-click/issues/150

if short_help:
yield f".. object:: {command.name}"
if command.help:
yield ""
for line in statemachine.string2lines(short_help, tab_width=4, convert_whitespace=True):
for line in statemachine.string2lines(
ANSI_ESC_SEQ_RE.sub("", command.help), tab_width=4, convert_whitespace=True
):
if "\\b" in line:
continue
yield _indent(line)
yield "" # workaround to display lines on their own line in MDX, eventually this should be improved


@_process_lines("sphinx-click-process-epilog")
Expand Down Expand Up @@ -392,8 +409,7 @@ def _format_command(
if command_obj.hidden:
continue

for line in _format_subcommand(command_obj):
yield line
yield from _format_subcommand(command_obj)
yield ""


Expand Down

1 comment on commit e3ce424

@github-actions
Copy link

@github-actions github-actions bot commented on e3ce424 Feb 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagster-docs ready!

✅ Preview
https://dagster-docs-fhgs2nb47-elementl.vercel.app

Built with commit e3ce424.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.