From 9a6159a529d9f7951c29844d5d5d8d84d718c8a3 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Wed, 28 Jun 2017 13:37:31 +0200 Subject: [PATCH] Minimal support for storyboard Allows setting of bug_project to a storyboard project number to redirect to project page on storyboard.openstack.org for report a bug feature. Also, add some minor cleanups to doc/source/conf.py. Change-Id: Ia14d30bf0dda89c48dec0a7cc3b8dccc26dc8d86 --- doc/source/conf.py | 9 +++------ doc/source/index.rst | 14 ++++++++++++-- openstackdocstheme/__init__.py | 3 +++ .../theme/openstackdocs/script_footer.html | 6 ++++++ .../theme/openstackdocs/static/js/docs.js | 8 +++++++- .../notes/storyboard-5f67da8941aec6ae.yaml | 4 ++++ 6 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/storyboard-5f67da8941aec6ae.yaml diff --git a/doc/source/conf.py b/doc/source/conf.py index a45c91a..9487fcc 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -12,10 +12,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import subprocess -import sys -import os -import warnings +# import os import openstackdocstheme @@ -62,8 +59,8 @@ master_doc = 'index' # 'security guide' or 'network guide' # It's used by the "log-a-bug" button on each page # and should ultimately be set automatically by the build process -project = u'network guide' -copyright = u'2015, OpenStack Contributors' +project = u'OpenStack Documentation Theme' +copyright = u'2015-2017, OpenStack Contributors' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/doc/source/index.rst b/doc/source/index.rst index 97f9b4b..cbe7275 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -54,19 +54,29 @@ Using the Theme ``'openstack/python-glanceclient'``. ``bug_project`` - The launchpad project name. For example, ``python-glanceclient``. + The project name or ID. For launchpad, it's a string like + ``python-glanceclient``. If your project uses + ``storyboard.openstack.org``, use the project number instead + like ``901`` ``bug_tag`` Launchpad bug tag. If unspecified, no tag is set. The default is empty. - For example:: + One example for a project using launchpad:: # openstackdocstheme options repository_name = 'openstack/python-glanceclient' bug_project = 'python-glanceclient' bug_tag = '' + One example for a project using storyboard:: + + # openstackdocstheme options + repository_name = 'openstack-infra/infra-manual' + bug_project = '721' + bug_tag = '' + #. Enable the "last-updated" information by setting the format for the timestamp:: diff --git a/openstackdocstheme/__init__.py b/openstackdocstheme/__init__.py index d8fb2f5..176219f 100644 --- a/openstackdocstheme/__init__.py +++ b/openstackdocstheme/__init__.py @@ -58,9 +58,12 @@ def _html_page_context(app, pagename, templatename, context, doctree): bug_project = app.config.bug_project if bug_project: _html_context_data['bug_project'] = bug_project + if bug_project and bug_project.isdigit(): + _html_context_data['use_storyboard'] = True bug_tag = app.config.bug_tag if bug_tag: _html_context_data['bug_tag'] = bug_tag + context.update(_html_context_data) diff --git a/openstackdocstheme/theme/openstackdocs/script_footer.html b/openstackdocstheme/theme/openstackdocs/script_footer.html index 3f2d7d8..5654a0b 100644 --- a/openstackdocstheme/theme/openstackdocs/script_footer.html +++ b/openstackdocstheme/theme/openstackdocs/script_footer.html @@ -47,6 +47,12 @@ var bugTitle = "{{ title }} in {{ project }}"; {%- endif %} var fieldTags = "{{ bug_tag }}"; + {%- if use_storyboard %} + var useStoryboard = "{{ use_storyboard }}"; + {%- else %} + var useStoryboard = ""; + {%- endif %} + /* "last_updated" is the build date and time. It relies on the conf.py variable "html_last_updated_fmt", which should include diff --git a/openstackdocstheme/theme/openstackdocs/static/js/docs.js b/openstackdocstheme/theme/openstackdocs/static/js/docs.js index a65ab80..2cd84a0 100644 --- a/openstackdocstheme/theme/openstackdocs/static/js/docs.js +++ b/openstackdocstheme/theme/openstackdocs/static/js/docs.js @@ -127,11 +127,17 @@ function logABug(bugTitle, bugProject, fieldComment, fieldTags) { var urlBase = "https://bugs.launchpad.net/" + bugProject + "/+filebug?field.title="; var currentURL = "URL: " + window.location.href; - var bugLink = urlBase + encodeURIComponent(bugTitle) + + var bugLink = ""; + if (useStoryboard) { + var urlBase = "https://storyboard.openstack.org/#!/project/"; + bugLink = urlBase + bugProject; + } else { + bugLink = urlBase + encodeURIComponent(bugTitle) + "&field.comment=" + lineFeed + lineFeed + lineFeed + bugChecklist + lineFeed + "-----------------------------------" + lineFeed + fieldComment + lineFeed + currentURL + "&field.tags=" + fieldTags; + } document.getElementById("logABugLink1").href=bugLink; document.getElementById("logABugLink2").href=bugLink; document.getElementById("logABugLink3").href=bugLink; diff --git a/releasenotes/notes/storyboard-5f67da8941aec6ae.yaml b/releasenotes/notes/storyboard-5f67da8941aec6ae.yaml new file mode 100644 index 0000000..a8c1638 --- /dev/null +++ b/releasenotes/notes/storyboard-5f67da8941aec6ae.yaml @@ -0,0 +1,4 @@ +--- +features: + - Initial integration of storyboard.openstack.org for report a bug, + set ``bug_project`` to the number of the project to use it.