use openstackdocstheme html context

Set some of the new config values and enable openstackdocstheme as an
extension so it will inject values into the page context as it writes
each documentation page. This ensures the pages link to the right bug
tracker, etc.

Change-Id: I36d400358b1b5e2c2423c43f43c775bafb0d4721
Depends-On: Icf3a40ed104cfd828f532f6f2b112ed02f996ff5
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2017-06-23 14:48:58 -04:00 committed by Akihiro Motoki
parent 8a71225a96
commit baa9b9c732
2 changed files with 15 additions and 28 deletions

View File

@ -26,11 +26,8 @@ from __future__ import print_function
import django import django
import logging import logging
import openstackdocstheme
import os import os
import subprocess
import sys import sys
import warnings
# NOTE(amotoki): Sphinx 1.6.x catches warnings from imported modules. # NOTE(amotoki): Sphinx 1.6.x catches warnings from imported modules.
@ -69,8 +66,15 @@ extensions = ['sphinx.ext.autodoc',
'sphinx.ext.todo', 'sphinx.ext.todo',
'sphinx.ext.coverage', 'sphinx.ext.coverage',
'sphinx.ext.viewcode', 'sphinx.ext.viewcode',
'openstackdocstheme',
] ]
# openstackdocstheme options
repository_name = 'openstack/horizon'
bug_project = 'horizon'
bug_tag = 'documentation'
html_last_updated_fmt = '%Y-%m-%d %H:%M'
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates'] templates_path = ['_templates']
@ -150,7 +154,7 @@ html_theme_options = {
} }
# 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 = [openstackdocstheme.get_html_theme_path()] # html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to # The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation". # "<project> v<release> documentation".
@ -176,13 +180,6 @@ html_static_path = []
# 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 = '%b %d, %Y'
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.
@ -224,20 +221,6 @@ except Exception:
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'Horizondoc' htmlhelp_basename = 'Horizondoc'
# We ask git for the SHA checksum
# The git SHA checksum is used by "log-a-bug"
gitsha = subprocess.check_output(git_cmd).strip('\n')
giturl = u'https://git.openstack.org/cgit/openstack/horizon/tree/doc/source'
# html_context allows us to pass arbitrary values into the html template
html_context = {
"gitsha": gitsha,
"giturl": giturl,
"bug_project": "horizon",
# tag that reported bugs will be tagged with
"bug_tag": "documentation",
}
# -- Options for LaTeX output ------------------------------------------------- # -- Options for LaTeX output -------------------------------------------------
latex_elements = { latex_elements = {

View File

@ -29,8 +29,6 @@
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.')) # sys.path.insert(0, os.path.abspath('.'))
import openstackdocstheme
# -- General configuration ------------------------------------------------ # -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here. # If your documentation needs a minimal Sphinx version, state it here.
@ -42,8 +40,15 @@ import openstackdocstheme
extensions = [ extensions = [
'reno.sphinxext', 'reno.sphinxext',
'sphinx.ext.extlinks', 'sphinx.ext.extlinks',
'openstackdocstheme',
] ]
# openstackdocstheme options
repository_name = 'openstack/horizon'
bug_project = 'horizon'
bug_tag = 'documentation'
html_last_updated_fmt = '%Y-%m-%d %H:%M'
# Set aliases for extlinks # Set aliases for extlinks
# - generic launchpad bug - [:bug:`12345`] # - generic launchpad bug - [:bug:`12345`]
# - horizon blueprint - [:blueprint:`drop-nova-network`] # - horizon blueprint - [:blueprint:`drop-nova-network`]
@ -138,7 +143,6 @@ html_theme = 'openstackdocs'
# 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 = []
html_theme_path = [openstackdocstheme.get_html_theme_path()]
# The name for this set of Sphinx documents. If None, it defaults to # The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation". # "<project> v<release> documentation".