|
3 | 3 | import sys
|
4 | 4 | from os.path import dirname, relpath
|
5 | 5 | from pathlib import Path
|
6 |
| -from typing import Dict, List, Union |
| 6 | +import typing as t |
7 | 7 |
|
8 | 8 | import libtmux # NOQA
|
9 | 9 | from libtmux import test # NOQA
|
10 | 10 |
|
| 11 | +if t.TYPE_CHECKING: |
| 12 | + from sphinx.application import Sphinx |
| 13 | + |
11 | 14 | # Get the project root dir, which is the parent dir of this
|
12 | 15 | cwd = Path(__file__).parent
|
13 | 16 | project_root = cwd.parent
|
|
17 | 20 | sys.path.insert(0, str(cwd / "_ext"))
|
18 | 21 |
|
19 | 22 | # package data
|
20 |
| -about: Dict[str, str] = {} |
| 23 | +about: t.Dict[str, str] = {} |
21 | 24 | with open(project_src / "libtmux" / "__about__.py") as fp:
|
22 | 25 | exec(fp.read(), about)
|
23 | 26 |
|
|
65 | 68 | html_css_files = ["css/custom.css"]
|
66 | 69 | html_extra_path = ["manifest.json"]
|
67 | 70 | 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]]]] = { |
70 | 73 | "light_logo": "img/libtmux.svg",
|
71 | 74 | "dark_logo": "img/libtmux.svg",
|
72 | 75 | "footer_icons": [
|
|
163 | 166 |
|
164 | 167 |
|
165 | 168 | 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 |
168 | 171 | """
|
169 | 172 | Determine the URL corresponding to Python object
|
170 | 173 |
|
@@ -236,3 +239,13 @@ def linkcode_resolve(
|
236 | 239 | fn,
|
237 | 240 | linespec,
|
238 | 241 | )
|
| 242 | + |
| 243 | + |
| 244 | +def remove_tabs_js(app: "Sphinx", exc: Exception) -> None: |
| 245 | + if app.builder.format == "html" and not exc: |
| 246 | + tabs_js = Path(app.builder.outdir) / "_static" / "tabs.js" |
| 247 | + tabs_js.unlink() |
| 248 | + |
| 249 | + |
| 250 | +def setup(app: "Sphinx") -> None: |
| 251 | + app.connect("build-finished", remove_tabs_js) |
0 commit comments