summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandra McCann <samccann@redhat.com>2019-07-08 15:21:05 -0400
committerAlicia Cozine <879121+acozine@users.noreply.github.com>2019-07-08 14:21:05 -0500
commit73bbdf4392c788d085c737489a91660fff06f525 (patch)
treebd203ff327bd8ba7d4325ef77058b11d9476fcbe
parent39adb258270c00476896a8bd951860d4e0845b05 (diff)
downloadansible-73bbdf4392c788d085c737489a91660fff06f525.tar.gz
Add a banner message to warn when not on latest documentation (#58526) (#58767)
* add banner to versions that are not latest (cherry picked from commit 35b6345bdcdc47126b05617736c67892f27db784)
-rw-r--r--docs/docsite/_themes/sphinx_rtd_theme/ansible_banner.html24
-rw-r--r--docs/docsite/_themes/sphinx_rtd_theme/layout.html2
-rw-r--r--docs/docsite/rst/conf.py12
3 files changed, 31 insertions, 7 deletions
diff --git a/docs/docsite/_themes/sphinx_rtd_theme/ansible_banner.html b/docs/docsite/_themes/sphinx_rtd_theme/ansible_banner.html
new file mode 100644
index 0000000000..3410f1e59a
--- /dev/null
+++ b/docs/docsite/_themes/sphinx_rtd_theme/ansible_banner.html
@@ -0,0 +1,24 @@
+<!--- Based on sphinx versionwarning extension. Extension currently only works on READTHEDOCS -->
+{# Creates a banner at the top of the page for any version not latest. #}
+ <script>
+ current_url = window.location.href;
+ if ((current_url.search("latest") > -1) || (current_url.search("/{{ latest_version }}/") > -1)) {
+ // no banner for latest release
+ } else if (current_url.search("devel") > -1) {
+ document.write('<div id="banner_id" class="admonition caution">');
+ para = document.createElement('p');
+ banner_text=document.createTextNode("You are reading the *devel* version of the Ansible documentation - this version is not guaranteed stable. Use the version selection to the left if you want the latest stable released version.");
+ para.appendChild(banner_text);
+ element = document.getElementById('banner_id');
+ element.appendChild(para);
+ document.write('</div>');
+ } else {
+ document.write('<div id="banner_id" class="admonition caution">');
+ para = document.createElement('p');
+ banner_text=document.createTextNode("You are reading an older version of the Ansible documentation. Use the version selection to the left if you want the latest stable released version.");
+ para.appendChild(banner_text);
+ element = document.getElementById('banner_id');
+ element.appendChild(para);
+ document.write('</div>');
+ }
+ </script>
diff --git a/docs/docsite/_themes/sphinx_rtd_theme/layout.html b/docs/docsite/_themes/sphinx_rtd_theme/layout.html
index 4b4d7ebd0f..6ec110b64b 100644
--- a/docs/docsite/_themes/sphinx_rtd_theme/layout.html
+++ b/docs/docsite/_themes/sphinx_rtd_theme/layout.html
@@ -232,6 +232,8 @@
</div> -->
{% include "breadcrumbs.html" %}
+
+ {% include "ansible_banner.html" %}
<div id="page-content">
{% block body %}{% endblock %}
</div>
diff --git a/docs/docsite/rst/conf.py b/docs/docsite/rst/conf.py
index 2010ec830f..e94e3a87b7 100644
--- a/docs/docsite/rst/conf.py
+++ b/docs/docsite/rst/conf.py
@@ -138,7 +138,11 @@ html_context = {
'github_user': 'ansible',
'github_repo': 'ansible',
'github_version': 'devel/docs/docsite/rst/',
- 'github_module_version': 'devel/lib/ansible/modules/'
+ 'github_module_version': 'devel/lib/ansible/modules/',
+ 'current_version': version,
+ 'latest_version': '2.8',
+ # list specifically out of order to make latest work
+ 'available_versions': ('latest', '2.7', '2.6', 'devel')
}
# The style sheet to use for HTML and HTML Help pages. A file of that name
@@ -244,9 +248,3 @@ autoclass_content = 'both'
intersphinx_mapping = {'python': ('https://docs.python.org/2/', (None, '../python2-2.7.13.inv')),
'python3': ('https://docs.python.org/3/', (None, '../python3-3.6.2.inv')),
'jinja2': ('http://jinja.pocoo.org/docs/', (None, '../jinja2-2.9.7.inv'))}
-
-# list specifically out of order to make latest work
-html_context = {
- 'current_version': version,
- 'available_versions': ('latest', '2.7', '2.6', 'devel')
-}