Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit edb471d

Browse files
Merge branch 'rewrite_help_pages_2' of https://github.com/Rowlando13/click into rewrite_help_pages_2
2 parents 2a6b6bf + 4336056 commit edb471d

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

‎docs/documentation.rst‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Simple example:
3535
Command Short Help
3636
------------------
3737

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``:
3939

4040
.. click:example::
4141
@@ -59,7 +59,9 @@ The help epilog is printed at the end of the help and is useful for showing exam
5959

6060
.. click:example::
6161
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+
)
6365
def init():
6466
"""Initializes the repository."""
6567

@@ -72,7 +74,7 @@ Documenting Arguments
7274
----------------------
7375

7476
: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 text
75-
by name. For Python that means including them in docstrings.
77+
by name. This should then be done via the docstring.
7678

7779
A brief example:
7880

@@ -185,7 +187,7 @@ Example:
185187
invoke(cli, args=['--help'])
186188

187189

188-
Placeholder Variable
190+
Placeholder / Meta Variable
189191
-----------------------
190192

191193
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.
@@ -197,8 +199,8 @@ The default placeholder variable (`meta variable <https://en.wikipedia.org/wiki/
197199
@click.option('--count', default=1, help='number of greetings',
198200
metavar='<int>')
199201
@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."""
202204
for x in range(count):
203205
click.echo(f"Hello {name}!")
204206

@@ -210,7 +212,7 @@ Example:
210212

211213
Help Parameter Customization
212214
----------------------------
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.
214216

215217
This example changes the default parameters to ``-h`` and ``--help``
216218
instead of just ``--help``:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /