Skip to content

Commit fa5f984

Browse files
committed
switch docs from autoapi to autodoc
1 parent e1560a1 commit fa5f984

7 files changed

Lines changed: 104 additions & 45 deletions

File tree

.readthedocs.yaml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,13 @@ build:
77
os: ubuntu-24.04
88
tools:
99
python: "3.12"
10-
jobs:
11-
create_environment:
12-
- asdf plugin add uv
13-
- asdf install uv latest
14-
- asdf global uv latest
15-
- UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH uv sync --only-group
16-
docs
17-
- UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH uv pip install .
18-
--no-deps
19-
install:
20-
- "true"
10+
commands:
11+
- asdf plugin add uv
12+
- asdf install uv latest
13+
- asdf global uv latest
14+
- uv sync --group docs
15+
- uv run python -m sphinx -T -b html -d docs/_build/doctrees -D language=en
16+
docs $READTHEDOCS_OUTPUT/html
2117

2218
sphinx:
2319
configuration: docs/conf.py

docs/api/polartoolkit.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
polartoolkit package
2+
====================
3+
4+
.. automodule:: polartoolkit
5+
:members:
6+
:show-inheritance:
7+
:undoc-members:
8+
9+
Submodules
10+
----------
11+
12+
polartoolkit.fetch module
13+
-------------------------
14+
15+
.. automodule:: polartoolkit.fetch
16+
:members:
17+
:show-inheritance:
18+
:undoc-members:
19+
20+
polartoolkit.maps module
21+
------------------------
22+
23+
.. automodule:: polartoolkit.maps
24+
:members:
25+
:show-inheritance:
26+
:undoc-members:
27+
28+
polartoolkit.profiles module
29+
----------------------------
30+
31+
.. automodule:: polartoolkit.profiles
32+
:members:
33+
:show-inheritance:
34+
:undoc-members:
35+
36+
polartoolkit.regions module
37+
---------------------------
38+
39+
.. automodule:: polartoolkit.regions
40+
:members:
41+
:show-inheritance:
42+
:undoc-members:
43+
44+
polartoolkit.utils module
45+
-------------------------
46+
47+
.. automodule:: polartoolkit.utils
48+
:members:
49+
:show-inheritance:
50+
:undoc-members:

docs/conf.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
import polartoolkit
1+
import importlib.metadata
22

