Skip to content

Commit 73a2ef9

Browse files
authored
Update conf.py
1 parent 059097e commit 73a2ef9

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

docs/source/conf.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
if PROJECT_ROOT not in sys.path:
1010
sys.path.insert(0, PROJECT_ROOT)
1111

12+
# Add src to path for autodoc
13+
SRC_DIR = os.path.join(PROJECT_ROOT, "src")
14+
if SRC_DIR not in sys.path:
15+
sys.path.insert(0, SRC_DIR)
16+
1217
project = "FastMDAnalysis"
1318
copyright = f"{datetime.now():%Y}, Adekunle Aina"
1419
author = "Adekunle Aina"
@@ -18,7 +23,7 @@
1823

1924
extensions = [
2025
"sphinx.ext.autodoc",
21-
"sphinx.ext.autosummary",
26+
"sphinx.ext.autosummary",
2227
"sphinx.ext.napoleon",
2328
"sphinx.ext.viewcode",
2429
"sphinx.ext.intersphinx",
@@ -29,11 +34,12 @@
2934
"members": True,
3035
"undoc-members": False,
3136
"show-inheritance": True,
37+
"special-members": "__init__",
3238
}
3339

3440
autodoc_mock_imports = [
3541
"mdtraj",
36-
"numpy",
42+
"numpy",
3743
"matplotlib",
3844
"matplotlib.pyplot",
3945
"sklearn",
@@ -42,6 +48,8 @@
4248

4349
intersphinx_mapping = {
4450
"python": ("https://docs.python.org/3", {}),
51+
"numpy": ("https://numpy.org/doc/stable/", None),
52+
"matplotlib": ("https://matplotlib.org/stable/", None),
4553
}
4654

4755
templates_path = ["_templates"]
@@ -54,3 +62,24 @@
5462
"navigation_depth": 4,
5563
}
5664
primary_domain = "py"
65+
66+
# Auto-generate API documentation on build
67+
def setup(app):
68+
from sphinx.ext import apidoc
69+
70+
def run_apidoc(_):
71+
apidoc_main = getattr(apidoc, 'main', None)
72+
if apidoc_main is None:
73+
# Fallback for older Sphinx versions
74+
from sphinx.ext.apidoc import main as apidoc_main
75+
76+
apidoc_main([
77+
'-f', # Force overwrite
78+
'-e', # Put each module/class on its own page
79+
'-M', # Put module documentation before submodule
80+
'-o',
81+
os.path.join(os.path.dirname(__file__)), # Output to source/
82+
os.path.join(PROJECT_ROOT, 'src', 'fastmdanalysis') # Package path
83+
])
84+
85+
app.connect('builder-inited', run_apidoc)

0 commit comments

Comments
 (0)