-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Stephen Finucane <stephen@that.guru>
- Loading branch information
1 parent
d8a73b7
commit 1503669
Showing
7 changed files
with
111 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Documenting commands | ||
==================== | ||
|
||
Consider the following sample application, using |Command|_: | ||
|
||
.. literalinclude:: ../../examples/commands/cli.py | ||
|
||
This can be documented using *sphinx-click* like so: | ||
|
||
.. code-block:: rst | ||
.. click:: commands.cli:cli | ||
:prog: cli | ||
:nested: full | ||
The rendered example is shown below. | ||
|
||
---- | ||
|
||
.. click:: commands.cli:cli | ||
:prog: cli | ||
:nested: full | ||
|
||
.. |Command| replace:: ``Command`` | ||
.. _Command: https://click.palletsprojects.com/en/7.x/api/#click.Command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Documenting groups | ||
================== | ||
|
||
Consider the following sample application, using |Group|_: | ||
|
||
.. literalinclude:: ../../examples/groups/cli.py | ||
|
||
This can be documented using *sphinx-click* like so: | ||
|
||
.. code-block:: rst | ||
.. click:: groups.cli:cli | ||
:prog: cli | ||
:nested: full | ||
The rendered example is shown below. | ||
|
||
---- | ||
|
||
.. click:: groups.cli:cli | ||
:prog: cli | ||
:nested: full | ||
|
||
.. |Group| replace:: ``Groups`` | ||
.. _Group: https://click.palletsprojects.com/en/7.x/api/#click.Group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ Examples | |
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:glob: | ||
|
||
* | ||
commands | ||
groups | ||
commandcollections |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# file: cli.py | ||
import click | ||
|
||
|
||
@click.command() | ||
@click.option('--param', envvar='PARAM', help='A sample option') | ||
@click.option('--another', metavar='[FOO]', help='Another option') | ||
@click.option( | ||
'--choice', | ||
help='A sample option with choices', | ||
type=click.Choice(['Option1', 'Option2']), | ||
) | ||
@click.option( | ||
'--numeric-choice', | ||
metavar='<choice>', | ||
help='A sample option with numeric choices', | ||
type=click.Choice([1, 2, 3]), | ||
) | ||
@click.option( | ||
'--flag', | ||
is_flag=True, | ||
help='A boolean flag', | ||
) | ||
@click.argument('ARG', envvar='ARG') | ||
def cli(bar): | ||
"""A sample command.""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# file: cli.py | ||
import click | ||
|
||
|
||
@click.group() | ||
@click.option( | ||
'--debug', | ||
default=False, | ||
is_flag=True, | ||
help="Output more information about what's going on.", | ||
) | ||
def cli(): | ||
"""A sample command group.""" | ||
pass | ||
|
||
|
||
@cli.command() | ||
@click.option('--param', envvar='PARAM', help='A sample option') | ||
@click.option('--another', metavar='[FOO]', help='Another option') | ||
def hello(): | ||
"""A sample command.""" | ||
pass |