def run_make_mode(args): warnings.warn( 'sphinx.make_mode.run_make_mode() is deprecated. ' 'Please use sphinx.cmd.make_mode.run_make_mode() instead.', RemovedInSphinx30Warning, stacklevel=2) return make_mode.run_make_mode(args)
def make_main(argv=sys.argv[1:]): # type: (List[str]) -> int """Sphinx build "make mode" entry.""" from sphinx.cmd import make_mode return make_mode.run_make_mode(argv[1:])
def run_make_mode(args): warnings.warn('sphinx.make_mode.run_make_mode() is deprecated. ' 'Please use sphinx.cmd.make_mode.run_make_mode() instead.', RemovedInSphinx30Warning, stacklevel=2) return make_mode.run_make_mode(args)
def test_sphinx_can_build_docs_with_constants(): # We've observed that sphinx has a problem building when trying to important constant_sorrow. docs_dir = os.path.join(os.path.dirname(__file__), 'docs_for_testing') exit_code = run_make_mode(args=["html", docs_dir, docs_dir]) assert exit_code is not 2
import sphinx.cmd.make_mode as sphinx_build import os import shutil OUT_DIR = "docs" # here you have your conf.py etc build_output = os.path.join(OUT_DIR, "_build") shutil.rmtree(build_output) # build HTML (same as `make html`) build_html_args = ["html", OUT_DIR, build_output] sphinx_build.run_make_mode(args=build_html_args) ''' # build PDF latex (same as `make latexpdf`) build_pdf_args = ["latexpdf", OUT_DIR, build_output] sphinx_build.run_make_mode(args=build_pdf_args) '''
def build(self, repo_name): source = self.get_repo_path(repo_name) destination = self.get_pickle_path(repo_name) run_make_mode(['htmlcontent', source, destination])
# Some parameters are unfortunately hardcoded, so dirty editing: conf_py = os.path.join(OUT_DIR, "conf.py") with open(conf_py, "r+") as f: # open in read/write mode: lines = f.readlines() os.remove(conf_py) # remove line, append text at beginning and at end: try: lines.pop(lines.index(REMOVE_LINE)) except ValueError: print("WARNING: EXPECTED LINE DIDN'T EXIST:", REMOVE_LINE) lines.insert(1, EXTRA_BEGIN + "\n") lines.append(EXTRA_END + "\n") # rewrite edited file to its original path with open(conf_py, "w") as f: f.writelines(lines) # Another dirty hack: the cleanest way to create a fresh apidoc is removing # the existing index.rst and running apidoc: os.remove(os.path.join(OUT_DIR, "index.rst")) apidoc_argv = ["-o", OUT_DIR, "-F", PACKAGE_NAME] sphinx_apidoc.main(argv=apidoc_argv) # Optionally build the docs: build_output = os.path.join(OUT_DIR, "_build") if BUILD_HTML: build_pdf_args = ["html", OUT_DIR, build_output] sphinx_build.run_make_mode(args=build_pdf_args) if BUILD_PDF: build_pdf_args = ["latexpdf", OUT_DIR, build_output] sphinx_build.run_make_mode(args=build_pdf_args)