Skip to content

Commit 4a77332

Browse files
authored
Include Git version string in footer and sidebar (#729)
* Include Git version string in footer. Try to fetch the current commit description from "git describe" to dynamically populate the "version" and "release" configuration values. Add a reference to the template page footer stating the release information, just below the "Edit on GitHub" link. * Add a short version number to the sidebar. In addition to the footer info, include a new snippet into the navigation sidebar.
1 parent 61f6e9b commit 4a77332

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

_templates/layout.html

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
{%- if edit_on_github_url %}
44
<div class="body footer-body" role="footer">
55
<a class="reference external" href="{{ edit_on_github_url }}" rel="nofollow">{{ _('Edit this page on GitHub') }}</a>
6+
<br />
7+
<small>Version: {{ release }}</small>
68
</div>
79
{%- endif %}
810
{{ super() }}

_templates/version.html

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<p>Written for {{ version }}</p>
2+
<hr />

conf.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@
6161
# |version| and |release|, also used in various other places throughout the
6262
# built documents.
6363
#
64-
# The short X.Y version.
65-
version = 'v1'
6664
# The full version, including alpha/beta/rc tags.
67-
release = 'v1'
65+
try:
66+
release = os.popen('git describe --tags --long --always --dirty').read().strip()
67+
except Exception:
68+
release = 'v1'
69+
# The short X.Y version.
70+
version = release.partition('-')[0]
6871

6972
# The language for content autogenerated by Sphinx. Refer to documentation
7073
# for a list of supported languages.
@@ -178,7 +181,16 @@
178181
#html_use_smartypants = True
179182

180183
# Custom sidebar templates, maps document names to template names.
181-
#html_sidebars = {}
184+
html_sidebars = {
185+
'**': [
186+
"about.html",
187+
"version.html",
188+
"navigation.html",
189+
"relations.html",
190+
"searchbox.html",
191+
"donate.html",
192+
],
193+
}
182194

183195
# Additional templates that should be rendered to pages, maps page names to
184196
# template names.

0 commit comments

Comments
 (0)