Skip to content

Commit

Permalink
Generate Python api and example rest docs only if sphinx build is ena…
Browse files Browse the repository at this point in the history
…bled.
  • Loading branch information
saurabheights committed Nov 13, 2023
1 parent 6167131 commit 6696c1b
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions docs/make_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,36 +659,37 @@ def run(self):
shutil.rmtree(cpp_build_dir)
print("Removed directory %s" % cpp_build_dir)

# Python API reST docs
if not args.py_api_rst == "never":
print("Building Python API reST")
pd = PyAPIDocsBuilder()
pd.generate_rst()

# Python example reST docs
py_example_input_dir = os.path.join(pwd, "..", "examples", "python")
if not args.py_example_rst == "never":
print("Building Python example reST")
pe = PyExampleDocsBuilder(input_dir=py_example_input_dir, pwd=pwd)
pe.generate_rst()

# Jupyter docs (needs execution)
if not args.execute_notebooks == "never":
print("Building Jupyter docs")
jdb = JupyterDocsBuilder(pwd, args.clean_notebooks,
args.execute_notebooks)
jdb.run()

# Remove *.ipynb in the output folder for CI docs.
if args.delete_notebooks:
print(f"Deleting all *.ipynb files in the {html_output_dir} folder.")
for f in Path(html_output_dir).glob("**/*.ipynb"):
print(f"Deleting {f}")
f.unlink()

# Sphinx is hard-coded to build with the "html" option
# To customize build, run sphinx-build manually
if args.sphinx:
# Python API reST docs
if not args.py_api_rst == "never":
print("Building Python API reST")
pd = PyAPIDocsBuilder()
pd.generate_rst()

# Python example reST docs
py_example_input_dir = os.path.join(pwd, "..", "examples", "python")
if not args.py_example_rst == "never":
print("Building Python example reST")
pe = PyExampleDocsBuilder(input_dir=py_example_input_dir, pwd=pwd)
pe.generate_rst()

# Jupyter docs (needs execution)
if not args.execute_notebooks == "never":
print("Building Jupyter docs")
jdb = JupyterDocsBuilder(pwd, args.clean_notebooks,
args.execute_notebooks)
jdb.run()

# Remove *.ipynb in the output folder for CI docs.
if args.delete_notebooks:
print(
f"Deleting all *.ipynb files in the {html_output_dir} folder.")
for f in Path(html_output_dir).glob("**/*.ipynb"):
print(f"Deleting {f}")
f.unlink()

print("Building Sphinx docs")
skip_notebooks = (args.execute_notebooks == "never" and
args.clean_notebooks)
Expand Down

0 comments on commit 6696c1b

Please sign in to comment.