Skip to content

Commit 27b51d8

Browse files
committed
Enable sphinx_multiversion
1 parent 7dd7683 commit 27b51d8

File tree

4 files changed

+69
-4
lines changed

4 files changed

+69
-4
lines changed

azure-pipelines.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,17 @@ jobs:
5454
parameters:
5555
versions: ['3.6']
5656
images: ['ubuntu-18.04']
57-
package: '-e .[all]'
57+
# don't install package, just build dependencies
58+
package: 'oldest-supported-numpy scipy cython'
5859
job:
5960
job: 'Docs'
6061
displayName: 'Build documentation'
6162
dependsOn: 'EvalChanges'
6263
condition: eq(dependencies.EvalChanges.outputs['output.buildDocs'], 'True')
6364
steps:
65+
- script: 'pip install "scipy>1.4.0" "scikit-learn>0.22.0" sparse "joblib>=0.13.0" "statsmodels>=0.10" pandas "shap>=0.38.1,<0.40.0" "dowhy<0.8" lightgbm'
66+
displayName: 'Install dependencies'
67+
6468
- script: 'sudo apt-get -yq install graphviz'
6569
displayName: 'Install graphviz'
6670

@@ -70,10 +74,10 @@ jobs:
7074
- script: 'pip install git+https://github.com/slundberg/shap.git@d1d2700acc0259f211934373826d5ff71ad514de'
7175
displayName: 'Install specific version of shap'
7276

73-
- script: 'pip install sphinx sphinx_rtd_theme'
77+
- script: 'pip install sphinx sphinx_rtd_theme sphinx_multiversion'
7478
displayName: 'Install sphinx'
7579

76-
- script: 'python setup.py build_sphinx -W'
80+
- script: 'sphinx-multiversion doc build/sphinx -W'
7781
displayName: 'Build documentation'
7882

7983
- publish: 'build/sphinx/html'

doc/_templates/layout.html

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{# This content is taken from https://holzhaus.github.io/sphinx-multiversion/master/templates.html#version-banners
2+
but applied to the layout.html document since the Read the Docs template does not have a page.html file. #}
3+
{% extends "!layout.html" %}
4+
{% block document %}
5+
{% if current_version and latest_version and current_version != latest_version %}
6+
<p>
7+
<strong>
8+
{% if current_version.is_released %}
9+
You're reading an old version of this documentation.
10+
If you want up-to-date information, please have a look at <a href="{{ vpathto(latest_version.name) }}">{{latest_version.name}}</a>.
11+
{% else %}
12+
You're reading the documentation for a development version.
13+
For the latest released version, please have a look at <a href="{{ vpathto(latest_version.name) }}">{{latest_version.name}}</a>.
14+
{% endif %}
15+
</strong>
16+
</p>
17+
{% endif %}
18+
{{ super() }}
19+
{% endblock %}

doc/_templates/versions.html

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{# This content is a slightly tweaked version of the suggestions in https://holzhaus.github.io/sphinx-multiversion/master/templates.html#readthedocs-theme #}
2+
{%- if current_version %}
3+
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
4+
<span class="rst-current-version" data-toggle="rst-current-version">
5+
<span class="fa fa-book"> Other Versions</span>
6+
{{ current_version.name }}
7+
<span class="fa fa-caret-down"></span>
8+
</span>
9+
<div class="rst-other-versions">
10+
{%- if versions.tags %}
11+
<dl>
12+
<dt>Tags</dt>
13+
{%- for item in versions.tags %}
14+
<dd><a href="{{ item.url }}">{{ item.name }}</a></dd>
15+
{%- endfor %}
16+
</dl>
17+
{%- endif %}
18+
{%- if versions.branches %}
19+
<dl>
20+
<dt>Branches</dt>
21+
{%- for item in versions.branches %}
22+
<dd><a href="{{ item.url }}">{{ item.name }}</a></dd>
23+
{%- endfor %}
24+
</dl>
25+
{%- endif %}
26+
</div>
27+
</div>
28+
{%- endif %}

doc/conf.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
'sphinx.ext.mathjax',
4747
'sphinx.ext.viewcode',
4848
'sphinx.ext.inheritance_diagram',
49+
"sphinx_multiversion"
4950
]
5051
inheritance_graph_attrs = dict(rankdir="TB", size='"7.0, 10.0"',
5152
fontsize=12, ratio='auto',
@@ -99,6 +100,11 @@
99100
# The name of the Pygments (syntax highlighting) style to use.
100101
pygments_style = None
101102

103+
# sphinx_multiversion configuration
104+
smv_tag_whitelist = r'^v0\.(12\.0|13\.0)$'
105+
smv_branch_whitelist = '^main$'
106+
smv_latest_version = 'v0.13.0'
107+
smv_released_pattern = '^refs/tags/.+$'
102108

103109
# -- Options for HTML output -------------------------------------------------
104110

@@ -215,7 +221,7 @@
215221

216222
# Example configuration for intersphinx: refer to the Python standard library.
217223
intersphinx_mapping = {'python': ('https://docs.python.org/3', None),
218-
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
224+
'numpy': ('https://numpy.org/doc/stable/', None),
219225
'sklearn': ('https://scikit-learn.org/stable/', None),
220226
'matplotlib': ('https://matplotlib.org/', None),
221227
'shap': ('https://shap.readthedocs.io/en/stable/', None),
@@ -244,5 +250,13 @@ def exclude_entity(app, what, name, obj, skip, opts):
244250

245251

246252
def setup(app):
253+
# HACK: ensure that we build extensions in place first
254+
# Will not be necessary if one of the PRs addressing https://github.com/Holzhaus/sphinx-multiversion/issues/45
255+
# is merged into sphinx-multiversion
256+
import subprocess
257+
print("Building extensions")
258+
subprocess.call(["python", "setup.py", "build_ext", "-i"])
259+
260+
# Hook up our method for skipping entities
247261
app.connect('autodoc-skip-member', exclude_entity)
248262
()

0 commit comments

Comments
 (0)