Skip to content

DOCS-454 make docs version aware and add version navigator #728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@
master_doc = 'contents'
project = u'mongodb-manual'
copyright = u'2011-' + meta['date'] + ', 10gen, Inc.'
version = '2.2.3'
release = version
version = '2.4'
release = '2.2.3'


BREAK = '\n'
rst_epilog = ('.. |branch| replace:: ``' + meta['branch'] + '``' + BREAK +
'.. |copy| unicode:: U+000A9' + BREAK +
'.. |year| replace:: ' + meta['date'] + BREAK +
'.. |ent-build| replace:: the MongoDB Subscriber Edition' + BREAK +
'.. |ent-build| replace:: the MongoDB Subscriber Edition' + BREAK +
'.. |hardlink| replace:: http://docs.mongodb.org/' + meta['branch'])

pygments_style = 'sphinx'
Expand Down Expand Up @@ -130,6 +131,10 @@
'jira_project': 'DOCS',
'google_analytics': 'UA-7301842-8',
'project': 'manual',
'version': version,
'versions': [{'v':"2.2", 't':"v2.2"},{'v':"2.4", 't':"v2.4"}],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is, to be clear, a list of python dicts. and might be fragile if your JS expects keys to appear in a certain order.

also more descriptive field names might be more clear in the future

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also we shouldn't hard code this like this, but I'll capture this information from the meta script and make a pull request against this tonight if I can manage, or tomorrow.

'stable': '2.4',
'version_uri': '/v',
}

html_sidebars = {
Expand Down
11 changes: 8 additions & 3 deletions themes/mongodb/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
(sidebars != []) %}
{%- set url_root = pathto('', 1) %}
{%- if not embedded and docstitle %}
{%- set titlesuffix = " — "|safe + docstitle|e %}
{%- set titlesuffix = " — "|safe + docstitle|e + " " + release|e %}
{%- else %}
{%- set titlesuffix = "" %}
{%- endif %}
Expand Down Expand Up @@ -37,10 +37,11 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '{{ url_root }}',
VERSION: '{{ release|e }}',
VERSION: '{{ version|e }}',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '{{ '' if no_search_suffix else file_suffix }}',
HAS_SOURCE: {{ has_source|lower }}
HAS_SOURCE: {{ has_source|lower }},
PAGENAME: '{{pagename}}'
};
</script>
{%- for scriptfile in script_files %}
Expand Down Expand Up @@ -81,6 +82,7 @@
<link rel="shortcut icon" href="http://media.mongodb.org/favicon.ico" />
<meta name="robots" content="index" />
<meta http-equiv="Content-Type" content="text/html; charset={{ encoding }}" />
<meta name="release" content="{{theme_release}}"/>

{%- if pagename == 'index' %}
<link rel="canonical" href="http://docs.mongodb.org/{{theme_project}}/" />
Expand Down Expand Up @@ -195,5 +197,8 @@
{%- block jiracollector %}
{%- include "jiracollector.html" %}
{%- endblock %}
{%- block versionnav %}
{%- include "versionnav.html"%}
{%- endblock %}
</body>
</html>
7 changes: 5 additions & 2 deletions themes/mongodb/pagenav.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<h3><a href="{{ pathto(master_doc) }}">{{ shorttitle }}</a>
{% if theme_project != 'about' %}
<small><a href="{{ pathto('genindex') }}">{{ _('(Index)') }}</a></small>
{% endif %}
{% endif -%}
</h3>

{% if theme_project == 'manual' %}
{# the following span is replaced by the javascript in versionnav.html #}
<h4 id="vnd">Versions: <span id="vn">{{version}}</span></h4>
{% endif %}
{{ toctree(maxdepth=-1) }}
1 change: 1 addition & 0 deletions themes/mongodb/static/mongodb-docs.css_t
Original file line number Diff line number Diff line change
Expand Up @@ -831,3 +831,4 @@ div.highlight-powershell pre { background-color: #F5F5F5; }
div.admonition-example pre { background-color: #FBFBFB; }

li p.first { margin-bottom: 0em; }
h4#vnd {padding:0;margin:0;line-height:1.5;padding-left:10px;}
7 changes: 6 additions & 1 deletion themes/mongodb/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ repo_name = REPONAME
jira_project = JIRA
google_analytics = GACODE
project = PROJECT
translations = LANGUAGES
translations = LANGUAGES
version = VERSION
versions = VERSIONS
latest = LATEST
stable=STABLE
version_uri=VERSION_URI
25 changes: 25 additions & 0 deletions themes/mongodb/versionnav.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script type="text/javascript">
var versions = {{theme_versions}}
function vfnav() {
if (DOCUMENTATION_OPTIONS.PAGENAME=='index'){pn=''}
else {pn=DOCUMENTATION_OPTIONS.PAGENAME}
v = $(this).children("option:selected").attr('value')
if ((v==0)||(v=='{{theme_stable}}')) {uri = '/manual/' +'/' + pn}
else {uri = '{{theme_version_uri}}' + v + '/' + pn}
window.location.href= uri;
}
$(document).ready(function(){
$("#vn").html(function(){
s=$("<select/>");
o='<option/>';
$.each(versions,function(index, version) {
if (version.v == '{{theme_stable}}') {$(o,{value:version.v,text: version.t + ' (stable)'}).appendTo(s);dv=true;}
else {$(o, {value: version.v, text: version.t}).appendTo(s);}})
if (dv==false) {$(o, {value:0,text:'Stable'}).appendTo(s);}
return(s);
});
$("#vn select").bind('change', vfnav);
$('#vn select').val(DOCUMENTATION_OPTIONS.VERSION);
});
</script>