def _sphinx_run(self, warnerrors): if not self.verbose: status_stream = cStringIO.StringIO() else: status_stream = sys.stdout confoverrides = {} if self.project: confoverrides['project'] = self.project if self.version: confoverrides['version'] = self.version if self.release: confoverrides['release'] = self.release if self.today: confoverrides['today'] = self.today sphinx_config = config.Config(self.config_dir, 'conf.py', {}, []) sphinx_ver = pkg_resources.parse_version( pkg_resources.get_distribution("sphinx").version) if sphinx_ver > pkg_resources.parse_version('1.2.3'): sphinx_config.init_values(warnings.warn) else: sphinx_config.init_values() if self.builder == 'man' and len(sphinx_config.man_pages) == 0: return if self.sphinx_initialized: if sphinx_ver >= pkg_resources.parse_version('1.4.2'): confoverrides['suppress_warnings'] = [ 'app.add_directive', 'app.add_role', 'app.add_generic_role', 'app.add_node'] elif sphinx_ver >= pkg_resources.parse_version('1.4.0'): log.warn("[pbr] WARN: Sphinx versions 1.4.0 and 1.4.1 raise " "warnings during this run and will cause warnerrors " "to fail. For more information see: " "http://docs.openstack.org/developer/pbr/" "compatibility.html#sphinx-1.4") app = application.Sphinx( self.source_dir, self.config_dir, self.builder_target_dir, self.doctree_dir, self.builder, confoverrides, status_stream, freshenv=self.fresh_env, warningiserror=warnerrors) self.sphinx_initialized = True try: app.build(force_all=self.all_files) except Exception as err: from docutils import utils if isinstance(err, utils.SystemMessage): sys.stder.write('reST markup error:\n') sys.stderr.write(err.args[0].encode('ascii', 'backslashreplace')) sys.stderr.write('\n') else: raise if self.link_index: src = app.config.master_doc + app.builder.out_suffix dst = app.builder.get_outfilename('index') os.symlink(src, dst)
def _sphinx_run(self): if not self.verbose: status_stream = cStringIO.StringIO() else: status_stream = sys.stdout confoverrides = {} if self.project: confoverrides['project'] = self.project if self.version: confoverrides['version'] = self.version if self.release: confoverrides['release'] = self.release if self.today: confoverrides['today'] = self.today sphinx_config = config.Config(self.config_dir, 'conf.py', {}, []) sphinx_ver = pkg_resources.parse_version( pkg_resources.get_distribution("sphinx").version) if sphinx_ver > pkg_resources.parse_version('1.2.3'): sphinx_config.init_values(warnings.warn) else: sphinx_config.init_values() if self.builder == 'man' and len( getattr(sphinx_config, 'man_pages', '')) == 0: return if self.sphinx_initialized: confoverrides['suppress_warnings'] = [ 'app.add_directive', 'app.add_role', 'app.add_generic_role', 'app.add_node' ] app = application.Sphinx(self.source_dir, self.config_dir, self.builder_target_dir, self.doctree_dir, self.builder, confoverrides, status_stream, freshenv=self.fresh_env, warningiserror=self.warning_is_error) self.sphinx_initialized = True try: app.build(force_all=self.all_files) except Exception as err: from docutils import utils if isinstance(err, utils.SystemMessage): sys.stder.write('reST markup error:\n') sys.stderr.write(err.args[0].encode('ascii', 'backslashreplace')) sys.stderr.write('\n') else: raise if self.link_index: src = app.config.master_doc + app.builder.out_suffix dst = app.builder.get_outfilename('index') os.symlink(src, dst)
def _sphinx_run(self): if not self.verbose: status_stream = cStringIO.StringIO() else: status_stream = sys.stdout confoverrides = {} if self.version: confoverrides['version'] = self.version if self.release: confoverrides['release'] = self.release if self.today: confoverrides['today'] = self.today sphinx_config = config.Config(self.config_dir, 'conf.py', {}, []) sphinx_config.init_values() if self.builder == 'man' and len(sphinx_config.man_pages) == 0: return app = application.Sphinx(self.source_dir, self.config_dir, self.builder_target_dir, self.doctree_dir, self.builder, confoverrides, status_stream, freshenv=self.fresh_env, warningiserror=True) try: app.build(force_all=self.all_files) except Exception as err: from docutils import utils if isinstance(err, utils.SystemMessage): sys.stder.write('reST markup error:\n') sys.stderr.write(err.args[0].encode( 'ascii', 'backslashreplace')) sys.stderr.write('\n') else: raise if self.link_index: src = app.config.master_doc + app.builder.out_suffix dst = app.builder.get_outfilename('index') os.symlink(src, dst)
from sphinx.cmd import build sphinx_build = build.main except ImportError: from sphinx import build_main as sphinx_build argv_prefix = ["sphinx-build"] from sphinx import config as sphinx_config if not hasattr(sphinx_config.Config, "read"): from sphinx.util.tags import Tags sphinx_config.Config.read = staticmethod( lambda path: sphinx_config.Config( path, os.path.join(path, "conf.py"), {}, Tags() ) ) if len(sys.argv) < 5: print( "versionselector.py DOCSFOLDER CURRENT LATEST METADATA [ ADDITIONAL ]", file=sys.stderr, ) sys.exit(-1) docsfolder = sys.argv[1] current = sys.argv[2] latest = sys.argv[3] metadata = sys.argv[4] add_argv = sys.argv[5:] if len(sys.argv) > 5 else []