Skip to content

Commit 0446c51

Browse files
committed
fix(config): Add html_static_path and templates_path defaults
why: merge_sphinx_config() was missing these two keys, so downstream projects lost their _static/ directory (logos, custom CSS, images) and _templates/ overrides from the build output. Discovered when migrating tmuxp: logo 404'd because docs/_static/img/tmuxp.svg was never copied. Both paths are standard conventions every gp-sphinx consumer uses. Sphinx silently ignores missing directories in these lists, so the defaults are safe for projects that don't have one or both. what: - defaults.py: add DEFAULT_HTML_STATIC_PATH = ["_static"] - defaults.py: add DEFAULT_TEMPLATES_PATH = ["_templates"] - config.py: import and wire both into merge_sphinx_config() conf dict - tests/test_config.py: update test_merge_sphinx_config_html_paths to assert defaults are present instead of asserting they're absent
1 parent 9b014c9 commit 0446c51

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
DEFAULT_COPYBUTTON_PROMPT_TEXT,
4646
DEFAULT_COPYBUTTON_REMOVE_PROMPTS,
4747
DEFAULT_EXTENSIONS,
48+
DEFAULT_HTML_STATIC_PATH,
4849
DEFAULT_MYST_EXTENSIONS,
4950
DEFAULT_MYST_HEADING_ANCHORS,
5051
DEFAULT_NAPOLEON_GOOGLE_DOCSTRING,
@@ -57,6 +58,7 @@
5758
DEFAULT_SPHINX_FONT_PRELOAD,
5859
DEFAULT_SPHINX_FONTS,
5960
DEFAULT_SUPPRESS_WARNINGS,
61+
DEFAULT_TEMPLATES_PATH,
6062
DEFAULT_THEME,
6163
DEFAULT_THEME_OPTIONS,
6264
DEFAULT_TOC_OBJECT_ENTRIES_SHOW_PARENTS,
@@ -368,6 +370,9 @@ def merge_sphinx_config(
368370
"master_doc": "index",
369371
# Source
370372
"source_suffix": dict(DEFAULT_SOURCE_SUFFIX),
373+
# Static files and templates
374+
"html_static_path": list(DEFAULT_HTML_STATIC_PATH),
375+
"templates_path": list(DEFAULT_TEMPLATES_PATH),
371376
# Theme (gp-sphinx child theme provides sidebars, templates, CSS, JS)
372377
"html_theme": DEFAULT_THEME,
373378
"html_theme_path": [],

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,28 @@
122122
'markdown'
123123
"""
124124

125+
DEFAULT_HTML_STATIC_PATH: list[str] = ["_static"]
126+
"""Default path(s) to project-specific static files (CSS, images, JS).
127+
128+
Resolved relative to the docs source directory (``docs/_static/``).
129+
130+
Examples
131+
--------
132+
>>> DEFAULT_HTML_STATIC_PATH
133+
['_static']
134+
"""
135+
136+
DEFAULT_TEMPLATES_PATH: list[str] = ["_templates"]
137+
"""Default path(s) to Jinja2 template overrides.
138+
139+
Resolved relative to the docs source directory (``docs/_templates/``).
140+
141+
Examples
142+
--------
143+
>>> DEFAULT_TEMPLATES_PATH
144+
['_templates']
145+
"""
146+
125147
DEFAULT_PYGMENTS_STYLE: str = "monokai"
126148
"""Default Pygments syntax highlighting style."""
127149

tests/test_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,14 @@ def test_merge_sphinx_config_copybutton_continuation() -> None:
373373

374374

375375
def test_merge_sphinx_config_html_paths() -> None:
376-
"""Theme asset paths stay opt-in for minimal consumers."""
376+
"""Static and template paths default to standard locations; extras are opt-in."""
377377
result = merge_sphinx_config(
378378
project="test",
379379
version="1.0",
380380
copyright="2026",
381381
)
382-
assert "templates_path" not in result
383-
assert "html_static_path" not in result
382+
assert result["html_static_path"] == ["_static"]
383+
assert result["templates_path"] == ["_templates"]
384384
assert "html_favicon" not in result
385385
assert "html_extra_path" not in result
386386

0 commit comments

Comments
 (0)