Repository navigation
Expand file tree
/
Copy pathconf.py
More file actions
177 lines (163 loc) · 5.95 KB
/
Copy pathconf.py
File metadata and controls
177 lines (163 loc) · 5.95 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
"""Configuration file for the Sphinx documentation builder."""
import dataclasses as dc
import os
from sphinx_design.config import SdConfig
project = "Sphinx Design"
copyright = "2021, Executable Book Project"
author = "Executable Book Project"
extensions = [
"myst_parser",
"sphinx_design",
"sphinx.ext.extlinks",
# SVG images must be converted for the LaTeX/PDF build
"sphinx.ext.imgconverter",
]
# suppresses the warning for builders with no fontawesome support (e.g. man)
suppress_warnings = ["design.fa-build"]
sd_fontawesome_latex = "fontawesome5"
# pdflatex errors on emoji (e.g. in the changelog); xelatex only warns for
# missing glyphs. makeindex replaces xindy, which CI TeX images lack.
latex_engine = "xelatex"
latex_use_xindy = False
latex_elements = {
# Sphinx >=9 auto-selects the newest FontAwesome LaTeX package installed
# for its admonition icons (fontawesome7 on full TeX Live 2025+), which
# hard-clashes with the fontawesome5 package sd_fontawesome_latex loads.
# Pin Sphinx's icons to the same package so there is a single FA load.
"sphinxsetup": "iconpackage=fontawesome5",
}
sd_custom_directives = {
"dropdown-syntax": {
"inherit": "dropdown",
"argument": "Syntax",
"options": {
"color": "primary",
"icon": "code",
},
}
}
extlinks = {
"pr": ("https://github.com/executablebooks/sphinx-design/pull/%s", "PR #%s"),
"issue": (
"https://github.com/executablebooks/sphinx-design/issues/%s",
"#%s",
),
"user": ("https://github.com/%s", "@%s"),
}
html_theme = os.environ.get("SPHINX_THEME", "alabaster")
html_title = f"Sphinx Design ({html_theme.replace('_', '-')})"
html_static_path = ["_static"]
html_logo = "_static/logo_wide.svg"
html_favicon = "_static/logo_square.svg"
if html_theme not in ("sphinx_book_theme", "pydata_sphinx_theme"):
# let sphinx-design load FontAwesome from the CDN, rather than
# hand-editing html_css_files (the sphinx_book/pydata themes bundle it)
sd_fontawesome_source = "cdn"
if html_theme == "alabaster":
html_logo = ""
html_theme_options = {
"logo": "logo_wide.svg",
"logo_name": False,
"description": "(alabaster theme)",
"github_button": False,
"github_type": "star",
"github_banner": False,
"github_user": "executablebooks",
"github_repo": "sphinx-design",
}
if html_theme == "sphinx_book_theme":
html_theme_options = {
"repository_url": "https://github.com/executablebooks/sphinx-design",
"use_repository_button": True,
"use_edit_page_button": True,
"use_issues_button": True,
"repository_branch": "main",
"path_to_docs": "docs",
"home_page_in_toc": False,
}
if html_theme == "furo":
# FontAwesome is loaded via sd_fontawesome_source="cdn" (set above)
html_css_files = ["furo.css"]
html_theme_options = {
"sidebar_hide_name": True,
}
if html_theme == "sphinx_rtd_theme":
html_theme_options = {
"logo_only": True,
}
if html_theme == "sphinx_immaterial":
extensions.append("sphinx_immaterial")
html_css_files = ["sphinx_immaterial.css"]
sd_fontawesome_source = "none" # immaterial provides its own icon fonts
html_theme_options = {
"icon": {
"repo": "fontawesome/brands/github",
},
"site_url": "https://sphinx-design.readthedocs.io/",
"repo_url": "https://github.com/executablebooks/sphinx-design",
"repo_name": "Sphinx-Design",
"palette": [
{
"media": "(prefers-color-scheme: light)",
"scheme": "default",
"primary": "blue",
"accent": "light-blue",
"toggle": {
"icon": "material/weather-night",
"name": "Switch to dark mode",
},
},
{
"media": "(prefers-color-scheme: dark)",
"scheme": "slate",
"primary": "blue",
"accent": "yellow",
"toggle": {
"icon": "material/weather-sunny",
"name": "Switch to light mode",
},
},
],
}
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
myst_enable_extensions = [
"attrs_inline",
"colon_fence",
"deflist",
"substitution",
"html_image",
]
def _sd_config_options_table() -> str:
"""Generate a Markdown table of all sphinx-design configuration options,
from the ``SdConfig`` dataclass fields.
"""
rows = [
"| Name | Type | Default | Description |",
"| ---- | ---- | ------- | ----------- |",
]
for field in dc.fields(SdConfig):
default = (
field.default_factory()
if field.default_factory is not dc.MISSING
else field.default
)
type_str = field.metadata.get("doc_type", field.type)
rows.append(
f"| `sd_{field.name}` | `{type_str}` | `{default!r}` "
f"| {field.metadata.get('help', '')} |"
)
return "\n".join(rows)
myst_substitutions = {
"sd_config_options": _sd_config_options_table(),
"loremipsum": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
"Sed iaculis arcu vitae odio gravida congue. Donec porttitor ac risus et condimentum. "
"Phasellus bibendum ac risus a sollicitudin. "
"Proin pulvinar risus ac mauris aliquet fermentum et varius nisi. "
"Etiam sit amet metus ac ipsum placerat congue semper non diam. "
"Nunc luctus tincidunt ipsum id eleifend. Ut sed faucibus ipsum. "
"Aliquam maximus dictum posuere. Nunc vitae libero nec enim tempus euismod. "
"Aliquam sed lectus ac nisl sollicitudin ultricies id at neque. "
"Aliquam fringilla odio vitae lorem ornare, sit amet scelerisque orci fringilla. "
"Nam sed arcu dignissim, ultrices quam sit amet, commodo ipsum. "
"Etiam quis nunc at ligula tincidunt eleifend.",
}