From 5c37935139892a96fe11a563dda9fdcce31edba4 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: Mon, 7 Aug 2017 09:28:04 +0200 Subject: [PATCH] Make openstackdocstheme an optional doc dependency cliff is a library that is used outside of OpenStack, too. Having a build requirement that needs something OpenStack specific makes life in cases (eg. for downstream packagers) more difficult. So let's make openstackdocstheme an optional requirement. Change-Id: I0f94a431be083b8b4baec850b1885ba07b5bf5c2 --- doc/source/conf.py | 19 +++++++++++++++---- setup.cfg | 7 +++++++ test-requirements.txt | 1 - tox.ini | 1 + 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 9cc93950..f58872b4 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -15,7 +15,15 @@ import datetime import subprocess -import openstackdocstheme +# make openstackdocstheme an optional dependency. cliff is a low level lib +# that is used outside of OpenStack. Not having something OpenStack specific +# as build requirement is a good thing. +try: + import openstackdocstheme +except ImportError: + has_openstackdocstheme = False +else: + has_openstackdocstheme = True # 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 @@ -32,8 +40,9 @@ import openstackdocstheme # ones. extensions = [ 'sphinx.ext.autodoc', - 'openstackdocstheme', ] +if has_openstackdocstheme: + extensions.append('openstackdocstheme') # openstackdocstheme options repository_name = 'openstack/cliff' @@ -109,7 +118,8 @@ pygments_style = 'sphinx' # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = 'default' -html_theme = 'openstackdocs' +if has_openstackdocstheme: + html_theme = 'openstackdocs' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -118,7 +128,8 @@ html_theme = 'openstackdocs' # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = [] -html_theme_path = [openstackdocstheme.get_html_theme_path()] +if has_openstackdocstheme: + html_theme_path = [openstackdocstheme.get_html_theme_path()] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". diff --git a/setup.cfg b/setup.cfg index 97252605..b5b936a5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,6 +16,13 @@ classifier = Intended Audience :: Developers Environment :: Console +[extras] +docs = + # make openstackdocstheme an optional dependency. cliff is a low level lib + # that is used outside of OpenStack. Not having something OpenStack specific + # as build requirement is a good thing. + openstackdocstheme>=1.16.0 # Apache-2.0 + [global] setup-hooks = pbr.hooks.setup_hook diff --git a/test-requirements.txt b/test-requirements.txt index 69453e51..b56d3558 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -12,4 +12,3 @@ coverage!=4.4,>=4.0 # Apache-2.0 # this is required for the docs build jobs sphinx>=1.6.2 # BSD -openstackdocstheme>=1.16.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 470da53f..6564c09e 100644 --- a/tox.ini +++ b/tox.ini @@ -15,6 +15,7 @@ commands = python setup.py test --coverage --coverage-package-name=cliff --slowest --testr-args='{posargs}' coverage report --show-missing deps = -r{toxinidir}/test-requirements.txt + .[docs] [testenv:pep8] deps = flake8