|
18 | 18 | import importlib.util |
19 | 19 | import os |
20 | 20 | from pathlib import Path |
21 | | -from typing import Any, Dict |
| 21 | +from typing import Any |
22 | 22 |
|
23 | 23 | from sphinx.application import Sphinx |
24 | 24 | from sphinx.config import Config |
25 | 25 | from sphinx.errors import ConfigError |
26 | 26 | from sphinx.util import logging |
27 | 27 |
|
28 | 28 |
|
29 | | -def setup(app: Sphinx) -> Dict[str, Any]: |
| 29 | +class SphinxConfig(Config): |
| 30 | + """Expanded class for linting config options.""" |
| 31 | + |
| 32 | + notfound_urls_prefix: str |
| 33 | + html_theme: str |
| 34 | + html_last_updated_fmt: str |
| 35 | + html_permalinks_icon: str |
| 36 | + html_theme_options: dict[str, Any] |
| 37 | + html_favicon: str |
| 38 | + notfound_template: str |
| 39 | + latex_engine: str |
| 40 | + latex_show_pagerefs: bool |
| 41 | + latex_show_urls: str |
| 42 | + latex_table_style: list[str] |
| 43 | + latex_config: str |
| 44 | + latex_elements: dict[str, Any] |
| 45 | + html_copy_source: bool |
| 46 | + html_show_sourcelink: bool |
| 47 | + |
| 48 | + def __init__(self) -> None: |
| 49 | + pass |
| 50 | + |
| 51 | + |
| 52 | +def setup(app: Sphinx) -> dict[str, Any]: |
30 | 53 | """Perform the main configuration and theme-setting.""" |
31 | 54 | # These are options that the user can set on their "conf.py" |
32 | 55 | # (many options are still missing). |
33 | | - app.add_config_value( |
| 56 | + app.add_config_value( # pyright: ignore [reportUnknownMemberType] |
34 | 57 | "disable_feedback_button", |
35 | 58 | default=False, |
36 | 59 | rebuild="env", |
37 | 60 | types=bool, |
38 | 61 | ) |
39 | | - app.add_config_value("slug", default="", rebuild="env", types=str) |
40 | | - app.add_config_value("epub_build", default=False, rebuild="env", types=bool) |
| 62 | + app.add_config_value( # pyright: ignore [reportUnknownMemberType] |
| 63 | + "slug", |
| 64 | + default="", |
| 65 | + rebuild="env", |
| 66 | + types=str, |
| 67 | + ) |
| 68 | + app.add_config_value( # pyright: ignore [reportUnknownMemberType] |
| 69 | + "epub_build", |
| 70 | + default=False, |
| 71 | + rebuild="env", |
| 72 | + types=bool, |
| 73 | + ) |
41 | 74 |
|
42 | 75 | extra_extensions = [ |
43 | 76 | "myst_parser", |
@@ -88,7 +121,7 @@ def setup(app: Sphinx) -> Dict[str, Any]: |
88 | 121 | } |
89 | 122 |
|
90 | 123 |
|
91 | | -def config_inited(app: Sphinx, config: Config) -> None: # noqa: PLR0915, PLR0912 |
| 124 | +def config_inited(app: Sphinx, config: SphinxConfig) -> None: # noqa: PLR0915, PLR0912 |
92 | 125 | """Read user-provided values and setup defaults.""" |
93 | 126 | # Get the Sphinx warning logger early |
94 | 127 | logger = logging.getLogger(__name__) |
@@ -184,7 +217,9 @@ def config_inited(app: Sphinx, config: Config) -> None: # noqa: PLR0915, PLR091 |
184 | 217 | with Path.open(theme_dir / "PDF/latex_elements_template.txt", "r+") as file: |
185 | 218 | config.latex_config = file.read() |
186 | 219 |
|
187 | | - if config.latex_elements == {}: |
| 220 | + if ( |
| 221 | + config.latex_elements == {} |
| 222 | + ): # pyright: ignore [reportUnnecessaryComparison] type: # ignore[comparison-overlap] |
188 | 223 |
|
189 | 224 | config.latex_elements = ast.literal_eval(config.latex_config) |
190 | 225 |
|
|
0 commit comments