Skip to content

Commit

Permalink
Remove sphinx-apidoc generation from docs build
Browse files Browse the repository at this point in the history
- Reorder docs
- Make clean ignore missing folder
  • Loading branch information
oerc0122 authored and alinelena committed Mar 5, 2024
1 parent 36d7ac4 commit 5d6235f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 56 deletions.
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ customdefault:
all: html

clean:
rm -r $(BUILDDIR)
rm -rf $(BUILDDIR)

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
Expand Down
20 changes: 10 additions & 10 deletions docs/source/apidoc/janus_core.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
janus\_core package
===================

Module contents
---------------

.. automodule:: janus_core
:members:
:special-members:
:private-members:
:undoc-members:
:show-inheritance:

Submodules
----------

Expand Down Expand Up @@ -43,13 +53,3 @@ janus\_core.single\_point module
:private-members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: janus_core
:members:
:special-members:
:private-members:
:undoc-members:
:show-inheritance:
45 changes: 0 additions & 45 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,48 +186,3 @@
nitpick_ignore = [
("py:class", "Logger"),
]


def run_apidoc(_):
"""Runs sphinx-apidoc when building the documentation.
Needs to be done in conf.py in order to include the APIdoc in the
build on readthedocs.
See also https://github.com/rtfd/readthedocs.org/issues/1139
"""
source_dir = os.path.abspath(os.path.dirname(__file__))
apidoc_dir = os.path.join(source_dir, "apidoc")
package_dir = os.path.join(source_dir, os.pardir, os.pardir, "janus_core")

# In #1139, they suggest the route below, but this ended up
# calling sphinx-build, not sphinx-apidoc
# from sphinx.apidoc import main
# main([None, '-e', '-o', apidoc_dir, package_dir, '--force'])

import subprocess

cmd_path = "sphinx-apidoc"
if hasattr(sys, "real_prefix"): # Check to see if we are in a virtualenv
# If we are, assemble the path manually
cmd_path = os.path.abspath(os.path.join(sys.prefix, "bin", "sphinx-apidoc"))

options = [
"-o",
apidoc_dir,
package_dir,
"--private",
"--force",
"--no-toc",
]

# See https://stackoverflow.com/a/30144019
env = os.environ.copy()
env["SPHINX_APIDOC_OPTIONS"] = (
"members,special-members,private-members,undoc-members,show-inheritance"
)
subprocess.check_call([cmd_path] + options, env=env)


def setup(app):
app.connect("builder-inited", run_apidoc)

0 comments on commit 5d6235f

Please sign in to comment.