summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-03-30 18:19:42 +0000
committerGerrit Code Review <review@openstack.org>2017-03-30 18:19:42 +0000
commit5a21031398e426c20562417081eaabf2b535aca2 (patch)
treeddd54d690a0ca7ae6e4e4576b4af4d4136888792
parent02228ceb2110a1bc2c484ff1a715dd664740efe2 (diff)
parent2d7c0045f402b31d6223437ba25423eeb32278e1 (diff)
Merge "Initialize sphinx config using application instead of config"2.1.0
-rw-r--r--pbr/builddoc.py17
-rw-r--r--pbr/tests/test_setup.py6
2 files changed, 9 insertions, 14 deletions
diff --git a/pbr/builddoc.py b/pbr/builddoc.py
index f51b283..4f05673 100644
--- a/pbr/builddoc.py
+++ b/pbr/builddoc.py
@@ -17,9 +17,7 @@
17from distutils import log 17from distutils import log
18import fnmatch 18import fnmatch
19import os 19import os
20import pkg_resources
21import sys 20import sys
22import warnings
23 21
24try: 22try:
25 import cStringIO 23 import cStringIO
@@ -29,7 +27,6 @@ except ImportError:
29try: 27try:
30 from sphinx import apidoc 28 from sphinx import apidoc
31 from sphinx import application 29 from sphinx import application
32 from sphinx import config
33 from sphinx import setup_command 30 from sphinx import setup_command
34except Exception as e: 31except Exception as e:
35 # NOTE(dhellmann): During the installation of docutils, setuptools 32 # NOTE(dhellmann): During the installation of docutils, setuptools
@@ -134,16 +131,6 @@ class LocalBuildDoc(setup_command.BuildDoc):
134 confoverrides['release'] = self.release 131 confoverrides['release'] = self.release
135 if self.today: 132 if self.today:
136 confoverrides['today'] = self.today 133 confoverrides['today'] = self.today
137 sphinx_config = config.Config(self.config_dir, 'conf.py', {}, [])
138 sphinx_ver = pkg_resources.parse_version(
139 pkg_resources.get_distribution("sphinx").version)
140 if sphinx_ver > pkg_resources.parse_version('1.2.3'):
141 sphinx_config.init_values(warnings.warn)
142 else:
143 sphinx_config.init_values()
144 if self.builder == 'man' and len(
145 getattr(sphinx_config, 'man_pages', '')) == 0:
146 return
147 if self.sphinx_initialized: 134 if self.sphinx_initialized:
148 confoverrides['suppress_warnings'] = [ 135 confoverrides['suppress_warnings'] = [
149 'app.add_directive', 'app.add_role', 136 'app.add_directive', 'app.add_role',
@@ -153,6 +140,10 @@ class LocalBuildDoc(setup_command.BuildDoc):
153 self.builder_target_dir, self.doctree_dir, 140 self.builder_target_dir, self.doctree_dir,
154 self.builder, confoverrides, status_stream, 141 self.builder, confoverrides, status_stream,
155 freshenv=self.fresh_env, warningiserror=self.warning_is_error) 142 freshenv=self.fresh_env, warningiserror=self.warning_is_error)
143 sphinx_config = app.config
144 if self.builder == 'man' and len(
145 getattr(sphinx_config, 'man_pages', '')) == 0:
146 return
156 self.sphinx_initialized = True 147 self.sphinx_initialized = True
157 148
158 try: 149 try:
diff --git a/pbr/tests/test_setup.py b/pbr/tests/test_setup.py
index 0754a8d..0930e35 100644
--- a/pbr/tests/test_setup.py
+++ b/pbr/tests/test_setup.py
@@ -224,6 +224,10 @@ class GitLogsTest(base.BaseTestCase):
224 self.assertTrue(co_author in authors) 224 self.assertTrue(co_author in authors)
225 225
226 226
227class _SphinxConfig(object):
228 man_pages = ['foo']
229
230
227class BaseSphinxTest(base.BaseTestCase): 231class BaseSphinxTest(base.BaseTestCase):
228 232
229 def setUp(self): 233 def setUp(self):
@@ -234,7 +238,7 @@ class BaseSphinxTest(base.BaseTestCase):
234 self.useFixture(fixtures.MonkeyPatch( 238 self.useFixture(fixtures.MonkeyPatch(
235 "sphinx.application.Sphinx.build", lambda *a, **kw: None)) 239 "sphinx.application.Sphinx.build", lambda *a, **kw: None))
236 self.useFixture(fixtures.MonkeyPatch( 240 self.useFixture(fixtures.MonkeyPatch(
237 "sphinx.config.Config.man_pages", ['foo'])) 241 "sphinx.application.Sphinx.config", _SphinxConfig))
238 self.useFixture(fixtures.MonkeyPatch( 242 self.useFixture(fixtures.MonkeyPatch(
239 "sphinx.config.Config.init_values", lambda *a: None)) 243 "sphinx.config.Config.init_values", lambda *a: None))
240 self.useFixture(fixtures.MonkeyPatch( 244 self.useFixture(fixtures.MonkeyPatch(