You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For 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 :
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 = ctx.command.__doc__ or ctx.command.short_help
if help_string:
yield from _format_help(help_string)
Instead of :
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.
"""
help_string = ctx.command.help or ctx.command.short_help
if help_string:
yield from _format_help(help_string)
Your toughts ?
If this seems good I will do a pull requests with the changes.
The text was updated successfully, but these errors were encountered:
maxcmoi89
changed the title
Help text truncated when \f is present in the docstring
Documentation truncated when \f is present in the docstring
Mar 28, 2022
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 pallets/click#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.
The text was updated successfully, but these errors were encountered: