summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcbjchen@cn.ibm.com <cbjchen@cn.ibm.com>2013-11-22 18:51:07 +0800
committercbjchen@cn.ibm.com <cbjchen@cn.ibm.com>2013-11-27 23:23:07 +0800
commit62d9684b3f71732e2fcdb6509dd02df89f13136f (patch)
tree2e53a3ed70bed07d95ab1810e2b8561d569cab11
parentb101514a4f24d307cfe33286d3b73242759058a0 (diff)
downloadpbr-62d9684b3f71732e2fcdb6509dd02df89f13136f.tar.gz
Make sphinx builders configurable in LocalBuildDoc
Sphinx builders were hard coded to be html and man in LocalBuildDoc before. This enables users to config a list of builders in setup.cfg as a comma seperated list, e.g. html,man,doctest Change-Id: I3528b208c7e719286fe8816acf65f8efdc5844c6
-rw-r--r--pbr/packaging.py7
-rw-r--r--pbr/tests/test_setup.py33
2 files changed, 40 insertions, 0 deletions
diff --git a/pbr/packaging.py b/pbr/packaging.py
index 7fa12af..5ba3848 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -721,6 +721,13 @@ try:
else:
setup_command.BuildDoc.run(self)
+ def finalize_options(self):
+ # Not a new style class, super keyword does not work.
+ setup_command.BuildDoc.finalize_options(self)
+ # Allow builders to be configurable - as a comma separated list.
+ if not isinstance(self.builders, list) and self.builders:
+ self.builders = self.builders.split(',')
+
class LocalBuildLatex(LocalBuildDoc):
builders = ['latex']
command_name = 'build_sphinx_latex'
diff --git a/pbr/tests/test_setup.py b/pbr/tests/test_setup.py
index 93d3cdf..0ca9a46 100644
--- a/pbr/tests/test_setup.py
+++ b/pbr/tests/test_setup.py
@@ -253,6 +253,39 @@ class BuildSphinxTest(base.BaseTestCase):
os.path.exists(
"api/fake_package.fake_module.rst") == self.has_autodoc)
+ def test_builders_config(self):
+ if self.has_opt:
+ self.distr.command_options["pbr"] = {
+ "autodoc_index_modules": ('setup.cfg', self.autodoc)}
+
+ build_doc = packaging.LocalBuildDoc(self.distr)
+ build_doc.finalize_options()
+
+ self.assertEqual(2, len(build_doc.builders))
+ self.assertIn('html', build_doc.builders)
+ self.assertIn('man', build_doc.builders)
+
+ build_doc = packaging.LocalBuildDoc(self.distr)
+ build_doc.builders = ''
+ build_doc.finalize_options()
+
+ self.assertEqual('', build_doc.builders)
+
+ build_doc = packaging.LocalBuildDoc(self.distr)
+ build_doc.builders = 'man'
+ build_doc.finalize_options()
+
+ self.assertEqual(1, len(build_doc.builders))
+ self.assertIn('man', build_doc.builders)
+
+ build_doc = packaging.LocalBuildDoc(self.distr)
+ build_doc.builders = 'html,man,doctest'
+ build_doc.finalize_options()
+
+ self.assertIn('html', build_doc.builders)
+ self.assertIn('man', build_doc.builders)
+ self.assertIn('doctest', build_doc.builders)
+
class ParseRequirementsTest(base.BaseTestCase):