Adds list of versions in the "Updated" bar
Includes Jimmy's magic CSS. Co-Authored-By: Jimmy McArthur <jimmy@tipit.net> Change-Id: Ifdfcf932367314499f945f58a8c2188d709759b7
This commit is contained in:
parent
7f0688d891
commit
1aa39974f5
|
@ -69,9 +69,18 @@ copyright = u'2015-2017, OpenStack Contributors'
|
||||||
# "version" and "release" are used by the "log-a-bug" feature
|
# "version" and "release" are used by the "log-a-bug" feature
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '1.0'
|
#version = '1.0'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = '1.0'
|
#release = '1.0'
|
||||||
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
|
# |version| and |release|, also used in various other places throughout the
|
||||||
|
# built documents.
|
||||||
|
#
|
||||||
|
from openstackdocstheme.version import version_info
|
||||||
|
# The full version, including alpha/beta/rc tags.
|
||||||
|
release = version_info.release_string()
|
||||||
|
# The short X.Y version.
|
||||||
|
version = version_info.version_string()
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
@ -128,6 +137,7 @@ html_theme = 'openstackdocs'
|
||||||
# Otherwise, the list of links for the User and Ops docs
|
# Otherwise, the list of links for the User and Ops docs
|
||||||
# appear in the sidebar dropdown menu.
|
# appear in the sidebar dropdown menu.
|
||||||
#html_theme_options = {"sidebar_dropdown": "api_ref"}
|
#html_theme_options = {"sidebar_dropdown": "api_ref"}
|
||||||
|
html_theme_options = {'show_other_versions': True}
|
||||||
|
|
||||||
# Add any paths that contain custom themes here, relative to this directory.
|
# Add any paths that contain custom themes here, relative to this directory.
|
||||||
# html_theme_path = []
|
# html_theme_path = []
|
||||||
|
|
|
@ -13,12 +13,41 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import string
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
_giturl = 'https://git.openstack.org/cgit/{}/tree/doc/source'
|
_giturl = 'https://git.openstack.org/cgit/{}/tree/doc/source'
|
||||||
_html_context_data = None
|
_html_context_data = None
|
||||||
|
|
||||||
|
|
||||||
|
def _get_other_versions(app):
|
||||||
|
if not app.config.html_theme_options.get('show_other_versions', False):
|
||||||
|
return []
|
||||||
|
|
||||||
|
git_cmd = ["git", "tag", "--merged"]
|
||||||
|
try:
|
||||||
|
raw_version_list = subprocess.Popen(
|
||||||
|
git_cmd, stdout=subprocess.PIPE).communicate()[0]
|
||||||
|
raw_version_list = raw_version_list.decode("utf-8")
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
app.warn('Cannot decode the list based on utf-8 encoding. '
|
||||||
|
'Not setting "other_versions".')
|
||||||
|
raw_version_list = u''
|
||||||
|
except OSError:
|
||||||
|
app.warn('Cannot get tags from git repository, or no merged tags. '
|
||||||
|
'Not setting "other_versions".')
|
||||||
|
raw_version_list = u''
|
||||||
|
|
||||||
|
# grab last five that start with a number and reverse the order
|
||||||
|
_tags = [t.strip("'") for t in raw_version_list.split('\n')]
|
||||||
|
other_versions = [
|
||||||
|
t for t in _tags if t and t[0] in string.digits
|
||||||
|
# Don't show alpha, beta or release candidate tags
|
||||||
|
and 'rc' not in t and 'a' not in t and 'b' not in t
|
||||||
|
][:-5:-1]
|
||||||
|
return other_versions
|
||||||
|
|
||||||
|
|
||||||
def builder_inited(app):
|
def builder_inited(app):
|
||||||
theme_dir = os.path.join(os.path.dirname(__file__), 'theme')
|
theme_dir = os.path.join(os.path.dirname(__file__), 'theme')
|
||||||
app.info('Using openstackdocstheme Sphinx theme from %s' % theme_dir)
|
app.info('Using openstackdocstheme Sphinx theme from %s' % theme_dir)
|
||||||
|
@ -65,6 +94,7 @@ def _html_page_context(app, pagename, templatename, context, doctree):
|
||||||
_html_context_data['bug_tag'] = bug_tag
|
_html_context_data['bug_tag'] = bug_tag
|
||||||
|
|
||||||
context.update(_html_context_data)
|
context.update(_html_context_data)
|
||||||
|
context['other_versions'] = _get_other_versions(app)
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
|
|
|
@ -38,6 +38,19 @@ ga('send', 'pageview');
|
||||||
{% include 'titlerow.html' %}
|
{% include 'titlerow.html' %}
|
||||||
<div class="row docs-byline">
|
<div class="row docs-byline">
|
||||||
<div class="docs-updated">updated: {{ last_updated }}</div>
|
<div class="docs-updated">updated: {{ last_updated }}</div>
|
||||||
|
{%- block otherversions %}
|
||||||
|
{%- if other_versions %}
|
||||||
|
<div class="version-dropdown">
|
||||||
|
<span>{{ _('version') }}</span>
|
||||||
|
<div class="version-dropdown-content">
|
||||||
|
<p><a href="{{ pathto(master_doc) }}" rel="nofollow">Current</a></p>
|
||||||
|
{%- for ver in other_versions: %}
|
||||||
|
<p><a href="../{{pathto(ver, 1) }}" rel="nofollow">{{ ver }}</a></p>
|
||||||
|
{%- endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{%- endif %}
|
||||||
|
{%- endblock %}
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
|
|
|
@ -3813,6 +3813,34 @@ a.overview-btn.contribute-btn:hover {
|
||||||
a.overview-btn.contribute-btn i {
|
a.overview-btn.contribute-btn i {
|
||||||
margin-left: 10px; }
|
margin-left: 10px; }
|
||||||
|
|
||||||
|
/*------------------------------------*\
|
||||||
|
Docs Version Dropdown
|
||||||
|
\*------------------------------------*/
|
||||||
|
|
||||||
|
.version-dropdown {
|
||||||
|
position: relative;
|
||||||
|
float: right;
|
||||||
|
display: inline-block;
|
||||||
|
border: solid 1px;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.version-dropdown-content {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
min-width: 160px;
|
||||||
|
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
|
||||||
|
padding: 12px 16px;
|
||||||
|
top: 25px;
|
||||||
|
right: 5px;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.version-dropdown:hover .version-dropdown-content {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
/*End Docs Main*/
|
/*End Docs Main*/
|
||||||
/*Docs Book View*/
|
/*Docs Book View*/
|
||||||
.docs-book-wrapper, .docs-search-wrapper {
|
.docs-book-wrapper, .docs-search-wrapper {
|
||||||
|
@ -4080,6 +4108,10 @@ li.docs-has-sub.open:before {
|
||||||
float: left;
|
float: left;
|
||||||
padding: 5px; }
|
padding: 5px; }
|
||||||
|
|
||||||
|
.docs-versioned {
|
||||||
|
float: right;
|
||||||
|
padding: 5px; }
|
||||||
|
|
||||||
a.docs-edit {
|
a.docs-edit {
|
||||||
float: right;
|
float: right;
|
||||||
color: #9eb5c3; }
|
color: #9eb5c3; }
|
||||||
|
|
|
@ -8,3 +8,4 @@ analytics_tracking_code = UA-17511903-1
|
||||||
sidebar_mode = toctree
|
sidebar_mode = toctree
|
||||||
display_toc = True
|
display_toc = True
|
||||||
sidebar_dropdown = os_docs
|
sidebar_dropdown = os_docs
|
||||||
|
show_other_versions = False
|
||||||
|
|
Loading…
Reference in New Issue