builddoc: Use '[sphinx_build] builders' with Sphinx < 1.6

In 'c024066', we resolved an issue with pbr and Sphinx 1.6+ and
implicitly started using Sphinx 1.6's support for declaring multiple
builders as part of the setuptools plugin. However, in doing so, we
neglected to provide a migration path for folks who were using the older
option. This meant folks using the '[sphinx_build] builders' option
would see a breaking change in behavior when upgrading to a pbr release
including the above change. Resolve this issue now.

Note that we want to deprecate support for this option in the future,
but doing so is not a backportable change and will be done separately.

Change-Id: Ic2fe67f932ba26b665110ae66431a5359fc50016
Closes-Bug: #1702872
Related-Bug: #1691129
This commit is contained in:
Stephen Finucane 2017-07-07 11:02:36 +01:00
parent 07de844615
commit c59fad9c88
1 changed files with 14 additions and 4 deletions

View File

@ -25,6 +25,7 @@ except ImportError:
import io as cStringIO
try:
import sphinx
from sphinx import apidoc
from sphinx import application
from sphinx import setup_command
@ -42,6 +43,7 @@ except Exception as e:
raise ImportError(str(e))
from pbr import git
from pbr import options
from pbr import version
_rst_template = """%(heading)s
@ -186,13 +188,21 @@ class LocalBuildDoc(setup_command.BuildDoc):
"autodoc_exclude_modules",
[None, ""])[1].split()))
# TODO(stephenfin): Deprecate this functionality once we depend on
self.finalize_options()
is_multibuilder_sphinx = version.SemanticVersion.from_pip_string(
sphinx.__version__) >= version.SemanticVersion(1, 6)
if self.builders != ['html'] and is_multibuilder_sphinx:
self.builder = self.builders
# TODO(stephenfin): Deprecate this functionality once we decide on
# Sphinx 1.6, which includes a similar feature, in g-r
# https://github.com/sphinx-doc/sphinx/pull/3476
self.finalize_options()
if hasattr(self, "builder_target_dirs"):
# Sphinx >= 1.6.1
if is_multibuilder_sphinx:
# Sphinx >= 1.6
return setup_command.BuildDoc.run(self)
# Sphinx < 1.6
for builder in self.builders:
self.builder = builder