Skip to content

Commit 0ce5a61

Browse files
committed
Fix creation of api index
1 parent 76b8a37 commit 0ce5a61

11 files changed

+177
-44
lines changed

derotation/analysis/full_derotation_pipeline.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,9 +1133,7 @@ def derotate_frames_line_by_line(self) -> np.ndarray:
11331133
def find_image_offset(img):
11341134
"""Find the "F0", also called "image offset" for a given image.
11351135
1136-
Explanations
1137-
------------
1138-
What is the image offset?
1136+
Explanations: What is the image offset?
11391137
The PMT (photo-multiplier tube) adds an arbitrary offset to the
11401138
image that corresponds to 0 photons received. We can use a Gaussian
11411139
Mixture Model to find this offset by assuming that it will be the

docs/make_api_index.py

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,65 @@
1-
"""
2-
Generate the API index page for all modules.
3-
Inspired by `movement` package.
4-
"""
5-
61
import os
72
from pathlib import Path
83

94
# Modules to exclude from the API index
10-
exclude_modules = [
11-
"cli_entrypoint",
12-
"loader_widgets",
13-
"meta_widget",
14-
]
5+
EXCLUDE_MODULES = {"cli_entrypoint", "loader_widgets", "meta_widget"}
156

167
# Set the current working directory to the directory of this script
17-
script_dir = Path(__file__).resolve().parent
18-
os.chdir(script_dir)
8+
SCRIPT_DIR = Path(__file__).resolve().parent
9+
os.chdir(SCRIPT_DIR)
1910

2011

2112
def make_api_index():
22-
"""Create a doctree of all ``movement`` modules."""
23-
doctree = "\n"
13+
"""Generate a properly formatted `api_index.rst` file for Sphinx documentation."""
14+
2415
api_path = Path("../derotation")
16+
module_entries = []
17+
2518
for path in sorted(api_path.rglob("*.py")):
2619
# Convert file path to module name
2720
rel_path = path.relative_to(api_path.parent)
2821
module_name = str(rel_path.with_suffix("")).replace(os.sep, ".")
29-
if rel_path.stem not in exclude_modules:
30-
doctree += f" {module_name}\n"
31-
# # Get the header
32-
api_head_path = Path("source") / "_templates" / "api_index_head.rst"
33-
api_head = api_head_path.read_text()
34-
# Write api_index.rst with header + doctree
22+
23+
if rel_path.stem not in EXCLUDE_MODULES:
24+
module_entries.append(module_name)
25+
26+
# Construct the API index content
27+
api_index_content = """\
28+
.. _target-api:
29+
30+
API Reference
31+
=============
32+
33+
This section contains automatically generated documentation for the `derotation` package.
34+
35+
.. toctree::
36+
:maxdepth: 2
37+
:caption: API Documentation
38+
39+
"""
40+
41+
# Add module entries for the toctree
42+
api_index_content += "\n".join(f" {module}" for module in module_entries) + "\n\n"
43+
44+
# Add the autosummary directive
45+
api_index_content += """\
46+
.. rubric:: Modules
47+
48+
.. autosummary::
49+
:toctree: api
50+
:nosignatures:
51+
52+
"""
53+
54+
# Add module entries for autosummary
55+
api_index_content += "\n".join(f" {module}" for module in module_entries) + "\n"
56+
57+
# Write the generated content to `api_index.rst`
3558
output_path = Path("source") / "api_index.rst"
36-
with output_path.open("w") as f:
37-
f.write(api_head)
38-
f.write(doctree)
59+
output_path.write_text(api_index_content, encoding="utf-8")
60+
61+
print(f"Generated {output_path}")
3962

4063

4164
if __name__ == "__main__":
42-
make_api_index()
65+
make_api_index()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
derotation.\_\_init\_\_
2+
=======================
3+
4+
.. currentmodule:: derotation
5+
6+
.. autofunction:: __init__
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
derotation.analysis.bayesian\_optimization
2+
==========================================
3+
4+
.. automodule:: derotation.analysis.bayesian_optimization
5+
6+
7+
.. rubric:: Classes
8+
9+
.. autosummary::
10+
11+
BO_for_derotation
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
derotation.analysis.full\_derotation\_pipeline
2+
==============================================
3+
4+
.. automodule:: derotation.analysis.full_derotation_pipeline
5+
6+
7+
.. rubric:: Classes
8+
9+
.. autosummary::
10+
11+
FullPipeline
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
derotation.analysis.incremental\_derotation\_pipeline
2+
=====================================================
3+
4+
.. automodule:: derotation.analysis.incremental_derotation_pipeline
5+
6+
7+
.. rubric:: Classes
8+
9+
.. autosummary::
10+
11+
IncrementalPipeline
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
derotation.analysis.mean\_images
2+
================================
3+
4+
.. automodule:: derotation.analysis.mean_images
5+
6+
7+
.. rubric:: Functions
8+
9+
.. autosummary::
10+
11+
calculate_mean_images
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
derotation.analysis.metrics
2+
===========================
3+
4+
.. automodule:: derotation.analysis.metrics
5+
6+
7+
.. rubric:: Functions
8+
9+
.. autosummary::
10+
11+
ptd_of_most_detected_blob
12+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
derotation.derotate\_batch
2+
==========================
3+
4+
.. automodule:: derotation.derotate_batch
5+
6+
7+
.. rubric:: Functions
8+
9+
.. autosummary::
10+
11+
derotate
12+
update_config_paths
13+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
derotation.simulate.synthetic\_data
2+
===================================
3+
4+
.. automodule:: derotation.simulate.synthetic_data
5+
6+
7+
.. rubric:: Classes
8+
9+
.. autosummary::
10+
11+
SyntheticData
12+

0 commit comments

Comments
 (0)