Skip to content

Commit 570c382

Browse files
committed
Merge branch 'doc_sphinx' into 'main'
Improve API documentation See merge request campus/lenapy!12
2 parents b6c4906 + e5ad467 commit 570c382

23 files changed

Lines changed: 422 additions & 316 deletions

.readthedocs.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ sphinx:
3030
# Optional but recommended, declare the Python requirements required
3131
# to build your documentation
3232
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
33-
python:
34-
install:
35-
- requirements: doc/requirements.txt
36-
3733
conda:
3834
environment: doc/environment.yml
35+
python:
36+
install:
37+
- method: pip
38+
path: .
File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{ fullname }}
2+
{{ underline }}
3+
4+
5+
.. automodule:: {{ fullname }}
6+
:members:
7+
:undoc-members:
8+
:show-inheritance:

doc/api.rst

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

doc/api/index.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
lenapy API Reference
2+
====================
3+
4+
Module contents
5+
~~~~~~~~~~~~~~~
6+
7+
.. autosummary::
8+
:toctree: _autosummary
9+
10+
lenapy.lenapy_geo
11+
lenapy.lenapy_time
12+
lenapy.lenapy_ocean
13+
lenapy.lenapy_harmo
14+
lenapy.constants
15+
16+
Submodules
17+
~~~~~~~~~~
18+
19+
Readers
20+
*******
21+
22+
Reader modules : define specific engines for the xarray.open_dataset() method
23+
24+
.. autosummary::
25+
:toctree: _autosummary
26+
27+
lenapy.readers.geo_reader
28+
lenapy.readers.gravi_reader
29+
lenapy.readers.ocean
30+
31+
Utils
32+
*****
33+
34+
Utils modules
35+
36+
.. autosummary::
37+
:toctree: _autosummary
38+
39+
lenapy.utils.harmo
40+
lenapy.utils.gravity
41+
42+
Writers
43+
*******
44+
45+
Writer modules : define writers
46+
47+
.. autosummary::
48+
:toctree: _autosummary
49+
50+
lenapy.writers.gravi_writer

doc/changelog.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.. mdinclude:: CHANGELOG.md
1+
.. _changes:
2+
.. mdinclude:: ../CHANGELOG.md

doc/conf.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44
# https://www.sphinx-doc.org/en/master/usage/configuration.html
55

66
import datetime
7+
import inspect
78
import os
89
import sys
910

11+
__location__ = os.path.join(
12+
os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe()))
13+
)
14+
1015
sys.path.insert(0, os.path.abspath(".."))
1116
sys.path.insert(0, os.path.abspath("../lenapy"))
17+
sys.path.insert(0, os.path.join(__location__, "../lenapy"))
1218

1319
# -- Project information -----------------------------------------------------
1420
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
@@ -46,6 +52,7 @@
4652
autoclass_content = "both"
4753
# sort class members by their order in the source
4854
autodoc_member_order = "bysource"
55+
autodoc_typehints = "both"
4956

5057
# show all members of a class in the Methods and Attributes sections automatically
5158
numpydoc_show_class_members = True
@@ -66,17 +73,16 @@
6673
html_theme = "sphinx_rtd_theme"
6774
html_theme_options = {
6875
"logo_only": False,
69-
"display_version": True,
7076
"prev_next_buttons_location": "both",
7177
"collapse_navigation": False,
7278
"sticky_navigation": True,
73-
"navigation_depth": 4,
79+
"navigation_depth": 3,
7480
"includehidden": True,
7581
"titles_only": False,
7682
"style_nav_header_background": "#2980B9", # header color en haut à gauche
7783
# github_url for open access version
7884
}
79-
html_static_path = ["_static"]
85+
# html_static_path = ["_static"]
8086

