summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarragh Bailey <dbailey@hp.com>2015-03-03 18:20:14 +0000
committerDarragh Bailey <dbailey@hp.com>2015-03-04 19:03:38 +0000
commit702042e7968404d181aa516201e46bf5ff9c469f (patch)
tree9d050ba7db4d65798d4145558a27ebc905b6788d
parente5e13df52e8b27f79cc70346db594774f0e544cd (diff)
downloadpbr-702042e7968404d181aa516201e46bf5ff9c469f.tar.gz
Allow overwriting sphinx builder from command line
The build_sphinx setuptools command supports selection of a builder. Support the behaviour of being able to explicitely select any builder available to sphinx via "python setup.py build_sphinx -b linkcheck", not just one of the builders specified in the configuration file. Change-Id: I4c7ddcaf413e1bcc72550b3d920f8a777a710c97
-rw-r--r--pbr/builddoc.py4
-rw-r--r--pbr/tests/test_setup.py35
2 files changed, 39 insertions, 0 deletions
diff --git a/pbr/builddoc.py b/pbr/builddoc.py
index f1822da..7c9916b 100644
--- a/pbr/builddoc.py
+++ b/pbr/builddoc.py
@@ -198,6 +198,10 @@ class LocalBuildDoc(setup_command.BuildDoc):
def finalize_options(self):
# Not a new style class, super keyword does not work.
setup_command.BuildDoc.finalize_options(self)
+ # Handle builder option from command line - override cfg
+ option_dict = self.distribution.get_option_dict('build_sphinx')
+ if 'command line' in option_dict.get('builder', [[]])[0]:
+ self.builders = option_dict['builder'][1]
# Allow builders to be configurable - as a comma separated list.
if not isinstance(self.builders, list) and self.builders:
self.builders = self.builders.split(',')
diff --git a/pbr/tests/test_setup.py b/pbr/tests/test_setup.py
index 9f66f7a..252658c 100644
--- a/pbr/tests/test_setup.py
+++ b/pbr/tests/test_setup.py
@@ -275,6 +275,41 @@ class BuildSphinxTest(base.BaseTestCase):
self.assertIn('man', build_doc.builders)
self.assertIn('doctest', build_doc.builders)
+ def test_cmd_builder_override(self):
+
+ if self.has_opt:
+ self.distr.command_options["pbr"] = {
+ "autodoc_index_modules": ('setup.cfg', self.autodoc)
+ }
+
+ self.distr.command_options["build_sphinx"]["builder"] = (
+ "command line", "non-existing-builder")
+
+ build_doc = packaging.LocalBuildDoc(self.distr)
+ self.assertNotIn('non-existing-builder', build_doc.builders)
+ self.assertIn('html', build_doc.builders)
+
+ # process command line options which should override config
+ build_doc.finalize_options()
+
+ self.assertIn('non-existing-builder', build_doc.builders)
+ self.assertNotIn('html', build_doc.builders)
+
+ def test_cmd_builder_override_multiple_builders(self):
+
+ if self.has_opt:
+ self.distr.command_options["pbr"] = {
+ "autodoc_index_modules": ('setup.cfg', self.autodoc)
+ }
+
+ self.distr.command_options["build_sphinx"]["builder"] = (
+ "command line", "builder1,builder2")
+
+ build_doc = packaging.LocalBuildDoc(self.distr)
+ build_doc.finalize_options()
+
+ self.assertEqual(["builder1", "builder2"], build_doc.builders)
+
class ParseRequirementsTest(base.BaseTestCase):