sphinx-argparse-cli 1.21.1__tar.gz → 1.21.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/PKG-INFO +1 -1
- {sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/src/sphinx_argparse_cli/__init__.py +14 -0
- {sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/src/sphinx_argparse_cli/_logic.py +6 -4
- {sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/src/sphinx_argparse_cli/version.py +2 -2
- {sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/tests/test_logic.py +16 -3
- {sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/.gitignore +0 -0
- {sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/LICENSE.txt +0 -0
- {sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/README.md +0 -0
- {sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/pyproject.toml +0 -0
- {sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/src/sphinx_argparse_cli/py.typed +0 -0
- {sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/tests/complex.txt +0 -0
- {sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/tests/complex_pre_310.txt +0 -0
- {sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/tests/conftest.py +0 -0
- {sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/tests/test_sphinx_argparse_cli.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sphinx-argparse-cli
|
|
3
|
-
Version: 1.21.
|
|
3
|
+
Version: 1.21.3
|
|
4
4
|
Summary: render CLI arguments (sub-commands friendly) defined by argparse module
|
|
5
5
|
Project-URL: Documentation, https://github.com/tox-dev/sphinx-argparse-cli#sphinx-argparse-cli
|
|
6
6
|
Project-URL: Homepage, https://github.com/tox-dev/sphinx-argparse-cli
|
{sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/src/sphinx_argparse_cli/__init__.py
RENAMED
|
@@ -15,10 +15,24 @@ def setup(app: Sphinx) -> dict[str, Any]:
|
|
|
15
15
|
|
|
16
16
|
app.add_directive(SphinxArgparseCli.name, SphinxArgparseCli)
|
|
17
17
|
app.add_config_value("sphinx_argparse_cli_prefix_document", False, "env") # noqa: FBT003
|
|
18
|
+
app.add_css_file("sphinx_argparse_cli.css")
|
|
19
|
+
app.connect("build-finished", _write_css)
|
|
18
20
|
|
|
19
21
|
return {"parallel_read_safe": True}
|
|
20
22
|
|
|
21
23
|
|
|
24
|
+
def _write_css(app: Sphinx, exception: Exception | None) -> None:
|
|
25
|
+
if exception or not app.builder or app.builder.format != "html":
|
|
26
|
+
return
|
|
27
|
+
from pathlib import Path # noqa: PLC0415
|
|
28
|
+
|
|
29
|
+
static = Path(app.outdir) / "_static"
|
|
30
|
+
static.mkdir(parents=True, exist_ok=True)
|
|
31
|
+
(static / "sphinx_argparse_cli.css").write_text(
|
|
32
|
+
".sphinx-argparse-cli-wrap pre { white-space: pre-wrap; word-wrap: break-word; }\n"
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
22
36
|
__all__ = [
|
|
23
37
|
"__version__",
|
|
24
38
|
]
|
|
@@ -25,6 +25,7 @@ from docutils.nodes import (
|
|
|
25
25
|
Node,
|
|
26
26
|
Text,
|
|
27
27
|
bullet_list,
|
|
28
|
+
container,
|
|
28
29
|
fully_normalize_name,
|
|
29
30
|
list_item,
|
|
30
31
|
literal,
|
|
@@ -144,7 +145,8 @@ class SphinxArgparseCli(SphinxDirective):
|
|
|
144
145
|
self._parser.prog = new_prog
|
|
145
146
|
_update_sub_parser_prog(self._parser, old_prog, new_prog)
|
|
146
147
|
|
|
147
|
-
|
|
148
|
+
formatter = self._parser.formatter_class
|
|
149
|
+
self._raw_format = isinstance(formatter, type) and issubclass(formatter, RawDescriptionHelpFormatter)
|
|
148
150
|
return self._parser
|
|
149
151
|
|
|
150
152
|
def _load_sub_parsers(
|
|
@@ -187,7 +189,7 @@ class SphinxArgparseCli(SphinxDirective):
|
|
|
187
189
|
self.env.note_reread() # this document needs to be always updated
|
|
188
190
|
title_text = self.options.get("title", f"{self.parser.prog} - CLI interface").strip()
|
|
189
191
|
if not title_text:
|
|
190
|
-
home_section: Element =
|
|
192
|
+
home_section: Element = container("")
|
|
191
193
|
else:
|
|
192
194
|
home_section = section("", title("", Text(title_text)), ids=[self.make_id(title_text)], names=[title_text])
|
|
193
195
|
|
|
@@ -223,7 +225,7 @@ class SphinxArgparseCli(SphinxDirective):
|
|
|
223
225
|
if block is None:
|
|
224
226
|
return None
|
|
225
227
|
if self._raw_format and "\n" in block:
|
|
226
|
-
lit = literal_block("", Text(block))
|
|
228
|
+
lit = literal_block("", Text(block), classes=["sphinx-argparse-cli-wrap"])
|
|
227
229
|
lit["language"] = "none"
|
|
228
230
|
return lit
|
|
229
231
|
return paragraph("", Text(block))
|
|
@@ -423,7 +425,7 @@ class SphinxArgparseCli(SphinxDirective):
|
|
|
423
425
|
with self.no_color():
|
|
424
426
|
texts = parser.format_usage()[len("usage: ") :].splitlines()
|
|
425
427
|
texts = [line if at == 0 else f"{' ' * (len(parser.prog) + 1)}{line.lstrip()}" for at, line in enumerate(texts)]
|
|
426
|
-
return literal_block("", Text("\n".join(texts)))
|
|
428
|
+
return literal_block("", Text("\n".join(texts)), classes=["sphinx-argparse-cli-wrap"])
|
|
427
429
|
|
|
428
430
|
@contextmanager
|
|
429
431
|
def no_color(self) -> Iterator[None]:
|
{sphinx_argparse_cli-1.21.1 → sphinx_argparse_cli-1.21.3}/src/sphinx_argparse_cli/version.py
RENAMED
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '1.21.
|
|
32
|
-
__version_tuple__ = version_tuple = (1, 21,
|
|
31
|
+
__version__ = version = '1.21.3'
|
|
32
|
+
__version_tuple__ = version_tuple = (1, 21, 3)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
@@ -133,6 +133,15 @@ def test_multiline_epilog_as_html(build_outcome: str) -> None:
|
|
|
133
133
|
assert ref in build_outcome
|
|
134
134
|
|
|
135
135
|
|
|
136
|
+
@pytest.mark.sphinx(buildername="html", testroot="epilog-multiline-subclass")
|
|
137
|
+
def test_multiline_epilog_subclass_formatter_as_html(build_outcome: str) -> None:
|
|
138
|
+
ref = (
|
|
139
|
+
"This epilog\nspans multiple lines.\n\n this line is indented.\n and also this.\n\nNow this should be"
|
|
140
|
+
" a separate paragraph.\n"
|
|
141
|
+
)
|
|
142
|
+
assert ref in build_outcome
|
|
143
|
+
|
|
144
|
+
|
|
136
145
|
@pytest.mark.sphinx(buildername="text", testroot="complex")
|
|
137
146
|
@pytest.mark.prepare(directive_args=[":usage_width: 100"])
|
|
138
147
|
def test_usage_width_default(build_outcome: str) -> None:
|
|
@@ -407,6 +416,10 @@ def test_multiword_prog(build_outcome: str) -> None:
|
|
|
407
416
|
|
|
408
417
|
|
|
409
418
|
@pytest.mark.sphinx(buildername="html", testroot="title-empty-groups")
|
|
410
|
-
def test_empty_title_groups_in_toctree(
|
|
411
|
-
|
|
412
|
-
|
|
419
|
+
def test_empty_title_groups_in_toctree(app: SphinxTestApp, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
420
|
+
monkeypatch.setenv("FORCE_COLOR", "1")
|
|
421
|
+
monkeypatch.delenv("NO_COLOR", raising=False)
|
|
422
|
+
app.build()
|
|
423
|
+
cli_html = (Path(app.outdir) / "cli.html").read_text()
|
|
424
|
+
assert '<section id="tool-options">' in cli_html
|
|
425
|
+
assert "be verbose" in cli_html
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|