Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stubs as Sphinx Archive #401

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,6 @@

# insert into PYTHONPATH
sys.path.insert(0, os.path.join(dst_path, ".."))

# make archive for download into apps like WarpX, ImpactX, ...
shutil.make_archive(dst_path, "zip", dst_path)
18 changes: 14 additions & 4 deletions docs/source/developers/documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ Documentation
Python API documentation
------------------------

to document:
.. note::

- Python doc style
- ``.pyi`` stub files generation & usage
- Sphinx autodocs/module used
TODO: document the Python doc style we use.

We add `docstrings for pybind11-created types and functions <https://pybind11.readthedocs.io/en/stable/basics.html#creating-bindings-for-a-simple-function>`__.
In order to retrieve those, one usually would need to build pyAMReX and have it available (installed) as a working Python import.
This build step can be complicated for building documentation and it does not work well with autocompletion in IPython.

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.
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.
A GitHub action then commits the updated stub files (``.pyi``) to the repository.

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>`__.
The logic for this resides in ``docs/source/conf.py``.
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.


Doxygen documentation (C++)
Expand Down
Loading