Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions roots/test-title-empty-groups/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from __future__ import annotations

import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).parent))
extensions = ["sphinx_argparse_cli"]
nitpicky = True
4 changes: 4 additions & 0 deletions roots/test-title-empty-groups/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.. sphinx_argparse_cli::
:module: parser
:func: make
:title:
9 changes: 9 additions & 0 deletions roots/test-title-empty-groups/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from __future__ import annotations

from argparse import ArgumentParser


def make() -> ArgumentParser:
parser = ArgumentParser(prog="tool")
parser.add_argument("--verbose", action="store_true", help="be verbose")
return parser
2 changes: 1 addition & 1 deletion src/sphinx_argparse_cli/_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def run(self) -> list[Node]:
self.env.note_reread() # this document needs to be always updated
title_text = self.options.get("title", f"{self.parser.prog} - CLI interface").strip()
if not title_text:
home_section: Element = paragraph()
home_section: Element = section("")
else:
home_section = section("", title("", Text(title_text)), ids=[self.make_id(title_text)], names=[title_text])

Expand Down
6 changes: 6 additions & 0 deletions tests/test_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,9 @@ def test_prog_subcommands(build_outcome: str) -> None:
def test_multiword_prog(build_outcome: str) -> None:
assert "python -m build positional arguments" in build_outcome
assert "python -m build options" in build_outcome


@pytest.mark.sphinx(buildername="html", testroot="title-empty-groups")
def test_empty_title_groups_in_toctree(build_outcome: str) -> None:
assert '<section id="tool-options">' in build_outcome
assert "be verbose" in build_outcome