From 8f62b3c4a80346b135317555c22e7f6107a9cc00 Mon Sep 17 00:00:00 2001 From: Ed Costello Date: Thu, 14 Mar 2013 12:57:09 -0400 Subject: [PATCH 1/4] DOCS-454 make sphinx project version aware and add navigation DOCS-454 conf.py modified to track version information better sphinx variable 'version' changed to be the actual version (2.2,2.4) variable release must be the point release (eg 2.2.3) Checkpoint DOCS-454 version/page flipping in jquery DOCS-454 add version navigation --- conf.py | 11 ++++++++--- themes/mongodb/layout.html | 11 ++++++++--- themes/mongodb/pagenav.html | 7 +++++-- themes/mongodb/static/mongodb-docs.css_t | 2 ++ themes/mongodb/theme.conf | 7 ++++++- themes/mongodb/versionnav.html | 25 ++++++++++++++++++++++++ 6 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 themes/mongodb/versionnav.html diff --git a/conf.py b/conf.py index 986211908da..3f4a517ae8c 100644 --- a/conf.py +++ b/conf.py @@ -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' @@ -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"}], + 'stable': '2.4', + 'version_uri': '/v', } html_sidebars = { diff --git a/themes/mongodb/layout.html b/themes/mongodb/layout.html index eaabfb62275..a12e526c929 100644 --- a/themes/mongodb/layout.html +++ b/themes/mongodb/layout.html @@ -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 %} @@ -37,10 +37,11 @@ {%- for scriptfile in script_files %} @@ -81,6 +82,7 @@ + {%- if pagename == 'index' %} @@ -195,5 +197,8 @@ {%- block jiracollector %} {%- include "jiracollector.html" %} {%- endblock %} +{%- block versionnav %} +{%- include "versionnav.html"%} +{%- endblock %} diff --git a/themes/mongodb/pagenav.html b/themes/mongodb/pagenav.html index 89a972c1bed..967b296b25b 100644 --- a/themes/mongodb/pagenav.html +++ b/themes/mongodb/pagenav.html @@ -1,7 +1,10 @@

{{ shorttitle }} {% if theme_project != 'about' %} {{ _('(Index)') }} -{% endif %} +{% endif -%}

