-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconf.py
More file actions
229 lines (204 loc) · 7.28 KB
/
Copy pathconf.py
File metadata and controls
229 lines (204 loc) · 7.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# Configuration file for the Sphinx documentation builder.
from __future__ import annotations
import os
from datetime import datetime
from functools import partial
from typing import TYPE_CHECKING, Any
from type_lens.__metadata__ import __project__, __version__
if TYPE_CHECKING:
from sphinx.addnodes import document
from sphinx.application import Sphinx
__all__ = (
"delayed_setup",
"setup",
"update_html_context",
)
# -- Environmental Data ------------------------------------------------------
suppress_warnings = ["config.cache"]
# -- Project information -----------------------------------------------------
current_year = datetime.now().year
project = __project__
copyright = f"{current_year}, Litestar Organization"
release = os.getenv("_TYPE_LENS_DOCS_BUILD_VERSION", __version__.rsplit(".")[0])
# -- General configuration ---------------------------------------------------
extensions = [
"autoapi.extension",
"sphinx.ext.napoleon",
"sphinx.ext.autosectionlabel",
"sphinx.ext.githubpages",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
"sphinx_copybutton",
"sphinx.ext.todo",
"sphinx_toolbox.collapse",
"sphinx_design",
"sphinx_togglebutton",
"sphinx_paramlinks",
]
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
}
PY_CLASS = "py:class"
PY_RE = r"py:.*"
PY_METH = "py:meth"
PY_ATTR = "py:attr"
PY_OBJ = "py:obj"
nitpicky = True
nitpick_ignore = [
# autoapi generates :py:class: refs for these, but they are not class objects.
# TypeVar and Ellipsis (...) are data objects; TypeAlias and re-exported types
# are documented at the root type_lens namespace, not their submodule paths.
# These cannot be resolved without patching autoapi templates.
("py:class", "T"),
("py:class", "Ellipsis"),
("py:class", "type_lens.types.empty.EmptyType"),
("py:class", "type_lens.type_view.TypeView"),
]
nitpick_ignore_regex = []
napoleon_google_docstring = True
napoleon_include_special_with_doc = True
napoleon_use_admonition_for_examples = True
napoleon_use_admonition_for_notes = True
napoleon_use_admonition_for_references = False
napoleon_attr_annotations = True
autoapi_dirs = ["../type_lens"]
autoapi_root = "reference"
autoapi_options = [
"members",
"undoc-members",
"show-inheritance",
"show-module-summary",
"special-members",
"imported-members",
]
autoapi_own_page_level = "class"
autoapi_python_class_content = "both"
autoapi_generate_api_docs = False
autoapi_add_toctree_entry = False
autosectionlabel_prefix_document = True
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
auto_pytabs_min_version = (3, 9)
auto_pytabs_max_version = (3, 12)
auto_pytabs_compat_mode = True
# -- Style configuration -----------------------------------------------------
html_theme = "litestar_sphinx_theme"
html_title = "Litestar Framework"
pygments_style = "lightbulb"
todo_include_todos = True
html_static_path = ["_static"]
templates_path = ["_templates"]
html_js_files = ["versioning.js"]
html_css_files = ["style.css"]
html_show_sourcelink = True
html_copy_source = True
html_context = {
"source_type": "github",
"source_user": "litestar-org",
"source_repo": "type-lens",
"current_version": "latest",
"versions": [
("latest", "/latest"),
("development", "/main"),
],
"version": release,
}
html_theme_options = {
"logo_target": "/",
"github_repo_name": "type-lens",
"navigation_with_keys": True,
"nav_links": [ # TODO(provinzkraut): I need a guide on extra_navbar_items and its magic :P
{"title": "Home", "url": "index"},
{
"title": "Community",
"children": [
{
"title": "Contributing",
"summary": "Learn how to contribute to the Type Lens project",
"url": "contribution-guide",
"icon": "contributing",
},
{
"title": "Code of Conduct",
"summary": "Review the etiquette for interacting with the Litestar community",
"url": "https://github.com/litestar-org/.github?tab=coc-ov-file",
"icon": "coc",
},
{
"title": "Security",
"summary": "Overview of Litestar's security protocols",
"url": "https://github.com/litestar-org/.github?tab=coc-ov-file#security-ov-file",
"icon": "coc",
},
],
},
{
"title": "About",
"children": [
{
"title": "Litestar Organization",
"summary": "Details about the Litestar organization",
"url": "https://litestar.dev/about/organization",
"icon": "org",
},
{
"title": "Releases",
"summary": "Explore the release process, versioning, and deprecation policy for Litestar",
"url": "releases",
"icon": "releases",
},
],
},
{
"title": "Release notes",
"children": [
{
"title": "1.x Changelog",
"url": "changelog",
"summary": "All changes in the 1.x series",
},
],
},
{
"title": "Help",
"children": [
{
"title": "Discord Help Forum",
"summary": "Dedicated Discord help forum",
"url": "https://discord.gg/litestar",
"icon": "coc",
},
{
"title": "GitHub Discussions",
"summary": "GitHub Discussions",
"url": "https://github.com/litestar-org/type-lens/discussions",
"icon": "coc",
},
{
"title": "Stack Overflow",
"summary": "We monitor the <code><b>litestar</b></code> tag on Stack Overflow",
"url": "https://stackoverflow.com/questions/tagged/litestar",
"icon": "coc",
},
],
},
{"title": "Sponsor", "url": "https://github.com/sponsors/Litestar-Org", "icon": "heart"},
],
}
def update_html_context(
app: Sphinx, pagename: str, templatename: str, context: dict[str, Any], doctree: document
) -> None:
context["generate_toctree_html"] = partial(context["generate_toctree_html"], startdepth=0)
def delayed_setup(app: Sphinx) -> None:
"""
When running linkcheck Shibuya causes a build failure, and checking
the builder in the initial `setup` function call is not possible, so the check
and extension setup has to be delayed until the builder is initialized.
"""
if app.builder.name == "linkcheck":
return
app.setup_extension("shibuya")
# app.connect("html-page-context", update_html_context) # TODO(provinkraut): fix
def setup(app: Sphinx) -> dict[str, bool]:
app.connect("builder-inited", delayed_setup, priority=0)
app.setup_extension("litestar_sphinx_theme")
return {"parallel_read_safe": True, "parallel_write_safe": True}