Skip to content
Myr

Apply suggestions from code review

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Rowlando13 · committed by GitHub · parent 9d7c7dc · Browse files · 1 file+9 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Andreas Backx <AndreasBackx@users.noreply.github.com>

Diff stats

1 file+9 added−7 removed

  • other:+9 added−7 removed

1 file+9 added−7 removed

modified:docs/documentation.rst+9 added-7 removed
35 unmodified lines
3637Command Short Help38------------------3940For sub commands, a short help snippet is generated. By default, it's the first sentence of the docstring. If it is too long, then it will show as much as it can on one line and end with ``...``. The short help snippet can also be overridden with the kwarg ``short_help``:40For subcommands, a short help snippet is generated. By default, it's the first sentence of the docstring. If too long, then it will ellipsize what cannot be fit on a single line with ``...``. The short help snippet can also be overridden with ``short_help``:4142.. click:example::4344 @click.group()
16 unmodified lines
61The help epilog is printed at the end of the help and is useful for showing example command usages or referencing additional help resources.6263.. click:example::6465 @click.command(epilog='Check out our docs at https://click.palletsprojects.com/ for more details')65 @click.command(66 epilog='See https://example.com for more details',67 )68 def init():69 """Initializes the repository."""7071And from the command line:
5 unmodified lines
77Documenting Arguments78----------------------7980:class:`click.argument` does not take a ``help`` parameter. This follows the Unix Command Line Tools convention of using arguments only for necessary things and documenting them in the command help text79by name. For Python that means including them in docstrings.81by name. This should then be done via the docstring.8283A brief example:8485.. click:example::
112 unmodified lines
198199 invoke(cli, args=['--help'])200201200Placeholder Variable202Placeholder / Meta Variable203-----------------------204205The default placeholder variable (`meta variable <https://en.wikipedia.org/wiki/Metasyntactic_variable#IETF_Requests_for_Comments>`_) in the help pages is the parameter name in uppercase with underscores. This can be changed for Commands and Parameters with the ``options_metavar`` and ``metavar`` kwargs.206
3 unmodified lines
210 @click.command(options_metavar='[[options]]')211 @click.option('--count', default=1, help='number of greetings',212 metavar='<int>')213 @click.argument('name', metavar='<name>')212 def hello(count, name):213 """This script prints hello to things."""214 def hello(name: str, count: int) -> None:215 """This script prints 'hello <name>' a total of <count> times."""216 for x in range(count):217 click.echo(f"Hello {name}!")218219Example:
3 unmodified lines
223 invoke(hello, args=['--help'])224225Help Parameter Customization226----------------------------225The help parameter(s) is automatically added by Click for any command. The default is ``--help`` but can be override by the context setting :attr:`~Context.help_option_names`. Click also performs automatic conflict resolution on the default help parameter so if a command itself implements a parameter named ``help`` then the default help will no be run.227Help parameters are automatically added by Click for any command. The default is ``--help`` but can be override by the context setting :attr:`~Context.help_option_names`. Click also performs automatic conflict resolution on the default help parameter so if a command itself implements a parameter named ``help`` then the default help will not be run.228229This example changes the default parameters to ``-h`` and ``--help``230instead of just ``--help``:231
13 unmodified lines