Skip to content

Commit 8e29f37

Browse files
authored
Autogenerate all API docs (#2002)
* Autogenerate all API docs * Fix duplicate Array docs * Fix doc errors * Fix skip logic * Fix module name splitting * Change autoapi directory * Add more enum docs * Fix testing docstring * Pin max version of sphinx-autoapi * Fix spelling * Pin max version of sphinx-autoapi * Skip zarr.core in API docs * Fix buffer namespace
1 parent 59b118d commit 8e29f37

File tree

16 files changed

+56
-18
lines changed

16 files changed

+56
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ coverage.xml
5151

5252
# Sphinx documentation
5353
docs/_build/
54+
docs/_autoapi
5455

5556
# PyBuilder
5657
target/

docs/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ help:
5252
.PHONY: clean
5353
clean:
5454
rm -rf $(BUILDDIR)/*
55+
rm -rf $(BUILDDIR)/../_autoapi
5556

5657
.PHONY: html
5758
html:

docs/api/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ API Reference
44
.. toctree::
55
:maxdepth: 1
66

7-
zarr
7+
../_autoapi/zarr/index

docs/api/zarr.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/conf.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@
5757

5858
autoapi_dirs = ['../src/zarr']
5959
autoapi_add_toctree_entry = False
60-
autoapi_generate_api_docs = False
60+
autoapi_generate_api_docs = True
6161
autoapi_member_order = "groupwise"
62-
autoapi_root = "api"
62+
autoapi_root = "_autoapi"
63+
autoapi_keep_files = True
6364

6465

6566
# Add any paths that contain templates here, relative to this directory.
@@ -172,8 +173,19 @@
172173
html_logo = "_static/logo1.png"
173174

174175

176+
def autoapi_skip_modules(app: sphinx.application.Sphinx, what: str, name: str, obj: object, skip: bool, options: dict[str, Any]) -> bool:
177+
"""
178+
Return True if a module should be skipped in th API docs.
179+
"""
180+
parts = name.split(".")
181+
if what == "module" and (any(part.startswith("_") for part in parts) or "v2" in name or name.startswith("zarr.core")):
182+
return True
183+
return False
184+
185+
175186
def setup(app: sphinx.application.Sphinx) -> None:
176187
app.add_css_file("custom.css")
188+
app.connect("autoapi-skip-member", autoapi_skip_modules)
177189

178190

179191
# The name of an image file (relative to this directory) to use as a favicon of
@@ -339,7 +351,7 @@ def setup(app: sphinx.application.Sphinx) -> None:
339351
# use in refs e.g:
340352
# :ref:`comparison manual <python:comparisons>`
341353
intersphinx_mapping = {
342-
"python": ("https://docs.python.org/", None),
354+
"python": ("https://docs.python.org/3/", None),
343355
"numpy": ("https://numpy.org/doc/stable/", None),
344356
"numcodecs": ("https://numcodecs.readthedocs.io/en/stable/", None),
345357
}

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ gpu = [
7878
"cupy-cuda12x",
7979
]
8080
docs = [
81-
'sphinx',
81+
'sphinx<8',
8282
'sphinx-autobuild>=2021.3.14',
83-
'sphinx-autoapi',
83+
'sphinx-autoapi<3.1',
8484
'sphinx_design',
8585
'sphinx-issues',
8686
'sphinx-copybutton',

src/zarr/codecs/blosc.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222

2323
class BloscShuffle(Enum):
24+
"""
25+
Enum for shuffle filter used by blosc.
26+
"""
27+
2428
noshuffle = "noshuffle"
2529
shuffle = "shuffle"
2630
bitshuffle = "bitshuffle"
@@ -38,6 +42,10 @@ def from_int(cls, num: int) -> BloscShuffle:
3842

3943

4044
class BloscCname(Enum):
45+
"""
46+
Enum for compression library used by blosc.
47+
"""
48+
4149
lz4 = "lz4"
4250
lz4hc = "lz4hc"
4351
blosclz = "blosclz"

src/zarr/codecs/bytes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020

2121
class Endian(Enum):
22+
"""
23+
Enum for endian type used by bytes codec.
24+
"""
25+
2226
big = "big"
2327
little = "little"
2428

src/zarr/codecs/sharding.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060

6161

6262
class ShardingCodecIndexLocation(Enum):
63+
"""
64+
Enum for index location used by the sharding codec.
65+
"""
66+
6367
start = "start"
6468
end = "end"
6569

src/zarr/core/array.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868

6969
from zarr.abc.codec import Codec, CodecPipeline
7070

71+
# Array and AsyncArray are defined in the base ``zarr`` namespace
72+
__all__ = ["parse_array_metadata", "create_codec_pipeline"]
73+
7174

7275
def parse_array_metadata(data: Any) -> ArrayV2Metadata | ArrayV3Metadata:
7376
if isinstance(data, ArrayV2Metadata | ArrayV3Metadata):

0 commit comments

Comments
 (0)