Skip to content

Commit 9b014c9

Browse files
committed
fix(exemplar): Fix module import path and clean up dead code
why: When sphinx-argparse-neo is installed as a proper package, `from argparse_roles import register_roles` fails with ModuleNotFoundError because `argparse_roles` is no longer a top-level module on sys.path -- it was only resolvable when the file lived under docs/_ext/. The correct path is `sphinx_argparse_neo.roles`. Also removes the ASSETS_DIR constant from config.py: it pointed to a non-existent assets/ directory (spa-nav.js moved to sphinx-gptheme theme statics) and was never referenced by any code. Adds DEFAULT_TOC_OBJECT_ENTRIES_SHOW_PARENTS constant to defaults.py and wires it into merge_sphinx_config() to replace the inline "hide" literal. what: - sphinx_argparse_neo/exemplar.py: from argparse_roles → from sphinx_argparse_neo.roles - gp_sphinx/config.py: remove ASSETS_DIR dead constant - gp_sphinx/defaults.py: add DEFAULT_TOC_OBJECT_ENTRIES_SHOW_PARENTS = "hide" - gp_sphinx/config.py: use DEFAULT_TOC_OBJECT_ENTRIES_SHOW_PARENTS constant
1 parent 82a1441 commit 9b014c9

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

packages/gp-sphinx/src/gp_sphinx/config.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
DEFAULT_SUPPRESS_WARNINGS,
6060
DEFAULT_THEME,
6161
DEFAULT_THEME_OPTIONS,
62+
DEFAULT_TOC_OBJECT_ENTRIES_SHOW_PARENTS,
6263
)
6364

6465
if t.TYPE_CHECKING:
@@ -68,9 +69,6 @@
6869

6970
logger = logging.getLogger(__name__)
7071

71-
ASSETS_DIR = pathlib.Path(__file__).parent / "assets"
72-
"""Path to bundled static assets (spa-nav.js, etc.)."""
73-
7472

7573
def deep_merge(base: dict[str, t.Any], override: dict[str, t.Any]) -> dict[str, t.Any]:
7674
"""Recursively merge *override* into *base*, returning a new dict.
@@ -390,7 +388,7 @@ def merge_sphinx_config(
390388
"autodoc_member_order": DEFAULT_AUTODOC_MEMBER_ORDER,
391389
"autodoc_class_signature": DEFAULT_AUTODOC_CLASS_SIGNATURE,
392390
"autodoc_typehints": DEFAULT_AUTODOC_TYPEHINTS,
393-
"toc_object_entries_show_parents": "hide",
391+
"toc_object_entries_show_parents": DEFAULT_TOC_OBJECT_ENTRIES_SHOW_PARENTS,
394392
"autodoc_default_options": dict(DEFAULT_AUTODOC_OPTIONS),
395393
# Napoleon
396394
"napoleon_google_docstring": DEFAULT_NAPOLEON_GOOGLE_DOCSTRING,

packages/gp-sphinx/src/gp_sphinx/defaults.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,18 @@
299299
DEFAULT_COPYBUTTON_LINE_CONTINUATION_CHARACTER: str = "\\"
300300
"""Line continuation character for sphinx-copybutton."""
301301

302+
DEFAULT_TOC_OBJECT_ENTRIES_SHOW_PARENTS: str = "hide"
303+
"""Hide parent module path in TOC object entries.
304+
305+
Keeps the API reference sidebar clean by showing only the object name
306+
(e.g. ``merge_sphinx_config``) instead of the full dotted path.
307+
308+
Examples
309+
--------
310+
>>> DEFAULT_TOC_OBJECT_ENTRIES_SHOW_PARENTS
311+
'hide'
312+
"""
313+
302314
DEFAULT_SUPPRESS_WARNINGS: list[str] = [
303315
"sphinx_autodoc_typehints.forward_reference",
304316
]

packages/sphinx-argparse-neo/src/sphinx_argparse_neo/exemplar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ def setup(app: Sphinx) -> dict[str, t.Any]:
12991299
app.add_lexer("argparse-help", ArgparseHelpLexer)
13001300

13011301
# Register CLI inline roles for documentation
1302-
from argparse_roles import register_roles
1302+
from sphinx_argparse_neo.roles import register_roles
13031303

13041304
register_roles()
13051305

0 commit comments

Comments
 (0)