Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 59d0566

Browse files
committedDec 11, 2020
Use sphinx_multiversion to make multiversioned docs
sphinx-multiversion can build a copy of the documentation for each tag and place in a subfolder. The existing spinx setup can build the top level latest version. versioning.html gives links to version in the sidebar. layout.html overrides the main template to use correct versions in the title and top navigation bar. Note this requires a patch to sphinx_multiversion to allow calling a prebuild command. This is used to call the docs_api for each checkout. sphinx-contrib/multiversion#62
1 parent 008ca57 commit 59d0566

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed
 

‎docs/_static/extra.css

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
div.versions {margin-top: 10px}

‎docs/_templates/layout.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{%- extends "!layout.html" %}
2+
{%- block htmltitle %}
3+
{% if versions %}
4+
<title>{{ title|striptags|e }} - {{ project }} {{ current_version.name }} Documentation</title>
5+
{% else %}
6+
<title>{{ title|striptags|e }}{{ titlesuffix }}</title>
7+
{% endif %}
8+
{%- endblock %}
9+
10+
{%- block rootrellink %}
11+
{% if versions %}
12+
<li class="nav-item nav-item-0"><a href="{{ pathto(master_doc)|e }}">{{ project }} {{ current_version.name }} Documentation</a>{{ reldelim1 }}</li>
13+
{% else %}
14+
<li class="nav-item nav-item-0"><a href="{{ pathto(master_doc)|e }}">{{ shorttitle|e }}</a>{{ reldelim1 }}</li>
15+
{% endif %}
16+
{%- endblock %}
17+

‎docs/_templates/versioning.html

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{% if versions %}
2+
<div class="versions">
3+
<h3>{{ _('Versions') }}</h3>
4+
<ul>
5+
<li><a href="../{{ pathto("",1)}}index.html">Latest</a></li>
6+
{%- for item in versions %}
7+
<li><a href="{{ item.url }}">{{ item.name }}</a></li>
8+
{%- endfor %}
9+
</ul>
10+
</div>
11+
{% else %}
12+
<div class="versions">
13+
<h3>{{ _('Versions') }}</h3>
14+
<ul>
15+
<li><a href="{{ pathto("",1)}}index.html">Latest</a></li>
16+
{%- for item in ['0.9.0', '1.0.0', '1.1.0'] %}
17+
<li><a href="{{ pathto("",1)}}{{ item }}/index.html">{{ item }}</a></li>
18+
{%- endfor %}
19+
</ul>
20+
</div>
21+
{% endif %}

‎docs/conf.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# ones.
3535
extensions = [
3636
'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage',
37-
'sphinx.ext.viewcode', 'sphinx.ext.githubpages', 'sphinx.ext.imgmath'
37+
'sphinx.ext.viewcode', 'sphinx.ext.githubpages', 'sphinx.ext.imgmath', 'sphinx_multiversion',
3838
]
3939

4040
# Add any paths that contain templates here, relative to this directory.
@@ -92,6 +92,7 @@
9292
'localtoc.html',
9393
'relations.html',
9494
'searchbox.html',
95+
'versioning.html'
9596
]
9697
}
9798

@@ -106,6 +107,7 @@
106107
html_static_path = ['_static']
107108

108109
# -- Options for HTMLHelp output ------------------------------------------
110+
html_css_files = ['extra.css']
109111

110112
# Output file base name for HTML help builder.
111113
htmlhelp_basename = 'MantidImagingdoc'
@@ -158,3 +160,9 @@
158160

159161
# Stop sphinx from being a smartypants and merging the -- into a single unicode dash
160162
html_use_smartypants = False
163+
164+
# sphinx-multiversion
165+
smv_tag_whitelist = r'^\d+\.\d+\.\d+$' # tags that look like versions
166+
smv_branch_whitelist = None # No branches
167+
smv_released_pattern = r''
168+
smv_prebuild_command = "python setup.py docs_api"

0 commit comments

Comments
 (0)
Please sign in to comment.