Skip to content

Commit 23cd55e

Browse files
authored
Move JS to theme (#126)
1 parent 7f45b97 commit 23cd55e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

docs/conf.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,15 @@ def test_search(value: str, pattern: str) -> bool:
7777

7878
rtd_links_prefix = PurePosixPath("src")
7979

80-
rtd_ver = os.environ.get("READTHEDOCS_VERSION", "")
81-
if re.fullmatch(r"\d+", rtd_ver): # PR versions don’t have a own search index
80+
# PR versions don’t have a own search index
81+
if re.fullmatch(r"\d+", os.environ.get("READTHEDOCS_VERSION", "")):
8282
rtd_sphinx_search_default_filter = (
8383
f"subprojects:{os.getenv('READTHEDOCS_PROJECT')}/latest"
8484
)
8585

8686

8787
def setup(app: Sphinx) -> None:
8888
"""Set up custom Sphinx extension."""
89-
if rtd_ver: # if we’re on ReadTheDocs, hide the pydata-sphinx-theme search popup
90-
app.add_js_file("scripts/rtd-sphinx-search.js", loading_method="defer")
9189
app.add_object_type(
9290
"confval",
9391
"confval",

src/scanpydoc/theme/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070

7171
from __future__ import annotations
7272

73+
import os
7374
from typing import TYPE_CHECKING
7475
from pathlib import Path
7576

@@ -87,4 +88,9 @@
8788
def setup(app: Sphinx) -> dict[str, bool]: # pragma: no cover
8889
"""Set up theme (like an extension)."""
8990
app.add_html_theme("scanpydoc", str(HERE))
91+
92+
# if we’re on ReadTheDocs, hide the pydata-sphinx-theme search popup
93+
if os.environ.get("READTHEDOCS_VERSION", ""): # pragma: no cover
94+
app.add_js_file("scripts/rtd-sphinx-search.js", loading_method="defer")
95+
9096
return dict(parallel_read_safe=True, parallel_write_safe=True)

0 commit comments

Comments
 (0)