From c59fad9c883c85af02b663f5c25b297f54f992d1 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 7 Jul 2017 11:02:36 +0100 Subject: [PATCH] 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 --- pbr/builddoc.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pbr/builddoc.py b/pbr/builddoc.py index c1a2e6f4..5c3a9e65 100644 --- a/pbr/builddoc.py +++ b/pbr/builddoc.py @@ -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