Fix openstackdocstheme options for api-ref

Initialize the parameter for current openstackdocstheme so that report a
bug feature works and displays all parameter including git URL and SHA.

We need to add openstackdocstheme as extension so that the parameter are
properly initialized. html_context is not needed anymore. The display of
time of last commit is done by openstackdocstheme.

Change-Id: Ic46f5ff6bc42b48ce9de5f5bf3a2193ed75fb063
Closes-Bug: #1743728
This commit is contained in:
Stephen Finucane 2018-01-17 10:03:51 +00:00
parent f9067e0b3d
commit 62ea2ff04d
2 changed files with 14 additions and 28 deletions

View File

@ -23,23 +23,18 @@
# serve to show the default. # serve to show the default.
import os import os
import subprocess
import sys import sys
import warnings
import openstackdocstheme
extensions = [ extensions = [
'openstackdocstheme',
'os_api_ref', 'os_api_ref',
] ]
html_theme = 'openstackdocs' html_theme = 'openstackdocs'
html_theme_path = [openstackdocstheme.get_html_theme_path()]
html_theme_options = { html_theme_options = {
"sidebar_mode": "toc", "sidebar_mode": "toc",
} }
html_context = {'bug_project': 'nova', 'bug_tag': 'api-ref'}
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
@ -67,6 +62,11 @@ master_doc = 'index'
project = u'Compute API Reference' project = u'Compute API Reference'
copyright = u'2010-present, OpenStack Foundation' copyright = u'2010-present, OpenStack Foundation'
# openstackdocstheme options
repository_name = 'openstack/nova'
bug_project = 'nova'
bug_tag = 'api-ref'
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
@ -150,14 +150,7 @@ pygments_style = 'sphinx'
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format. # using the given strftime format.
# html_last_updated_fmt = '%b %d, %Y' html_last_updated_fmt = '%Y-%m-%d %H:%M'
git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local",
"-n1"]
try:
html_last_updated_fmt = subprocess.check_output(git_cmd).decode('utf-8')
except Exception:
warnings.warn('Cannot get last updated time from git repository. '
'Not setting "html_last_updated_fmt".')
# If true, SmartyPants will be used to convert quotes and dashes to # If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities. # typographically correct entities.

View File

@ -25,23 +25,18 @@
# serve to show the default. # serve to show the default.
import os import os
import subprocess
import sys import sys
import warnings
import openstackdocstheme
extensions = [ extensions = [
'openstackdocstheme',
'os_api_ref', 'os_api_ref',
] ]
html_theme = 'openstackdocs' html_theme = 'openstackdocs'
html_theme_path = [openstackdocstheme.get_html_theme_path()]
html_theme_options = { html_theme_options = {
"sidebar_mode": "toc", "sidebar_mode": "toc",
} }
html_context = {'bug_project': 'nova', 'bug_tag': 'placement-api-ref'}
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
@ -69,6 +64,11 @@ master_doc = 'index'
project = u'Placement API Reference' project = u'Placement API Reference'
copyright = u'2010-present, OpenStack Foundation' copyright = u'2010-present, OpenStack Foundation'
# openstackdocstheme options
repository_name = 'openstack/nova'
bug_project = 'nova'
bug_tag = 'placement-api-ref'
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
@ -152,14 +152,7 @@ pygments_style = 'sphinx'
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format. # using the given strftime format.
# html_last_updated_fmt = '%b %d, %Y' html_last_updated_fmt = '%Y-%m-%d %H:%M'
git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local",
"-n1"]
try:
html_last_updated_fmt = subprocess.check_output(git_cmd).decode('utf-8')
except Exception:
warnings.warn('Cannot get last updated time from git repository. '
'Not setting "html_last_updated_fmt".')
# If true, SmartyPants will be used to convert quotes and dashes to # If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities. # typographically correct entities.