- +{% if theme_project == 'manual' %} +{# the following span is replaced by the javascript in versionnav.html #} +

Versions: {{version}}

+{% endif %} {{ toctree(maxdepth=-1) }} diff --git a/themes/mongodb/static/mongodb-docs.css_t b/themes/mongodb/static/mongodb-docs.css_t index 09297de1a26..b7a59fd7d6c 100644 --- a/themes/mongodb/static/mongodb-docs.css_t +++ b/themes/mongodb/static/mongodb-docs.css_t @@ -831,3 +831,5 @@ 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;} +h4#vnd select option {font-size:smaller;line-height:1.0;font-size:1em;} diff --git a/themes/mongodb/theme.conf b/themes/mongodb/theme.conf index a8d5d0b73d9..32dd91cec44 100644 --- a/themes/mongodb/theme.conf +++ b/themes/mongodb/theme.conf @@ -12,4 +12,9 @@ repo_name = REPONAME jira_project = JIRA google_analytics = GACODE project = PROJECT -translations = LANGUAGES \ No newline at end of file +translations = LANGUAGES +version = VERSION +versions = VERSIONS +latest = LATEST +stable=STABLE +version_uri=VERSION_URI diff --git a/themes/mongodb/versionnav.html b/themes/mongodb/versionnav.html new file mode 100644 index 00000000000..bb917f8c541 --- /dev/null +++ b/themes/mongodb/versionnav.html @@ -0,0 +1,25 @@ + + From 6f95a19c155a237806b85adef5077897cbd0d6bd Mon Sep 17 00:00:00 2001 From: Ed Costello Date: Thu, 14 Mar 2013 18:49:56 -0400 Subject: [PATCH 2/4] Minor: remove unnecessary css style for h4#vnd --- themes/mongodb/static/mongodb-docs.css_t | 1 - 1 file changed, 1 deletion(-) diff --git a/themes/mongodb/static/mongodb-docs.css_t b/themes/mongodb/static/mongodb-docs.css_t index b7a59fd7d6c..90540c203bf 100644 --- a/themes/mongodb/static/mongodb-docs.css_t +++ b/themes/mongodb/static/mongodb-docs.css_t @@ -832,4 +832,3 @@ 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;} -h4#vnd select option {font-size:smaller;line-height:1.0;font-size:1em;} From 650d885e884d94b84ba3a44d68fb0fb6ab4b8873 Mon Sep 17 00:00:00 2001 From: Ed Costello Date: Thu, 14 Mar 2013 20:03:30 -0400 Subject: [PATCH 3/4] DOCS-454 minor tweak to /manual/ url --- themes/mongodb/versionnav.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/mongodb/versionnav.html b/themes/mongodb/versionnav.html index bb917f8c541..4fb80836010 100644 --- a/themes/mongodb/versionnav.html +++ b/themes/mongodb/versionnav.html @@ -4,8 +4,8 @@ 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} +if ((v==0)||(v=='{{theme_stable}}')) {uri='/manual/'+pn} +else {uri = '{{theme_version_uri}}'+v+'/'+pn} window.location.href= uri; } $(document).ready(function(){ From 235475ad4074d5176048835a761ddbf80f2560d2 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Fri, 15 Mar 2013 10:50:17 -0400 Subject: [PATCH 4/4] DOCS-454 refactor --- bin/makefile.meta | 9 ++++++ bin/mongodb_docs_meta.py | 55 +++++++++++++++++++++++++++---- conf.py | 10 +++--- makefile | 11 +------ themes/mongodb/layout.html | 1 - themes/mongodb/pagenav.html | 2 +- themes/mongodb/theme.conf | 5 ++- themes/mongodb/versionnav.html | 59 +++++++++++++++++++++++----------- 8 files changed, 107 insertions(+), 45 deletions(-) create mode 100644 bin/makefile.meta diff --git a/bin/makefile.meta b/bin/makefile.meta new file mode 100644 index 00000000000..dd06c4b970b --- /dev/null +++ b/bin/makefile.meta @@ -0,0 +1,9 @@ +manual-branch = $(shell bin/mongodb_docs_meta.py manual) +current-branch := $(shell bin/mongodb_docs_meta.py branch) +last-commit := $(shell bin/mongodb_docs_meta.py commit) + +ifeq ($(current-branch),$(manual-branch)) + current-if-not-manual = manual +else + current-if-not-manual = $(current-branch) +endif diff --git a/bin/mongodb_docs_meta.py b/bin/mongodb_docs_meta.py index d64d63d32ed..75db51c8518 100755 --- a/bin/mongodb_docs_meta.py +++ b/bin/mongodb_docs_meta.py @@ -3,8 +3,12 @@ import datetime import re import subprocess +import argparse MANUAL_BRANCH = 'master' +PUBLISHED_VERSIONS = [ '2.4', '2.2' ] +STABLE_RELEASE = PUBLISHED_VERSIONS[0] +UPCOMING_RELEASE = None def shell_value( args ): if isinstance( args , str ): @@ -16,7 +20,7 @@ def shell_value( args ): return value def get_manual_path(): - branch = shell_value('git symbolic-ref HEAD').split('/')[2] + branch = get_branch() if branch == MANUAL_BRANCH: manual_path = MANUAL_BRANCH @@ -31,13 +35,52 @@ def get_commit(): def get_branch(): return shell_value('git symbolic-ref HEAD').split('/')[2] +def get_versions(): + o = [] + + for version in PUBLISHED_VERSIONS: + version_string = str(version) + path_name = 'v' + version_string + + if version == STABLE_RELEASE: + version_string += ' (stable)' + elif version == UPCOMING_RELEASE: + version_string += ' (upcoming)' + + version_dict = { 'v': path_name, 't': version_string } + o.append(version_dict) + + return o + + def main(): - BREAK = "\n" + action_list = ['branch', 'commit', 'versions', 'stable', 'all', 'manual'] + parser = argparse.ArgumentParser('MongoDB Documentation Meta Data Provider') + parser.add_argument('action', choices=action_list, nargs='?', default='all') + + action = parser.parse_args().action + + if action == 'all': + BREAK = "\n" - print("MongoDB Manual:" + BREAK + - " Commit: " + meta_commit() + BREAK + - " Branch: " + meta_branch() + BREAK + - " Year: " + str(datetime.date.today().year)) + print("MongoDB Manual:" + BREAK + + " Commit: " + get_commit() + BREAK + + " Branch: " + get_branch() + BREAK + + " Manual: " + MANUAL_BRANCH + BREAK + + " Versions: " + str(PUBLISHED_VERSIONS) + BREAK + + " Stable: " + str(STABLE_RELEASE) + BREAK + + " Year: " + str(datetime.date.today().year) + BREAK + + " Version UI: " + str(get_versions())) + elif action == 'branch': + print(get_branch()) + elif action == 'commit': + print(get_commit()) + elif action == 'stable': + print(STABLE_RELEASE) + elif action == 'versions': + print(PUBLISHED_VERSIONS) + elif action == 'manual': + print(MANUAL_BRANCH) if __name__ == '__main__': main() diff --git a/conf.py b/conf.py index 3f4a517ae8c..0f12e2f31d8 100644 --- a/conf.py +++ b/conf.py @@ -18,6 +18,8 @@ 'commit': mongodb_docs_meta.get_commit(), 'manual_path': mongodb_docs_meta.get_manual_path(), 'date': str(datetime.date.today().year), + 'version_selector': mongodb_docs_meta.get_versions(), + 'stable': mongodb_docs_meta.STABLE_RELEASE } # -- General configuration ---------------------------------------------------- @@ -42,8 +44,7 @@ project = u'mongodb-manual' copyright = u'2011-' + meta['date'] + ', 10gen, Inc.' version = '2.4' -release = '2.2.3' - +release = '2.4.0' BREAK = '\n' rst_epilog = ('.. |branch| replace:: ``' + meta['branch'] + '``' + BREAK + @@ -132,9 +133,8 @@ 'google_analytics': 'UA-7301842-8', 'project': 'manual', 'version': version, - 'versions': [{'v':"2.2", 't':"v2.2"},{'v':"2.4", 't':"v2.4"}], - 'stable': '2.4', - 'version_uri': '/v', + 'version_selector': meta['version_selector'], + 'stable': meta['stable'], } html_sidebars = { diff --git a/makefile b/makefile index 35f9e9bb688..a75f047b1e1 100644 --- a/makefile +++ b/makefile @@ -10,16 +10,6 @@ public-output = $(output)/public branch-output = $(output)/$(current-branch) public-branch-output = $(public-output)/$(current-branch) -# get current branch & commit; set the branch that "manual/" points to; + a conditional -manual-branch = master -current-branch := $(shell git symbolic-ref HEAD 2>/dev/null | cut -d "/" -f "3" ) -last-commit := $(shell git rev-parse --verify HEAD) -ifeq ($(current-branch),$(manual-branch)) -current-if-not-manual = manual -else -current-if-not-manual = $(current-branch) -endif - help: @echo "Use 'make ', where is a Sphinx target (e.g. 'html', 'latex')" @echo "See 'meta.build.rst' for more on the build. Use the following MongoDB Manual targets:" @@ -36,6 +26,7 @@ include bin/makefile.content include bin/makefile.tables include bin/makefile.push include bin/makefile.manpages +include bin/makefile.meta ############# Meta targets that control the build and publication process. ############# publish-if-up-to-date: diff --git a/themes/mongodb/layout.html b/themes/mongodb/layout.html index a12e526c929..309ef455098 100644 --- a/themes/mongodb/layout.html +++ b/themes/mongodb/layout.html @@ -41,7 +41,6 @@ COLLAPSE_INDEX: false, FILE_SUFFIX: '{{ '' if no_search_suffix else file_suffix }}', HAS_SOURCE: {{ has_source|lower }}, - PAGENAME: '{{pagename}}' }; {%- for scriptfile in script_files %} diff --git a/themes/mongodb/pagenav.html b/themes/mongodb/pagenav.html index 967b296b25b..ad4c9be242f 100644 --- a/themes/mongodb/pagenav.html +++ b/themes/mongodb/pagenav.html @@ -5,6 +5,6 @@

{{ shorttitle }}

{% if theme_project == 'manual' %} {# the following span is replaced by the javascript in versionnav.html #} -

Versions: {{version}}

+

Version: {{version}}

{% endif %} {{ toctree(maxdepth=-1) }} diff --git a/themes/mongodb/theme.conf b/themes/mongodb/theme.conf index 32dd91cec44..b265a82d156 100644 --- a/themes/mongodb/theme.conf +++ b/themes/mongodb/theme.conf @@ -14,7 +14,6 @@ google_analytics = GACODE project = PROJECT translations = LANGUAGES version = VERSION -versions = VERSIONS +version_selector = VERSION_SELECTOR latest = LATEST -stable=STABLE -version_uri=VERSION_URI +stable = STABLE diff --git a/themes/mongodb/versionnav.html b/themes/mongodb/versionnav.html index 4fb80836010..516eaa6b40a 100644 --- a/themes/mongodb/versionnav.html +++ b/themes/mongodb/versionnav.html @@ -1,25 +1,46 @@ -