Merge lp:~rvb/maas/version-switcher-1.3 into lp:maas/1.3

Proposed by Raphaël Badin
Status: Merged
Merged at revision: 1475
Proposed branch: lp:~rvb/maas/version-switcher-1.3
Merge into: lp:maas/1.3
Prerequisite: lp:~rvb/maas/docs-1.3
Diff against target: 120 lines (+58/-3)
4 files modified
Makefile (+3/-0)
docs/_templates/maas/layout.html (+7/-1)
docs/_templates/maas/relations.html (+12/-0)
docs/conf.py (+36/-2)
To merge this branch: bzr merge lp:~rvb/maas/version-switcher-1.3
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+215605@code.launchpad.net

Commit message

Backport 2258: Add the bzr last revision, last revision date, and build date to the documentation pages.
Backport 2238: Add version switcher.

This only affects the documentation (i.e. not part of what gets packaged).

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) wrote :

Simple backport, self-approving.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2012-11-22 23:39:27 +0000
3+++ Makefile 2014-04-14 07:56:25 +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-14 07:56:25 +0000
17+++ docs/_templates/maas/layout.html 2014-04-14 07:56:25 +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@@ -13,7 +14,12 @@
27 <footer class="global clearfix">
28 <div class="legal clearfix">
29 <p>&copy; Copyright {{ copyright }}. Ubuntu and Canonical are registered trademarks of
30- <a href="http://canonical.com">Canonical Ltd</a></p>
31+ <a href="http://canonical.com">Canonical Ltd</a>.
32+ </p>
33+ <p>
34+ Revision {{ bzr_last_revision_number}} ({{ bzr_last_revision_date }}).
35+ Documentation generation date: {{ bzr_build_date }}.
36+ </p>
37 </div>
38 </footer>
39 {%- endblock %}
40
41=== modified file 'docs/_templates/maas/relations.html'
42--- docs/_templates/maas/relations.html 2014-04-14 07:56:25 +0000
43+++ docs/_templates/maas/relations.html 2014-04-14 07:56:25 +0000
44@@ -1,3 +1,15 @@
45+<script type="text/javascript">
46+$(document).ready(function () {
47+ if ({{ add_version_switcher }}) {
48+ $.ajaxSetup({cache: true});
49+ $.getScript('{{ versions_json_path }}', function() {
50+ console.log( "Versions script loaded." );
51+ set_up_version_switcher('#version_switcher', '{{ doc_prefix }}');
52+ });
53+}
54+});
55+</script>
56+
57 <h3>Related Topics</h3>
58 <ul>
59 <li><a href="{{ pathto(master_doc) }}">Documentation overview</a><ul>
60
61=== modified file 'docs/conf.py'
62--- docs/conf.py 2014-04-14 07:56:25 +0000
63+++ docs/conf.py 2014-04-14 07:56:25 +0000
64@@ -23,6 +23,23 @@
65
66 # -- General configuration -----------------------------------------------------
67
68+# Add a widget to switch between different versions of the documentation to
69+# each generated page.
70+add_version_switcher = False
71+
72+# In order for the version widget to be able to redirect correctly to the
73+# other versions of the documentation, each version of the documentation
74+# has to be accessible at the following addresses:
75+# /<doc_prefix>/ -> documentation for trunk.
76+# /<doc_prefix>1.4/ -> documentation for 1.4.
77+# etc.
78+doc_prefix = 'docs'
79+
80+# Path of the JSON document, relative to homepage of the documentation for trunk
81+# (i.e. '/<doc_prefix>/'), with the list of the versions to include in the
82+# version switcher widget.
83+versions_path = '_static/versions.js'
84+
85 # If your documentation needs a minimal Sphinx version, state it here.
86 #needs_sphinx = '1.0'
87
88@@ -58,9 +75,9 @@
89 # built documents.
90 #
91 # The short X.Y version.
92-version = '12.10'
93+version = '1.3'
94 # The full version, including alpha/beta/rc tags.
95-release = '12.10b'
96+release = '1.3'
97
98 # The language for content autogenerated by Sphinx. Refer to documentation
99 # for a list of supported languages.
100@@ -240,3 +257,20 @@
101
102 # Example configuration for intersphinx: refer to the Python standard library.
103 intersphinx_mapping = {'http://docs.python.org/': None}
104+
105+# Gather information about the branch and the build date.
106+from subprocess import check_output
107+bzr_last_revision_number = check_output(['bzr', 'revno'])
108+bzr_last_revision_date = check_output(['bzr', 'version-info', '--template={date}', '--custom'])
109+bzr_build_date = check_output(['bzr', 'version-info', '--template={build_date}', '--custom'])
110+
111+# Populate html_context with the variables used in the templates.
112+html_context = {
113+ 'add_version_switcher': 'true' if add_version_switcher else 'false',
114+ 'versions_json_path': '/'.join(['', doc_prefix, versions_path]),
115+ 'doc_prefix': doc_prefix,
116+ 'bzr_last_revision_date': bzr_last_revision_date,
117+ 'bzr_last_revision_number': bzr_last_revision_number,
118+ 'bzr_build_date': bzr_build_date,
119+}
120+

Subscribers

People subscribed via source and target branches