Skip to content
Myr

Merge branch 'rewrite_help_pages_2' of https://github.com/Rowlando13/click into rewrite_help_pages_2

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

authored by Edward G · committed by Edward G · parents 2a6b6bf, 4336056 · 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.

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
33 unmodified lines
3435Command Short Help36------------------3738For 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``:38For 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``:3940.. click:example::4142 @click.group()
15 unmodified lines
58The help epilog is printed at the end of the help and is useful for showing example command usages or referencing additional help resources.5960.. click:example::6162 @click.command(epilog='Check out our docs at https://click.palletsprojects.com/ for more details')62 @click.command(63 epilog='See https://example.com for more details',64 )65 def init():66 """Initializes the repository."""6768
4 unmodified lines
73Documenting Arguments74----------------------7576: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 text75by name. For Python that means including them in docstrings.77by name. This should then be done via the docstring.7879A brief example:8081.. click:example::
104 unmodified lines
186187 invoke(cli, args=['--help'])188189188Placeholder Variable190Placeholder / Meta Variable191-----------------------192193The 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.194
3 unmodified lines
198 @click.command(options_metavar='[[options]]')199 @click.option('--count', default=1, help='number of greetings',200 metavar='<int>')201 @click.argument('name', metavar='<name>')200 def hello(count, name):201 """This script prints hello to things."""202 def hello(name: str, count: int) -> None:203 """This script prints 'hello <name>' a total of <count> times."""204 for x in range(count):205 click.echo(f"Hello {name}!")206207Example:
3 unmodified lines
211 invoke(hello, args=['--help'])212213Help Parameter Customization214----------------------------213The 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.215Help 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.216217This example changes the default parameters to ``-h`` and ``--help``218instead of just ``--help``:219
12 unmodified lines