|
1 | | -Extending results of `argparse` directives |
2 | | -========================================== |
| 1 | +Extending results of ``argparse`` directives |
| 2 | +============================================ |
3 | 3 |
|
4 | | -You can add extra content or even replace some parts of the documentation generated by the `argparse` directive. For example, any content you put inside directives (you must follow ReStructuredText identation rules) will be inserted just before the argument and option list:: |
| 4 | +You can add extra content or even replace some parts of the documentation generated by the ``argparse`` directive. |
| 5 | +For example, any content you put inside directives (you must follow ReStructuredText identation rules) will be inserted just before the argument and option list: |
| 6 | + |
| 7 | +.. code:: rst |
5 | 8 |
|
6 | 9 | .. argparse:: |
7 | | - :module: my.module |
8 | | - :func: my_func_that_return_parser |
9 | | - :prog: fancytool |
| 10 | + :module: my.module |
| 11 | + :func: my_func_that_return_parser |
| 12 | + :prog: fancytool |
10 | 13 |
|
11 | 14 | My content here that will be inserted right before the argument list. |
12 | 15 |
|
13 | 16 | Also any valid markup... |
14 | 17 | ************************* |
15 | 18 |
|
16 | | - ... may `be` *applied* here |
| 19 | + ... may ``be`` *applied* here |
17 | 20 |
|
18 | 21 | including:: |
19 | 22 |
|
20 | 23 | any directives you usually use. |
21 | 24 |
|
22 | 25 |
|
23 | | -Also, there is an option to insert custom content into a specific argument/option/subcommand/argument-group description. Just create a name:definition pair, where the name is an argument/option/subcommand/argument-group name and the definition is any reStructured markup. Changes to options/arguments appearing in multiple action groups can either be targeted (i.e., only one instance of the argument is changed) or general (i.e., all instances are modified).:: |
| 26 | +Also, there is an option to insert custom content into a specific argument/option/subcommand/argument-group description. |
| 27 | +Just create a name:definition pair, where the name is an argument/option/subcommand/argument-group name and the definition is any reStructured markup. |
| 28 | +Changes to options/arguments appearing in multiple action groups can either be targeted (i.e., only one instance of the argument is changed) or general (i.e., all instances are modified). |
| 29 | + |
| 30 | +.. code:: rst |
24 | 31 |
|
25 | 32 | .. argparse:: |
26 | | - :module: my.module |
27 | | - :func: my_func_that_return_parser |
28 | | - :prog: fancytool |
| 33 | + :module: my.module |
| 34 | + :func: my_func_that_return_parser |
| 35 | + :prog: fancytool |
29 | 36 |
|
30 | | - My content here that will be inserted right before the argument list. |
| 37 | + My content here that will be inserted right before the argument list. |
| 38 | +
|
| 39 | + foo |
| 40 | + This text will go right after the "foo" positional argument help. |
31 | 41 |
|
32 | | - foo |
33 | | - This text will go right after the "foo" positional argument help. |
| 42 | + install |
| 43 | + This text will go right after the "install" subcommand help and before its arguments. |
34 | 44 |
|
35 | | - install |
36 | | - This text will go right after the "install" subcommand help and before its arguments. |
| 45 | + --upgrade -u |
| 46 | + This text will go after the upgrade option of the install subcommand. Nesting is unlimited. |
| 47 | + Note the space between --upgrade and -u, which differs from the comma that would normally |
| 48 | + be used. |
37 | 49 |
|
38 | | - --upgrade -u |
39 | | - This text will go after the upgrade option of the install subcommand. Nesting is unlimited. |
40 | | - Note the space between --upgrade and -u, which differs from the comma that would normally |
41 | | - be used. |
| 50 | + --output -o |
| 51 | + Content appended to the --output option, regardless of the argument group. |
42 | 52 |
|
43 | | - --output -o |
44 | | - Content appended to the --output option, regardless of the argument group. |
45 | 53 |
|
| 54 | +You can also add classifiers, which will change how these definitions are incorporated: |
46 | 55 |
|
47 | | -You can also add classifiers, which will change how these definitions are incorporated:: |
| 56 | +.. code:: rst |
48 | 57 |
|
49 | 58 | .. argparse:: |
50 | | - :module: my.module |
51 | | - :func: my_func_that_return_parser |
52 | | - :prog: fancytool |
| 59 | + :module: my.module |
| 60 | + :func: my_func_that_return_parser |
| 61 | + :prog: fancytool |
53 | 62 |
|
54 | | - My content that will be inserted right before the argument list. |
| 63 | + My content that will be inserted right before the argument list. |
55 | 64 |
|
56 | | - foo : @before |
57 | | - This text will go before the "foo" positional argument help. |
| 65 | + foo : @before |
| 66 | + This text will go before the "foo" positional argument help. |
58 | 67 |
|
59 | | - install : @replace |
60 | | - This text will replace the "install" subcommand help/description. |
| 68 | + install : @replace |
| 69 | + This text will replace the "install" subcommand help/description. |
61 | 70 |
|
62 | | - --upgrade : @after |
63 | | - The after directive is the default, so you needn't specify it. |
| 71 | + --upgrade : @after |
| 72 | + The after directive is the default, so you needn't specify it. |
64 | 73 |
|
65 | | - advanced arguments : @skip |
66 | | - skip advanced arguments |
| 74 | + advanced arguments : @skip |
| 75 | + skip advanced arguments |
67 | 76 |
|
68 | 77 |
|
69 | 78 | @before |
|
0 commit comments