def run(self): # type: () -> None if not color_terminal(): nocolor() if not self.verbose: # type: ignore status_stream = StringIO() else: status_stream = sys.stdout # type: ignore confoverrides = {} # type: Dict[unicode, Any] 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 if self.copyright: confoverrides['copyright'] = self.copyright if self.nitpicky: confoverrides['nitpicky'] = self.nitpicky for builder, builder_target_dir in self.builder_target_dirs: app = None try: confdir = self.config_dir or self.source_dir with patch_docutils(confdir), docutils_namespace(): app = Sphinx(self.source_dir, self.config_dir, builder_target_dir, self.doctree_dir, builder, confoverrides, status_stream, freshenv=self.fresh_env, warningiserror=self.warning_is_error) app.build(force_all=self.all_files) if app.statuscode: raise DistutilsExecError('caused by %s builder.' % app.builder.name) except Exception as exc: handle_exception(app, self, exc, sys.stderr) if not self.pdb: raise SystemExit(1) if not self.link_index: continue src = app.config.master_doc + app.builder.out_suffix # type: ignore dst = app.builder.get_outfilename('index') # type: ignore os.symlink(src, dst)
def run(self): # type: () -> None if not color_terminal(): nocolor() if not self.verbose: # type: ignore status_stream = StringIO() else: status_stream = sys.stdout # type: ignore 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 if self.copyright: confoverrides['copyright'] = self.copyright for builder, builder_target_dir in self.builder_target_dirs: app = None try: confdir = self.config_dir or self.source_dir with patch_docutils(confdir), docutils_namespace(): app = Sphinx(self.source_dir, self.config_dir, builder_target_dir, self.doctree_dir, builder, confoverrides, status_stream, freshenv=self.fresh_env, warningiserror=self.warning_is_error) app.build(force_all=self.all_files) if app.statuscode: raise DistutilsExecError( 'caused by %s builder.' % app.builder.name) except Exception as exc: handle_exception(app, self, exc, sys.stderr) if not self.pdb: raise SystemExit(1) if not self.link_index: continue src = app.config.master_doc + app.builder.out_suffix # type: ignore dst = app.builder.get_outfilename('index') # type: ignore os.symlink(src, dst)
def run(self): if not color_terminal(): nocolor() if not self.verbose: status_stream = 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 if self.copyright: confoverrides['copyright'] = self.copyright app = None try: with docutils_namespace(): app = 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) app.build(force_all=self.all_files) if app.statuscode: raise DistutilsExecError('caused by %s builder.' % app.builder.name) except Exception as exc: handle_exception(app, self, exc, sys.stderr) if not self.pdb: raise SystemExit(1) if self.link_index: src = app.config.master_doc + app.builder.out_suffix dst = app.builder.get_outfilename('index') os.symlink(src, dst)
def run(self): if not color_terminal(): nocolor() if not self.verbose: status_stream = 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 if self.copyright: confoverrides["copyright"] = self.copyright try: with docutils_namespace(): app = 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, ) app.build(force_all=self.all_files) if app.statuscode: raise DistutilsExecError("caused by %s builder." % app.builder.name) except Exception as exc: handle_exception(app, self, exc, sys.stderr) if not self.pdb: raise SystemExit(1) if self.link_index: src = app.config.master_doc + app.builder.out_suffix dst = app.builder.get_outfilename("index") os.symlink(src, dst)
async def build_docs(collector, reference, tasks, **kwargs): """ Build the documentation You can specify options using the reference option. fresh Remove the cache force Force the build For example ``build_docs fresh,force`` """ options = collector.configuration["documentation"] reference_opts = [thing.strip() for thing in reference.split(",")] is_fresh = "fresh" in reference_opts force_all = "force" in reference_opts out = options.out tags = [] jobs = 1 srcdir = options.src confdir = pkg_resources.resource_filename("photons_docs", "config") builder = "html" verbosity = 0 confoverrides = {} warningiserror = False outdir = os.path.join(out, "result") doctreedir = os.path.join(out, "doctree") if is_fresh and os.path.exists(out): shutil.rmtree(out) for d in (outdir, doctreedir): if not os.path.exists(d): os.makedirs(d) app = None try: with docutils_namespace(): app = Sphinx( srcdir, confdir, outdir, doctreedir, builder, confoverrides, sys.stdout, sys.stderr, is_fresh, warningiserror, tags, verbosity, jobs, ) app.builder.env.protocol_register = collector.configuration[ "protocol_register"] app.builder.env.tasks = tasks app.build(force_all, []) if app.statuscode != 0: sys.exit(app.statuscode) except (Exception, KeyboardInterrupt) as exc: opts = type("opts", (object, ), { "pdb": False, "verbosity": verbosity, "traceback": True }) handle_exception(app, opts, exc, sys.stderr) sys.exit(1)