Skip to content

Commit 45ff86c

Browse files
authored
Stubs as Sphinx Archive (#401)
Zip up our stub files, so we can reuse them in WarpX/ImpactX/... Sphinx doc builds.
1 parent 84e8125 commit 45ff86c

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

docs/source/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,6 @@
225225

226226
# insert into PYTHONPATH
227227
sys.path.insert(0, os.path.join(dst_path, ".."))
228+
229+
# make archive for download into apps like WarpX, ImpactX, ...
230+
shutil.make_archive(dst_path, "zip", dst_path)

docs/source/developers/documentation.rst

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@ Documentation
66
Python API documentation
77
------------------------
88

9-
to document:
9+
.. note::
1010

11-
- Python doc style
12-
- ``.pyi`` stub files generation & usage
13-
- Sphinx autodocs/module used
11+
TODO: document the Python doc style we use.
12+
13+
We add `docstrings for pybind11-created types and functions <https://pybind11.readthedocs.io/en/stable/basics.html#creating-bindings-for-a-simple-function>`__.
14+
In order to retrieve those, one usually would need to build pyAMReX and have it available (installed) as a working Python import.
15+
This build step can be complicated for building documentation and it does not work well with autocompletion in IPython.
16+
17+
Thus, on every merge to the mainline ``development`` branch, we build pyAMReX and create "stub" (interface/facade) files that carry all type information and doc strings.
18+
We do this by building pyAMReX and running the script ``.github/update_stub.sh``, which uses `pybind11-stubgen <https://github.com/sizmailov/pybind11-stubgen>`__ to extract these information.
19+
A GitHub action then commits the updated stub files (``.pyi``) to the repository.
20+
21+
When we build our Sphinx documentation, we copy the ``.pyi`` files and generate documentation of classes and functions via `autodoc <https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html>`__.
22+
The logic for this resides in ``docs/source/conf.py``.
23+
We also provide a zip archive online under https://pyamrex.readthedocs.io/en/latest/_static/pyapi/amrex.zip that can be downloaded by dependent projects that build their Sphinx docs.
1424

1525

1626
Doxygen documentation (C++)

0 commit comments

Comments
 (0)