33
project = "polartoolkit"
44
copyright = "2023, Matt Tankersley"
55
author = "Matt Tankersley"
6-
version = release = polartoolkit.__version__
6+
version = release = importlib.metadata.version("polartoolkit")
7+
78
extensions = [
8-
"sphinx.ext.autodoc", # needed for typehints
9-
"sphinx.ext.viewcode",
9+
"myst_parser",
10+
"sphinx.ext.autodoc",
1011
"sphinx.ext.intersphinx",
11-
"sphinx.ext.napoleon",
12-
"autoapi.extension",
1312
"sphinx.ext.mathjax",
13+
"sphinx.ext.napoleon",
14+
"sphinx_autodoc_typehints",
1415
"sphinx_copybutton",
15-
"myst_parser",
16-
"sphinx_design",
16+
"sphinx.ext.viewcode",
1717
"nbsphinx",
1818
"sphinxcontrib.bibtex",
19+
"sphinx_design",
1920
]
21+
2022
source_suffix = [".rst", ".md"]
2123
exclude_patterns = [
2224
"_build",
@@ -29,8 +31,6 @@
2931

3032
bibtex_bibfiles = ["_polartoolkit_refs.bib"]
3133

32-
nbsphinx_execute = "never"
33-
3434
myst_enable_extensions = [
3535
"colon_fence",
3636
]
@@ -47,11 +47,11 @@
4747
"rioxarray": ("https://corteva.github.io/rioxarray/stable/", None),
4848
"xrft": ("https://xrft.readthedocs.io/en/stable/", None),
4949
"harmonica": ("https://www.fatiando.org/harmonica/latest/", None),
50-
"numba": ("https://numba.pydata.org/numba-doc/latest/", None),
50+
"numba": ("https://numba.readthedocs.io/en/stable/index.html", None),
5151
"scipy": ("https://docs.scipy.org/doc/scipy/", None),
5252
"pyvista": ("https://docs.pyvista.org/", None),
5353
"pooch": ("https://www.fatiando.org/pooch/latest/", None),
54-
"cartopy": ("https://scitools.org.uk/cartopy/docs/latest/", None),
54+
"cartopy": ("https://cartopy.readthedocs.io/latest/", None),
5555
# "tqdm": ("https://tqdm.github.io/", None),
5656
"pygmt": ("https://www.pygmt.org/latest/", None),
5757
"matplotlib": ("https://matplotlib.org/stable/", None),
@@ -76,13 +76,15 @@
7676
add_module_names = False
7777
add_function_parentheses = False
7878

79-
# API doc configuration
80-
# -----------------------------------------------------------------------------
81-
autoapi_dirs = ["../src/polartoolkit"]
82-
autoapi_type = "python"
83-
autoapi_add_toctree_entry = False
84-
autodoc_typehints = "description"
8579

80+
nbsphinx_execute = "never"
81+
82+
nbsphinx_execute_arguments = [
83+
"--InlineBackend.figure_formats={'png2x'}",
84+
"--InlineBackend.rc=figure.dpi=96",
85+
]
86+
87+
nbsphinx_kernel_name = "python3"
8688

8789
# HTML output configuration
8890
# -----------------------------------------------------------------------------

docs/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ datasets/greenland_arctic/index.md
7676
```{toctree}
7777
:maxdepth: 2
7878
:hidden:
79-
:caption: 📖 Reference documentation
80-
autoapi/polartoolkit/index
81-
changelog.md
82-
references.rst
79+
:caption: 📖 API
80+
api/polartoolkit
8381
```
8482

8583
```{toctree}
8684
:maxdepth: 1
8785
:hidden:
8886
:caption: ℹ️ Other resources
8987
contributing.md
88+
changelog.md
89+
references.rst
9090
Source code on GitHub <https://github.com/mdtanker/polartoolkit>
9191
```
9292

@@ -118,7 +118,7 @@ Start a discussion on GitHub!
118118
:::{grid-item-card} {octicon}`file-badge` Reference documentation
119119
:text-align: center
120120
A list of modules and functions
121-
```{button-ref} autoapi/polartoolkit/index
121+
```{button-ref} api/polartoolkit
122122
:click-parent:
123123
:color: primary
124124
:outline:

environment.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ dependencies:
2020
- deprecation
2121
- openpyxl
2222
- pyproj
23-
- geopandas>=1.0
23+
- geopandas>=1.0
2424
- pyogrio
25-
- zarr>=3.0
25+
- zarr>=3.0
2626
- python-dotenv
2727
- requests
2828
- earthaccess
@@ -47,7 +47,6 @@ dependencies:
4747
- ipykernel
4848
- nbconvert
4949
- sphinxcontrib-bibtex
50-
- sphinx-autoapi
5150
- sphinx-design
5251
# dev
5352
- jupyterlab

noxfile.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ def lint(session: nox.Session) -> None:
1818
"""
1919
session.install("pre-commit")
2020
session.run(
21-
"pre-commit",
22-
"run",
23-
"--all-files",
24-
"--show-diff-on-failure",
25-
*session.posargs,
21+
"pre-commit", "run", "--all-files", "--show-diff-on-failure", *session.posargs
2622
)
2723

2824

@@ -66,8 +62,7 @@ def tests(session: nox.Session) -> None:
6662
@nox.session(reuse_venv=True, default=False)
6763
def docs(session: nox.Session) -> None:
6864
"""
69-
Build the docs. Pass --non-interactive to avoid serving. First positional
70-
argument is the target directory.
65+
Build the docs. Pass --non-interactive to avoid serving. First positional argument is the target directory.
7166
"""
7267

7368
doc_deps = nox.project.dependency_groups(PROJECT, "docs")
@@ -96,6 +91,24 @@ def docs(session: nox.Session) -> None:
9691
session.run("sphinx-build", "--keep-going", *shared_args)
9792

9893

94+
@nox.session(default=False)
95+
def build_api_docs(session: nox.Session) -> None:
96+
"""
97+
Build (regenerate) API docs.
98+
"""
99+
100+
session.install("sphinx")
101+
session.run(
102+
"sphinx-apidoc",
103+
"-o",
104+
"docs/api/",
105+
"--module-first",
106+
"--no-toc",
107+
"--force",
108+
"src/polartoolkit",
109+
)
110+
111+
99112
@nox.session
100113
def build(session: nox.Session) -> None:
101114
"""

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ docs = [
8080
"ipykernel",
8181
"nbconvert",
8282
"sphinxcontrib-bibtex",
83-
"sphinx_autoapi",
8483
"sphinx_design",
8584
]
8685

0 commit comments

Comments
 (0)