Skip to content

Commit ddc99fa

Browse files
Epilog support (#146)
* Add support for epilog * Add epilog tests * Update README.md * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent b3dbb06 commit ddc99fa

File tree

15 files changed

+107
-2
lines changed

15 files changed

+107
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Within the reStructuredText files use the `sphinx_argparse_cli` directive that t
3737
| hook | (optional) hook `argparse` to retrieve the parser if `func` uses a parser instead of returning it. |
3838
| title | (optional) when provided, overwrites the `<prog> - CLI interface` title added by default and when empty, will not be included |
3939
| description | (optional) when provided, overwrites the description and when empty, will not be included |
40+
| epilog | (optional) when provided, overwrites the epilog and when empty, will not be included |
4041
| usage_width | (optional) how large should usage examples be - defaults to 100 character |
4142
| group_title_prefix | (optional) groups subsections title prefixes, accepts the string `{prog}` as a replacement for the program name - defaults to `{prog}` |
4243
| group_sub_title_prefix | (optional) subcommands groups subsections title prefixes, accepts replacement of `{prog}` and `{subcommand}` for program and subcommand name - defaults to `{prog} {subcommand}` |

roots/test-complex/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def make() -> ArgumentParser:
7-
parser = ArgumentParser(description="argparse tester", prog="complex")
7+
parser = ArgumentParser(description="argparse tester", prog="complex", epilog="test epilog")
88
parser.add_argument("--root", action="store_true", help="root flag")
99
parser.add_argument("--no-help", action="store_true")
1010
parser.add_argument("--outdir", "-o", type=str, help="output directory", metavar="out_dir")

roots/test-epilog-empty/conf.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from __future__ import annotations
2+
3+
import sys
4+
from pathlib import Path
5+
6+
sys.path.insert(0, str(Path(__file__).parent))
7+
extensions = ["sphinx_argparse_cli"]
8+
nitpicky = True

roots/test-epilog-empty/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.. sphinx_argparse_cli::
2+
:module: parser
3+
:func: make
4+
:epilog:

roots/test-epilog-empty/parser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from __future__ import annotations
2+
3+
from argparse import ArgumentParser
4+
5+
6+
def make() -> ArgumentParser:
7+
return ArgumentParser(prog="foo", epilog="epi", add_help=False)

roots/test-epilog-multiline/conf.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from __future__ import annotations
2+
3+
import sys
4+
from pathlib import Path
5+
6+
sys.path.insert(0, str(Path(__file__).parent))
7+
extensions = ["sphinx_argparse_cli"]
8+
nitpicky = True

roots/test-epilog-multiline/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.. sphinx_argparse_cli::
2+
:module: parser
3+
:func: make

roots/test-epilog-multiline/parser.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from __future__ import annotations
2+
3+
from argparse import ArgumentParser, RawDescriptionHelpFormatter
4+
5+
6+
def make() -> ArgumentParser:
7+
return ArgumentParser(
8+
prog="foo",
9+
epilog="""This epilog
10+
spans multiple lines.
11+
12+
this line is indented.
13+
and also this.
14+
15+
Now this should be a separate paragraph.
16+
""",
17+
formatter_class=RawDescriptionHelpFormatter,
18+
add_help=False,
19+
)

roots/test-epilog-set/conf.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from __future__ import annotations
2+
3+
import sys
4+
from pathlib import Path
5+
6+
sys.path.insert(0, str(Path(__file__).parent))
7+
extensions = ["sphinx_argparse_cli"]
8+
nitpicky = True

roots/test-epilog-set/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.. sphinx_argparse_cli::
2+
:module: parser
3+
:func: make
4+
:epilog: My own epilog

0 commit comments

Comments
 (0)