8187
# Example configuration for intersphinx: refer to the Python standard library.
8288
intersphinx_mapping = {
@@ -94,3 +100,4 @@
94100
# See also:
95101
# https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#confval-intersphinx_disabled_reftypes
96102
intersphinx_disabled_reftypes = ["*"]
103+
templates_path = [".templates"]

doc/contributing.rst

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
Contributing
2+
============
3+
4+
Thanks for helping to build lenapy!
5+
6+
Retrieve the code: forking and cloning the Repository
7+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8+
9+
Make a fork of the `lenapy repo <https://github.com/CNES/lenapy>`__ and clone
10+
the fork.
11+
12+
A documentation is available on GitHub to help platform users create a fork: `https://docs.github.com/fork-a-repo <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo>`__
13+
14+
.. code-block:: none
15+
16+
git clone https://github.com/<your-github-username>/lenapy.git
17+
cd lenapy
18+
19+
You may want to add ``https://github.com/CNES/lenapy`` as an upstream remote
20+
repository.
21+
22+
.. code-block:: none
23+
24+
git remote add upstream https://github.com/CNES/lenapy
25+
26+
Creating a Python environment
27+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28+
29+
We have conda environment YAML file with all the necessary dependencies.
30+
31+
.. code-block:: none
32+
33+
conda env create -f environment.yml --name=lenapy-dev
34+
35+
to create a conda environment and install all the dependencies.
36+
37+
Building lenapy
38+
~~~~~~~~~~~~~~~
39+
40+
Lenapy is a pure-python repository. Development installation should be as simple as
41+
cloning the repository and running the following in the cloned directory:
42+
43+
.. code-block:: none
44+
45+
conda activate lenapy-dev
46+
python -m pip install --no-deps -e .
47+
48+
If you have any trouble, please open an issue on the
49+
`lenapy issue tracker <https://github.com/CNES/lenapy/issues>`_.
50+
51+
Style
52+
~~~~~
53+
54+
Lenapy uses `black <http://black.readthedocs.io/en/stable/>`_ and `isort <https://isort.readthedocs.io/en/latest/>`_
55+
for formatting. If you installed lenapy with ``python -m pip install -e ".[dev]"`` these tools will already be
56+
installed.
57+
58+
Running tests
59+
~~~~~~~~~~~~~
60+
61+
Lenapy uses `pytest <https://docs.pytest.org/en/latest/>`_ for testing. You
62+
can run tests from the main lenapy directory as follows:
63+
64+
.. code-block:: none
65+
66+
pytest tests
67+
68+
Alternatively you may choose to run only a subset of the full test suite. For
69+
example to test only the `writers` submodule we would run tests as follows:
70+
71+
.. code-block:: none
72+
73+
pytest tests/writers
74+
75+
Coverage
76+
~~~~~~~~
77+
78+
It is possible to check code coverage
79+
80+
.. code-block:: none
81+
82+
pytest --cov=lenapy --cov-report=html
83+
84+
You can still use all the usual pytest command-line options in addition to those.
85+
86+
Pre-Commit Hooks
87+
~~~~~~~~~~~~~~~~
88+
89+
Install and build the `pre commit <https://github.com/pre-commit/pre-commit>`_ tool as:
90+
91+
.. code-block:: none
92+
93+
python -m pip install -e ".[dev]"
94+
pre-commit install
95+
96+
to install a few plugins like black, isort, and pylint. These tools will automatically
97+
be run on each commit. You can skip the checks with ``git commit --no-verify``.
98+
99+
Documentation
100+
~~~~~~~~~~~~~
101+
102+
We use `numpydoc <http://numpydoc.readthedocs.io/en/latest/format.html>`_ for our docstrings.
103+
104+
Building the docs is possible with
105+
106+
.. code-block:: none
107+
108+
$ conda env create -f environment.yml --name=lenapy-dev
109+
$ conda activate lenapy-dev
110+
$ python -m pip install -e ".[dev]"
111+
$ cd doc
112+
$ sphinx-build -b html doc doc/build

doc/environment.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ channels:
66
dependencies:
77
- python=3.11
88
- esmpy>=8.4.0
9+
- gsw>=3.6.16
910
- pip>=20.1 # pip is needed as dependency
10-
- pip:
11-
- sphinx_rtd_theme
12-
- sphinx-mdinclude
13-
- nbsphinx
14-
- matplotlib>=3.6
15-
- xarray>=2024.2
16-
- gsw>=3.6.16
17-
- netCDF4>=1.6.5
18-
- pyyaml>=6.0
19-
- dask>=2023.6
20-
- xesmf>=0.8.2
11+
- sphinx_rtd_theme
12+
- sphinx-mdinclude
13+
- nbsphinx
14+
- matplotlib>=3.6
15+
- xarray>=2024.2
16+
- netCDF4>=1.6.5
17+
- pyyaml>=6.0
18+
- dask>=2023.6
19+
- xesmf>=0.8.2
20+
- cf_xarray
21+
- pandas
22+
- scipy
23+
2124

doc/index.rst

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,13 @@ This library is based on the principle of class extension, i.e. functions can be
1818
Reading interfaces are implemented, enabling netcdf files to be opened with a compatible formalism from the **lenapy** library.
1919

2020
.. toctree::
21-
:maxdepth: 4
21+
:maxdepth: 1
2222
:caption: Contents:
23-
24-
changelog
23+
:hidden:
24+
2525
gettingStarted
26-
api
26+
Changelog <changelog>
2727
tutorials
28-
29-
30-
31-
Indices and tables
32-
==================
33-
34-
* :ref:`genindex`
35-
* :ref:`modindex`
36-
* :ref:`search`
28+
lenapy API Reference <api/index>
29+
How to contribute <contributing>
30+
Release procedure <release_procedure>

0 commit comments

Comments
 (0)