From 23bb8e74b5f77f97feaa19fd3bf8ec93cd9d276b Mon Sep 17 00:00:00 2001 From: codingfabi Date: Sun, 5 May 2024 11:06:22 +0200 Subject: [PATCH] add autosummary documentation --- docs/_templates/autosummary/class.rst | 19 +++++++++++++++++++ docs/_templates/autosummary/function.rst | 3 +++ docs/api.rst | 8 ++++++++ docs/commuting.rst | 9 --------- docs/conf.py | 4 ++++ docs/index.rst | 2 +- 6 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 docs/_templates/autosummary/class.rst create mode 100644 docs/_templates/autosummary/function.rst create mode 100644 docs/api.rst diff --git a/docs/_templates/autosummary/class.rst b/docs/_templates/autosummary/class.rst new file mode 100644 index 0000000..84571d7 --- /dev/null +++ b/docs/_templates/autosummary/class.rst @@ -0,0 +1,19 @@ +{{ fullname | escape | underline}} + +{{ module }} + +{{ objname }} + +{% block attributes %} {% if attributes %} .. rubric:: Attributes + +{% for item in attributes %} +~{{ fullname }}.{{ item }} + +{%- endfor %} {% endif %} {% endblock %} + +{% block methods %} {% if methods %} .. rubric:: Methods + +{% for item in methods %} +{%- if item != '__init__' %} ~{{ fullname }}.{{ item }} {%- endif -%} + +{%- endfor %} {% endif %} {% endblock %} diff --git a/docs/_templates/autosummary/function.rst b/docs/_templates/autosummary/function.rst new file mode 100644 index 0000000..b877145 --- /dev/null +++ b/docs/_templates/autosummary/function.rst @@ -0,0 +1,3 @@ +{{ fullname | escape | underline}} + +{{ module }} diff --git a/docs/api.rst b/docs/api.rst new file mode 100644 index 0000000..bb786dd --- /dev/null +++ b/docs/api.rst @@ -0,0 +1,8 @@ +API Docs +======== + +.. autosummary:: + :toctree: generated + :recursive: + + co2calculator diff --git a/docs/commuting.rst b/docs/commuting.rst index d42482b..fd3dcfa 100644 --- a/docs/commuting.rst +++ b/docs/commuting.rst @@ -53,12 +53,3 @@ motorbike. Tram, bicycle or pedelec commute -------------------------------- For tram, bicylce or pedelec, no specifica have to be provided. - - -Aggregating emissions to the group level ----------------------------------------- -If it can be assumed that a representative sample (``n_participants``) of the entire group (``n_members``) have entered -their commuting data, an estimate of the commuting emissions for the entire group can be obtained using the following -function: - -.. autofunction:: co2calculator.calculate.commuting_emissions_group diff --git a/docs/conf.py b/docs/conf.py index 3f1f4ce..6aa7ff8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -43,12 +43,16 @@ "sphinx.ext.napoleon", "sphinx.ext.autosectionlabel", "sphinx.ext.viewcode", + "sphinx.ext.autosummary", "myst_parser", ] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] +# generate autosummary +autosummary_generate = True + # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. diff --git a/docs/index.rst b/docs/index.rst index 5abad77..28021d5 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -24,7 +24,7 @@ Contents calculate/heating_electricity calculate/emission_factors calculate/transport_modes - + api Indices and tables ==================