Closed maxcmoi89 closed 2 years ago
It seems like Click \b
does not prevent rewrapping anymore with this solution. I tweaked it a little with :
import inspect
def _format_description(ctx):
"""Format the description for a given `click.Command`.
We parse this as reStructuredText, allowing users to embed rich
information in their help messages if they so choose.
"""
# Gets the ctx.command.__doc__ instead of ctx.command.help to avoid truncation by click class
help_string = inspect.cleandoc(ctx.command.__doc__) or ctx.command.short_help
if help_string:
yield from _format_help(help_string)
which seems to be working. I will test it some more before doing a pull request.
This is a duplicate of #56. Note that your proposed solution would only work if the user is defining their help strings using docstring as opposed to the Command.help
argument. I think we'd be better off relying on https://github.com/pallets/click/pull/2151 which was included in click 8.1.0 and means click now stores raw strings, allowing us to process this stuff manually.
Click can truncate the docstring as help text. When inserting
\f
in the docstring all lines after this are hidden in help. Documentation : https://click.palletsprojects.com/en/8.0.x/documentation/#truncating-help-textsFor my documentation I wanted to have less information for the
command --help
than what would be present in the documentation. Naively I added a\f
thinking that it would be hidden on the--help
but present in the Sphinx documentation which was not the case. Sphinx-click gets the ctx.command.help of Click which is trunctated for the documentation. A quick fix could be :Instead of :
Your toughts ?
If this seems good I will do a pull requests with the changes.