diff --git a/.readthedocs.yaml b/.readthedocs.yaml index f50da3627..aca0061d1 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -3,7 +3,10 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.10" + python: "3.11" + jobs: + pre_build: + - bash docs/scripts/api_build.sh sphinx: configuration: docs/conf.py diff --git a/docs/Makefile b/docs/Makefile index 6c0762a44..12f080733 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -19,4 +19,5 @@ help: # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile + bash $(SOURCEDIR)/scripts/api_build.sh @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/_templates/apidoc/package.rst.jinja b/docs/_templates/apidoc/package.rst.jinja new file mode 100644 index 000000000..dcafef589 --- /dev/null +++ b/docs/_templates/apidoc/package.rst.jinja @@ -0,0 +1,55 @@ +{%- macro automodule(modname, options) -%} +.. automodule:: {{ modname }} +{%- for option in options %} + :{{ option }}: +{%- endfor %} +{%- endmacro %} + +{%- macro toctree(docnames) -%} +.. toctree:: + :maxdepth: {{ maxdepth }} +{% for docname in docnames %} + {{ docname }} +{%- endfor %} +{%- endmacro %} + +{%- if is_namespace %} +{{- pkgname.split(".")[1:] | join(".") | e | heading }} +{% else %} +{{- pkgname.split(".")[1:] | join(" ") | e | heading }} +{% endif %} + +{%- if is_namespace %} +.. py:module:: {{ pkgname }} +{% endif %} + +{%- if modulefirst and not is_namespace %} +{{ automodule(["anemoi", pkgname] | join("."), [""]) }} +{% endif %} + +{%- if subpackages %} +Subpackages +----------- + +{{ toctree(subpackages) }} +{% endif %} + +{%- if submodules %} +{% if separatemodules %} +{{ toctree(submodules) }} +{% else %} +{%- for submodule in submodules %} +{% if show_headings %} +{{- submodule.split(".")[2:] | join(".") | e | heading(2) }} +{% endif %} +{{ automodule(["anemoi", submodule] | join("."), automodule_options) }} +{% endfor %} +{%- endif %} +{%- endif %} + +{%- if not modulefirst and not is_namespace %} +Module contents +--------------- + +{{ automodule(pkgname, automodule_options) }} +{% endif %} diff --git a/docs/modules/create.rst b/docs/modules/create.rst index 7ca890dc7..6b5a39b84 100644 --- a/docs/modules/create.rst +++ b/docs/modules/create.rst @@ -2,6 +2,10 @@ Create ######## +This module contains the neccessary functions to create a dataset. It +interfaces with the data on disk, and provides methods to prepare it for +use in Anemoi. + .. automodule:: anemoi.datasets.create :members: :no-undoc-members: diff --git a/docs/modules/data.rst b/docs/modules/data.rst index 8605eb9e3..5ae1dff88 100644 --- a/docs/modules/data.rst +++ b/docs/modules/data.rst @@ -4,12 +4,4 @@ Data ###### -.. automodule:: anemoi.datasets.data.__init__ - :members: - :no-undoc-members: - :show-inheritance: - -.. automodule:: anemoi.datasets.data.dataset - :members: - :no-undoc-members: - :show-inheritance: +.. include:: ../_api/datasets.data.rst diff --git a/docs/modules/filters.rst b/docs/modules/filters.rst new file mode 100644 index 000000000..98289c82d --- /dev/null +++ b/docs/modules/filters.rst @@ -0,0 +1,5 @@ +######### + Filters +######### + +.. include:: ../_api/datasets.create.filters.rst diff --git a/docs/modules/sources.rst b/docs/modules/sources.rst new file mode 100644 index 000000000..488db1924 --- /dev/null +++ b/docs/modules/sources.rst @@ -0,0 +1,5 @@ +######### + Sources +######### + +.. include:: ../_api/datasets.create.sources.rst diff --git a/docs/scripts/api_build.sh b/docs/scripts/api_build.sh new file mode 100644 index 000000000..04ac1a584 --- /dev/null +++ b/docs/scripts/api_build.sh @@ -0,0 +1,6 @@ + +script_dir=$(dirname "${BASH_SOURCE[0]}") +docs_dir="$script_dir/.." +source_dir="$script_dir/../../src/" + +sphinx-apidoc -M -f -o "$docs_dir/_api" "$source_dir/anemoi" -t "$docs_dir/_templates/apidoc" diff --git a/pyproject.toml b/pyproject.toml index a11359e8d..a3c4e816d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -77,6 +77,7 @@ optional-dependencies.dev = [ ] optional-dependencies.docs = [ + "anemoi-datasets[all]", "nbsphinx", "pandoc", "sphinx",