Skip to content

Commit 44d643f

Browse files
committed
chore: Add typed remove_tabs_js fix for inline-tabs
1 parent d2325c5 commit 44d643f

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

docs/conf.py

+20-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
import sys
44
from os.path import dirname, relpath
55
from pathlib import Path
6-
from typing import Dict, List, Union
6+
import typing as t
77

88
import libtmux # NOQA
99
from libtmux import test # NOQA
1010

11+
if t.TYPE_CHECKING:
12+
from sphinx.application import Sphinx
13+
1114
# Get the project root dir, which is the parent dir of this
1215
cwd = Path(__file__).parent
1316
project_root = cwd.parent
@@ -17,7 +20,7 @@
1720
sys.path.insert(0, str(cwd / "_ext"))
1821

1922
# package data
20-
about: Dict[str, str] = {}
23+
about: t.Dict[str, str] = {}
2124
with open(project_src / "libtmux" / "__about__.py") as fp:
2225
exec(fp.read(), about)
2326

@@ -65,8 +68,8 @@
6568
html_css_files = ["css/custom.css"]
6669
html_extra_path = ["manifest.json"]
6770
html_theme = "furo"
68-
html_theme_path: List[str] = []
69-
html_theme_options: Dict[str, Union[str, List[Dict[str, str]]]] = {
71+
html_theme_path: t.List[str] = []
72+
html_theme_options: t.Dict[str, t.Union[str, t.List[t.Dict[str, str]]]] = {
7073
"light_logo": "img/libtmux.svg",
7174
"dark_logo": "img/libtmux.svg",
7275
"footer_icons": [
@@ -163,8 +166,8 @@
163166

164167

165168
def linkcode_resolve(
166-
domain: str, info: Dict[str, str]
167-
) -> Union[None, str]: # NOQA: C901
169+
domain: str, info: t.Dict[str, str]
170+
) -> t.Union[None, str]: # NOQA: C901
168171
"""
169172
Determine the URL corresponding to Python object
170173
@@ -236,3 +239,14 @@ def linkcode_resolve(
236239
fn,
237240
linespec,
238241
)
242+
243+
244+
def remove_tabs_js(app: "Sphinx", exc: Exception) -> None:
245+
# Fix for sphinx-inline-tabs#18
246+
if app.builder.format == "html" and not exc:
247+
tabs_js = Path(app.builder.outdir) / "_static" / "tabs.js"
248+
tabs_js.unlink()
249+
250+
251+
def setup(app: "Sphinx") -> None:
252+
app.connect("build-finished", remove_tabs_js)

0 commit comments

Comments
 (0)