Merge lp:~rvb/maas/add-version-switcher into lp:maas/1.4

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 1722
Proposed branch: lp:~rvb/maas/add-version-switcher
Merge into: lp:maas/1.4
Prerequisite: lp:~rvb/maas/backport-doc-theme
Diff against target: 85 lines (+41/-0)
4 files modified
Makefile (+3/-0)
docs/_templates/maas/layout.html (+1/-0)
docs/_templates/maas/relations.html (+12/-0)
docs/conf.py (+25/-0)
To merge this branch: bzr merge lp:~rvb/maas/add-version-switcher
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Review via email: mp+214418@code.launchpad.net

Commit message

Add the version switcher widget. Add the new `doc-with-versions` make target to generate a version of the documentation that includes the version switcher widget.

Description of the change

This works in conjunction with https://code.launchpad.net/~rvb/maas/multiple-versions-doc-1.6/+merge/214424.

The change to the 1.4 branch should be a one-off. No further modification should be required, even when publishing a new version of the documentation.

If 'add_version_switcher' is set to True, the code in docs/_templates/maas/relations.html dynamically fetches the Javascript file used to generate the version switcher widget from the trunk documentation.

See the result at http://162.213.35.95:8000/docs

To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

 review: approve

Is this any different from the one I just approved? Doesn't look like it.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlNCVXYACgkQWhGlTF8G/HeUyQCeOhCAu8iGHAa8/M/25jIfHoPp
4bMAn3sLNslz7tkdE5ktl0eTZ0Qbg2lB
=2lsm
-----END PGP SIGNATURE-----

review: Approve
Revision history for this message
Raphaël Badin (rvb) wrote :

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> review: approve
>
> Is this any different from the one I just approved? Doesn't look like it.

Yep, it's the same, just not targeting the same branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2013-09-03 15:38:39 +0000
3+++ Makefile 2014-04-07 17:12:31 +0000
4@@ -139,6 +139,9 @@
5 doc: bin/sphinx docs/api.rst
6 bin/sphinx
7
8+doc-with-versions: bin/sphinx
9+ cd docs/_build; make SPHINXOPTS="-A add_version_switcher=true" html
10+
11 man: $(patsubst docs/man/%.rst,man/%,$(wildcard docs/man/*.rst))
12
13 man/%: docs/man/%.rst | bin/sphinx-build
14
15=== modified file 'docs/_templates/maas/layout.html'
16--- docs/_templates/maas/layout.html 2014-04-07 17:12:31 +0000
17+++ docs/_templates/maas/layout.html 2014-04-07 17:12:31 +0000
18@@ -5,6 +5,7 @@
19 <a style="border:0" title="MAAS Documentation Homepage" href="{{ pathto('index.html', 1) }}"><img src="{{ pathto('_static/maas-logo-200.png',1) }}" alt="MAAS logo"/></a>
20 <h2 style="text-align:center;">MAAS</h2>
21 <p style="font-style:italic;font-size:0.9em; text-align:center; margin-bottom:1.5em">Metal As A Service.</p>
22+<span id="version_switcher"></span>
23 <br/>
24 <br/>
25 {% endblock %}
26
27=== modified file 'docs/_templates/maas/relations.html'
28--- docs/_templates/maas/relations.html 2014-04-07 17:12:31 +0000
29+++ docs/_templates/maas/relations.html 2014-04-07 17:12:31 +0000
30@@ -1,3 +1,15 @@
31+<script type="text/javascript">
32+$(document).ready(function () {
33+ if ({{ add_version_switcher }}) {
34+ $.ajaxSetup({cache: true});
35+ $.getScript('{{ versions_json_path }}', function() {
36+ console.log( "Versions script loaded." );
37+ set_up_version_switcher('#version_switcher', '{{ doc_prefix }}');
38+ });
39+}
40+});
41+</script>
42+
43 <h3>Related Topics</h3>
44 <ul>
45 <li><a href="{{ pathto(master_doc) }}">Documentation overview</a><ul>
46
47=== modified file 'docs/conf.py'
48--- docs/conf.py 2014-04-07 17:12:31 +0000
49+++ docs/conf.py 2014-04-07 17:12:31 +0000
50@@ -23,6 +23,23 @@
51
52 # -- General configuration -----------------------------------------------------
53
54+# Add a widget to switch between different versions of the documentation to
55+# each generated page.
56+add_version_switcher = False
57+
58+# In order for the version widget to be able to redirect correctly to the
59+# other versions of the documentation, each version of the documentation
60+# has to be accessible at the following addresses:
61+# /<doc_prefix>/ -> documentation for trunk.
62+# /<doc_prefix>1.4/ -> documentation for 1.4.
63+# etc.
64+doc_prefix = 'docs'
65+
66+# Path of the JSON document, relative to homepage of the documentation for trunk
67+# (i.e. '/<doc_prefix>/'), with the list of the versions to include in the
68+# version switcher widget.
69+versions_path = '_static/versions.js'
70+
71 # If your documentation needs a minimal Sphinx version, state it here.
72 #needs_sphinx = '1.0'
73
74@@ -240,3 +257,11 @@
75
76 # Example configuration for intersphinx: refer to the Python standard library.
77 intersphinx_mapping = {'http://docs.python.org/': None}
78+
79+# Populate html_context with the variables used in the templates.
80+html_context = {
81+ 'add_version_switcher': 'true' if add_version_switcher else 'false',
82+ 'versions_json_path': '/'.join(['', doc_prefix, versions_path]),
83+ 'doc_prefix': doc_prefix,
84+}
85+

Subscribers

People subscribed via source and target branches

to all changes: