Skip to content

Commit

Permalink
Added development warning to sphinx docs
Browse files Browse the repository at this point in the history
Added a warning at the top of the screen
when accessing the current master version.
This warning is clickable to bring the user
to the latest released version.

Co-authored-by: WAEliasmith <[email protected]>
  • Loading branch information
drasmuss and WAEliasmith committed Aug 25, 2020
1 parent f47ad69 commit 23bb11c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Release History

- Swapped position of "search" and "version" boxes (so search is at the top
and version is at the bottom). (`#58`_)
- Added notification when viewing the development version of docs. (`#62`_)

**Fixed**

Expand All @@ -40,6 +41,7 @@ Release History

.. _#58: https://github.com/nengo/nengo-sphinx-theme/pull/58
.. _#59: https://github.com/nengo/nengo-sphinx-theme/pull/59
.. _#62: https://github.com/nengo/nengo-sphinx-theme/pull/62

1.2.2 (April 14, 2020)
======================
Expand Down
4 changes: 4 additions & 0 deletions nengo_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ def sort_versions(releases):
releases.sort(key=parse_version, reverse=True)
return releases

def to_root(pagename):
return "../" * pagename.count("/")

if app.builder.format == "html":
app.builder.templates.environment.filters["sort_versions"] = sort_versions
app.builder.templates.environment.filters["to_root"] = to_root

app.connect("builder-inited", add_jinja_filters)
12 changes: 12 additions & 0 deletions nengo_sphinx_theme/theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@
<div class="container">
<div class="row">
<div class="col-10 offset-1 pb-5 documentation-source" role="main">
{% if building_version == "latest" and releases %}
{% set stable = releases | sort_versions | first %}
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>
This documentation is for a development version.
<a href="{{ pagename | to_root }}{{ stable }}/{{ pagename }}.html">
Click here for the latest stable release ({{ stable }}).
</a>
</p>
</div>
{% endif %}
{% block body %} {% endblock %}
</div>
</div>
Expand Down
6 changes: 1 addition & 5 deletions nengo_sphinx_theme/theme/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ <h3 class="pt-5 px-5">
<div class="form-group">
<label class="text-gray">Version:</label>
<select class="custom-select" onchange="switchVersion(this);">
{% set prefix = pagename
| list
| select("equalto", "/")
| map("replace", "/", "../")
| join("") %}
{% set prefix = pagename | to_root %}
{% if building_version == "latest" %}
<option selected>latest</option>
{% else %}
Expand Down

0 comments on commit 23bb11c

Please sign in to comment.