Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog/910.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Manually generate \`\`autoapi\`\` docs
51 changes: 45 additions & 6 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"sphinx_jinja",
"pyvista.ext.plot_directive",
"sphinx_design",
"ansys_sphinx_theme.extension.autoapi",
]

# Intersphinx mapping
Expand Down Expand Up @@ -144,10 +143,6 @@

# -- Declare the Jinja context -----------------------------------------------
BUILD_API = True if os.environ.get("BUILD_API", "true") == "true" else False
if not BUILD_API:
exclude_patterns.append("api")
html_theme_options.pop("ansys_sphinx_theme_autoapi")
extensions.remove("ansys_sphinx_theme.extension.autoapi")

suppress_warnings = ["autoapi.python_import_resolution", "config.cache", "docutils"]

Expand Down Expand Up @@ -194,6 +189,45 @@
},
}

import sphinx
from sphinx.util import logging
import pathlib
import sys

def run_autoapi(app):
"""
Run the autoapi script to generate API documentation.

Parameters
----------
app : sphinx.application.Sphinx
Sphinx application instance containing the all the doc build configuration.

"""
logger = logging.getLogger(__name__)
logger.info("\nWriting reST files for API documentation...", color="green")

scritps_dir = pathlib.Path(app.srcdir).parent.parent / "scripts"
sys.path.append(str(scritps_dir.resolve()))

print(scritps_dir)

from autoapi import autodoc_extensions
autodoc_extensions()

logger.info("Done!\n")

autodoc_default_options = {
#'members': 'var1, var2',
"member-order": "alphabetical",
#'special-members': '__init__',
"show-inheritance": True,
"undoc-members": True,
#'exclude-members': '__weakref__'
}
autodoc_class_signature = "separated"


def skip_run_subpackage(app, what, name, obj, skip, options):
"""Skip specific members of the 'run' subpackage during documentation generation.

Expand All @@ -215,4 +249,9 @@ def skip_run_subpackage(app, what, name, obj, skip, options):

def setup(sphinx):
"""Add custom extensions to Sphinx."""
sphinx.connect("autoapi-skip-member", skip_run_subpackage)
if BUILD_API:
# exclude_patterns.append("api")
# html_theme_options.pop("ansys_sphinx_theme_autoapi")
# extensions.remove("ansys_sphinx_theme.extension.autoapi")
sphinx.connect("builder-inited", run_autoapi)
# sphinx.connect("autoapi-skip-member", skip_run_subpackage)
Loading
Loading