def build(self): # Document modules from source dir into self.temp_docs, remove temp conf.py, replace with template apidoc_command = f"-F -o {self.temp_docs} {self.source}".split(" ") print(f"Running sphinx api doc... [{apidoc_command}]") sphinx_apidoc_cmd(apidoc_command) conf_py_target = str(self.temp_docs / "conf.py") unlink(conf_py_target) data = asdict( SphinxKWArgs( sphinx_docs_target=str(self.source), project_name="", copyright="", author="", )) print("Rendering conf.py...") render_jinja_file(str(TEMPLATES_DIR / "conf.template"), conf_py_target, data) print("Replacing .rst files with available notebooks...") for notebook in self.notebook_path_iterator: unlink(self.temp_docs / f"{notebook.stem}.rst", ignore_errors=True) copy_file(source=notebook, target=(self.temp_docs / notebook.name)) build_command = f"-b html {self.temp_docs} {self.temp_docs / '_build'}" print(f"Running sphinx build... [{build_command}]") sphinx_build_cmd(build_command.split(" ")) change_log = ChangeLog() for source_dir in self.source_item_iterator: update_or_create_item(source_dir, self.target, self.temp_docs, change_log) target_static = self.target / "_static/_static" if not target_static.exists(): copy_file(self.temp_docs / "_build/_static", target_static) build_catalog_json(self.target_item_iterator, self.target) render_index(self.target_item_iterator, self.target) render_pages(self.target_item_iterator, self.target / "_static") copy_file(STATIC_DIR / "styles.css", self.target / "_static" / "styles.css") write_change_log(self.target / "README.md", change_log) rmtree(str(self.temp_docs))
def render_html_files(temp_docs): cmd = f"-b html {temp_docs} {temp_docs / '_build'}" click.echo(f"Rendering HTML... [sphinx {cmd}]") sphinx_build_cmd(cmd.split(" "))
def sphinx_build(): root = os.path.dirname(__file__) source = os.path.join(root, "docs", "source") build = os.path.join(root, "docs", "build", "html") sphinx_build_cmd([source, build])