-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconf.py
363 lines (295 loc) · 12.3 KB
/
conf.py
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
import os
import sys
from datetime import datetime
import yaml
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('.'))
# -- Split configurations ----------------------------------------------------
from _conf.schemas import _schemas
from _conf.deploy import D
# For `.. only::` directive.
if D.is_private():
tags.add('private') # type: ignore
with open('./_conf/redirect.yml') as data:
_redirects = yaml.safe_load(data)
# -- Project information -----------------------------------------------------
project = '银色子弹'
author = 'Shengyu Zhang'
author_id = 'SilverRainZ'
author_nick = 'LA'
copyright = '2020-%s, ' % datetime.now().year + author
# -- Non-standard project information ----------------------------------------
logo = '_static/logo.png'
description = 'Yes silver bullet here.'
datefmt = '%Y-%m-%d'
# -- Enviroment information -----------------------------------------------------
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.graphviz',
'sphinxcontrib.email',
'sphinx.ext.githubpages',
'sphinxnotes.strike',
'sphinxcontrib.plantuml',
'sphinxcontrib.asciinema',
'sphinx_copybutton',
'sphinxcontrib.youtube',
'sphinxnotes.extweb',
'sphinx_design',
'sphinx_simplepdf', # .. pdf-include::
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'zh_CN'
language_full = '简体中文'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'README.rst']
# A string of reStructuredText that will be included at the end of every
# source file that is read.
rst_epilog = """
"""
# Provided by sphinxnotes.any
primary_domain = 'any'
# Use :code: as default role, so we can write `content` instead of ``content``.
default_role = 'code'
# Keep warnings as “system message” paragraphs in the built documents.
# Regardless of this setting, warnings are always written to the standard error
# stream when sphinx-build is run.
# See also suppress_
if D.is_private():
keep_warnings = True
# A list of warning codes to suppress arbitrary warning messages.
if D is D.Local:
suppress_warnings = ['ref.' + x.objtype for x in _schemas]
# Auto numbered figures, tables and code-blocks if they have a caption.
# numfig = True
# Show codeauthor and sectionauthor directives produce any output in the built
# files.
show_authors = True
# A URL to cross-reference manpage directives.
manpages_url = 'https://man7.org/linux/man-pages/man{section}/{page}.{section}.html'
# -- Options for HTML output -------------------------------------------------
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_css_files = ['custom.css']
# A list of JavaScript filename.
# The entry must be a filename string or a tuple containing the filename string
# and the attributes dictionary. The filename must be relative to the
# html_static_path, or a full URI with scheme like https://example.org/script.js.
# The attributes is used for attributes of <script> tag. It defaults to an empty list.
html_js_files = []
html_baseurl = D.url()
html_title = project
html_logo = logo
html_favicon = '_static/favicon.png'
# HTML theme configuration
html_theme = 'sphinx_book_theme'
html_theme_options = {
'repository_url': f'https://github.com/{author_id}/bullet',
'use_repository_button': True,
'use_download_button': False,
'use_edit_page_button': False,
'use_source_button': True,
'use_issues_button': True,
'show_toc_level': 2,
'navigation_with_keys': False, # https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/configuring.html#changing-pages-with-keyboard-presses
}
# Setup announcement as your need
# html_theme_options['announcement'] = '</p>blahblah… </p>
if D.is_mirror():
src = D.Github
msg = f'<p> 这是部署于 {D} 的镜像,访问源站点:<a class="source-page" href="{src.url()}">{src}</a></p>'
if html_theme_options.get('announcement'):
html_theme_options['announcement'] += msg
else:
html_theme_options['announcement'] = msg
html_js_files.append('mirror-redirect.js')
html_css_files.append('sphinx-book-theme-custom.css')
nosidebar_page = ['nosidebar']
blog_post_page = [ # Provided by sphinx_book_theme
'navbar-logo',
# Provided by ABlog
'ablog/postcard', 'ablog/recentposts', 'ablog/tagcloud',
'ablog/categories', 'ablog/archives']
# TODO...
html_sidebars = {
# We have best toc on page content
'about/resume': nosidebar_page,
'about/resume-en': nosidebar_page,
'blog': blog_post_page, # ABlog's "All Posts" page
'blog/**': blog_post_page, # Inlucde posts and autogenerated pages
}
# If true, the reST sources are included in the HTML build as _sources/name.
# I don't want to public my sources, so set it to false.
html_copy_source = True
html_search_language = language
html_last_updated_fmt = datefmt
# A list of paths that contain extra files not directly related to the
# documentation.
html_extra_path = ['robots.txt', 'LICENSE']
# -- Per-extension configuration ---------------------------------------------------
extensions.append('sphinxnotes.mock')
mock_directives = []
mock_directives.append('contents') # Theme has built-in local-toc, see html_theme
extensions.append('sphinx.ext.todo')
todo_include_todos = True
extensions.append('sphinx.ext.extlinks')
extlinks = {
'zhwiki': ('https://zh.wikipedia.org/wiki/%s', '📖 %s'),
'enwiki': ('https://wikipedia.org/wiki/%s', '📖 %s'),
'search': ('https://duckduckgo.com/?q=%s', '🔍 %s'),
'twitter': ('https://twitter.com/%s', '👤 %s'),
'ghuser': ('https://github.com/%s', '👤 %s'),
'ghorg': ('https://github.com/%s', '👥 %s'),
'ghrepo': ('https://github.com/%s', '⛺ %s'),
'weibo': ('https://weibo.com/%s', '👤 %s'),
'aur': ('https://aur.archlinux.org/packages/%s', '📦 %s'),
'archpkg': ('https://archlinux.org/packages/%s', '📦 %s'),
'archwiki': ('https://wiki.archlinux.org/index.php/%s', '📖 %s'),
'zhihua': ('https://www.zhihu.com/answer/%s', '🙋 %s'),
'zhihuq': ('https://www.zhihu.com/question/%s', '🤔 %s'),
'zhihup': ('https://www.zhihu.com/people/%s', '👤 %s'),
'pypi': ('https://pypi.org/project/%s', '📦 %s'),
'lilydoc': ('https://lilypond.org/doc/v2.20/Documentation/%s', None),
'so.q': ('https://stackoverflow.com/a/%s', '🤔 %s'),
'so.a': ('https://stackoverflow.com/a/%s', '🙋 %s'),
'bili': ('https://www.bilibili.com/video/%s', '🎥 %s'),
'musicca-drum': ('https://www.musicca.com/zh/drum-machine?data=%s', '🥁 %s'),
'dudir': ('https://docutils.sourceforge.io/docs/ref/rst/directives.html#%s', '%s'),
'durole': ('https://docutils.sourceforge.io/docs/ref/rst/roles.html#%s', '%s'),
}
extensions.append('sphinxnotes.any')
any_schemas = _schemas
extensions.append('ablog')
blog_path = 'blog'
blog_title = project
blog_baseurl = D.url()
blog_authors = {
author_nick: (author, blog_baseurl),
}
blog_default_author = author_nick
blog_languages = {
language: (language_full, None),
# FIXME: https://github.com/sunpy/ablog/issues/136
# 'en': ('English', None),
}
blog_default_language = language
post_date_format = datefmt
post_auto_image = 1
blog_feed_fulltext = True
blog_feed_subtitle = description
fontawesome_included = True
html_css_files.append('ablog-custom.css')
if D.is_public():
extensions.append('sphinxcontrib.gtagjs')
if D is D.Github:
gtagjs_ids = ['G-FYHS50G6DL']
elif D is D.Gitee:
gtagjs_ids = ['G-5MZDR9VPYN']
if D is D.Local:
extensions.append('sphinxnotes.snippet')
snippet_config = {}
snippet_patterns = {
'd': ['.*'],
's': ['notes/.*', 'jour/.*', 'collections/.*', 'about/.*', 'p/.*'],
'c': ['p/.*', 'notes/man/.*'],
}
if D.is_public():
extensions.append('sphinxnotes.isso')
isso_url = 'https://comments.silverrainz.me:30500'
isso_include_patterns = ['**',]
isso_exclude_patterns = ['index', 'ronin/**']
if D.is_public():
extensions.append('sphinx_sitemap')
sitemap_filename = "sitemap.xml"
sitemap_url_scheme = "{link}"
# NOTE: required by ablog
extensions.append('sphinx.ext.intersphinx')
# Although fetching intersphinx info is slow, but we have fasthtml now.
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'sphinx': ('https://www.sphinx-doc.org/en/master', None),
'srain': ('https://srain.silverrainz.me/', None),
}
if D.is_public():
extensions.append('sphinx_reredirects')
# https://documatt.gitlab.io/sphinx-reredirects/usage.html
with open('./_conf/redirect.yml') as data:
redirects = _redirects
# extensions.append('sphinxcontrib.images')
# images_config = {
# 'override_image_directive': True,
# 'cache_path': '_cache',
# 'download': True,
# }
extensions.append('sphinxnotes.lilypond')
lilypond_audio_volume = 300
lilypond_audio_format = 'mp3'
if D is not D.Local:
extensions.append('sphinxnotes.recentupdate')
recentupdate_date_format = datefmt
recentupdate_exclude_path = ['_templates']
recentupdate_exclude_commit = ['skip-recentupdate', 'conf']
else:
mock_directives.append('recentupdate')
if D.is_public():
extensions.append('sphinxext.opengraph')
ogp_site_url = D.url()
ogp_site_name = project
ogp_image = D.url() + logo
if D is not D.Local:
# Doesn't work locally
extensions.append('notfound.extension')
notfound_urls_prefix = ''
extensions.append('sphinxnotes.comboroles')
comboroles_roles = {
'parsed_literal': (['literal'], True),
'sup_abbr': ['superscript', 'abbr',],
# for ./blog/sphinxnotes-comboroles.rst
'strong_literal': ['strong', 'literal'],
'literal_enwiki': ['literal', 'enwiki'],
'literal_strike': ['literal', 'strike'],
}
extensions.append('sphinxcontrib.globalsubs')
global_substitutions = {
'?': ':sup_abbr:`存疑 (笔者对此断言存有疑惑,请谨慎参考)`',
'i': ':sup_abbr:`个人观点 (这是笔者的个人观点,并无权威出处,请谨慎参考)`',
'todo': ':sup_abbr:`待补充 (但什么时候呢?)`',
'noref': ':sup_abbr:`来源请求 (此断言也许有出处可考,但暂时无法找到)`', # citation needed
# Marks for TODO list.
# Role octicon: https://sphinx-design.readthedocs.io/en/latest/badges_buttons.html
'o': ':octicon:`issue-closed;1em;sd-text-success`', # done
'.': ':octicon:`issue-opened;1em;sd-text-warning`', # wip
'_': ':octicon:`issue-draft`', # todo
'x': ':octicon:`issue-closed;1em;sd-text-danger`', # fail/wontdo/cancel
'p0': ':bdg-danger:`P0`', # priv high
'p1': ':bdg-warning:`P1`', # priv medium
'p2': ':bdg-info:`P2`', # priv low
# Abbrs.
'rst': 'reStructuredText',
}
if D is not D.Local:
# Speed up local build (prevent read git timestamp).
extensions.append('sphinx_last_updated_by_git')
if D is D.Local:
# Speed up local incremental HTML build (may cause document inconsistencies).
extensions.append('sphinxnotes.fasthtml')