Add support for configuring pbr sphinx options.

Change-Id: Idfdd1c8850433bf3ea2439f939756f5c60bb88a1
This commit is contained in:
Monty Taylor 2013-03-27 16:40:45 +01:00
parent d539c3d76b
commit d0b083d28f
2 changed files with 9 additions and 6 deletions

View File

@ -236,19 +236,16 @@ try:
def __init__(self, *args, **kwargs):
kwargs['warningiserror'] = True
super(LocalSphinx, self).__init__(*args, **kwargs)
sphinx.application.Sphinx = LocalSphinx
class LocalBuildDoc(setup_command.BuildDoc):
command_name = 'build_sphinx'
builders = ['html', 'man']
def generate_autoindex(self):
def generate_autoindex(self, option_dict):
log.info("[pbr] Autodocumenting from %s"
% os.path.abspath(os.curdir))
modules = {}
option_dict = self.distribution.get_option_dict('build_sphinx')
source_dir = os.path.join(option_dict['source_dir'][1], 'api')
if not os.path.exists(source_dir):
os.makedirs(source_dir)
@ -278,8 +275,11 @@ try:
autoindex.write(" %s.rst\n" % module)
def run(self):
if not os.getenv('SPHINX_DEBUG'):
self.generate_autoindex()
option_dict = self.distribution.get_option_dict('build_sphinx')
if 'autoindex' in option_dict and not os.getenv('SPHINX_DEBUG'):
self.generate_autoindex(option_dict)
if 'warnerrors' in option_dict:
application.Sphinx = LocalSphinx
for builder in self.builders:
self.builder = builder

View File

@ -23,3 +23,6 @@ packages =
[global]
setup-hooks =
pbr.hooks.setup_hook
[build_sphinx]
warnerrors = True