Skip to content

Commit 3ad7885

Browse files
committed
support sphinx-multiversion
1 parent 9cf1035 commit 3ad7885

3 files changed

Lines changed: 52 additions & 15 deletions

File tree

rebuild.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cat << EOF >/usr/local/lib/python3.10/site-packages/sphinx_rtd_theme/comments.html
2+
<comments>
3+
<script src="https://utteranc.es/client.js"
4+
repo="iswbm/PythonCodingTime"
5+
issue-term="pathname"
6+
theme="github-light"
7+
crossorigin="anonymous"
8+
async>
9+
</script>
10+
</comments>
11+
EOF
12+
13+
rm -rf build/ && sphinx-multiversion source build/html && cp -rf build/html/master/* build/html/

source/_templates/versions.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{%- if current_version %}
2+
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
3+
<span class="rst-current-version" data-toggle="rst-current-version">
4+
<span class="fa fa-book"> Other Versions</span>
5+
v: {{ current_version.name }}
6+
<span class="fa fa-caret-down"></span>
7+
</span>
8+
<div class="rst-other-versions">
9+
{%- if versions.tags %}
10+
<dl>
11+
<dt>Tags</dt>
12+
{%- for item in versions.tags %}
13+
<dd><a href="{{ item.url }}">{{ item.name }}</a></dd>
14+
{%- endfor %}
15+
</dl>
16+
{%- endif %}
17+
{%- if versions.branches %}
18+
<dl>
19+
<dt>Branches</dt>
20+
{%- for item in versions.branches %}
21+
<dd><a href="{{ item.url }}">{{ item.name }}</a></dd>
22+
{%- endfor %}
23+
</dl>
24+
{%- endif %}
25+
</div>
26+
</div>
27+
{%- endif %}

source/conf.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# Add any Sphinx extension module names here, as strings. They can be
2929
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3030
# ones.
31-
extensions = ['chinese_search','sphinx.ext.mathjax', 'sphinx_sitemap']
31+
extensions = ['chinese_search','sphinx.ext.mathjax', 'sphinx_sitemap', 'sphinx_multiversion']
3232

3333
# Add any paths that contain templates here, relative to this directory.
3434
templates_path = ['_templates']
@@ -127,28 +127,25 @@
127127
sys.path.append(os.path.abspath(_exts))
128128

129129
html_js_files = [
130-
'js/readmore.js',
130+
'js/readmore.js',
131131
'js/baidutongji.js',
132132
]
133133

134-
# General configuration.
135-
with open("/home/docs/checkouts/readthedocs.org/user_builds/pythoncodingtime/envs/latest/lib/python3.7/site-packages/sphinxcontrib/disqus.py", "r") as file:
136-
content = file.read()
137-
content=content.replace("sphinx.application", "sphinx.errors")
138-
139-
with open("/home/docs/checkouts/readthedocs.org/user_builds/pythoncodingtime/envs/latest/lib/python3.7/site-packages/sphinxcontrib/disqus.py", "w") as file:
140-
file.write(content)
141134

142135
author = '王炳明'
143-
copyright = '2020, Python编程时光'
136+
copyright = '2020-2024, Python编程时光'
144137
exclude_patterns = ['_build']
145-
extensions = ['sphinxcontrib.disqus'] # Add to this list.
146138
master_doc = 'index'
147139
project = 'Python编程时光'
148-
release = '1.0'
149-
version = '1.0'
150140

151141
# Options for extensions.
152-
disqus_shortname = 'iswbm' # Add this line to conf.py.
153-
html_baseurl = 'http://pythontime.iswbm.com'
142+
html_baseurl = 'https://magic.iswbm.com'
154143
html_extra_path = ["robots.txt"]
144+
145+
html_sidebars = {
146+
'**': [
147+
'versioning.html',
148+
],
149+
}
150+
smv_latest_version = 'master'
151+
sitemap_url_scheme = "{link}"

0 commit comments

Comments
 (0)