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
Provenance
- Commit
edb471d- Tree
f8eb261- Author
Edward G <edward.g2013@gmail.com>- Committer
Edward G <edward.g2013@gmail.com>- Parent 1
2a6b6bf- Parent 2
4336056
1 file changed+9 added−7 removed
modified:docs/documentation.rst+9 added-7 removed
33 unmodified lines34 35 Command Short Help36 ------------------37 38-For 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``:38+For 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``:39 40 .. click:example::41 42 @click.group()15 unmodified lines58 The help epilog is printed at the end of the help and is useful for showing example command usages or referencing additional help resources.59 60 .. click:example::61 62- @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."""67 68 4 unmodified lines73 Documenting Arguments74 ----------------------75 76 :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 text75-by name. For Python that means including them in docstrings.77+by name. This should then be done via the docstring.78 79 A brief example:80 81 .. click:example::104 unmodified lines186 187 invoke(cli, args=['--help'])188 189 188-Placeholder Variable190+Placeholder / Meta Variable191 -----------------------192 193 The 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 lines198 @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}!")206 207 Example:3 unmodified lines211 invoke(hello, args=['--help'])212 213 Help Parameter Customization214 ----------------------------213-The 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.215+Help 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.216 217 This example changes the default parameters to ``-h`` and ``--help``218 instead of just ``--help``:219 12 unmodified lines