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

docs: Automatic Code Documentation #698

Merged
merged 30 commits into from Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
58fc26f
docs: automatic generation of code documentation
victorgarcia98 May 24, 2023
51b4f7c
docs: class and module templates
victorgarcia98 May 24, 2023
0010661
fix: simplify generated docs
victorgarcia98 May 24, 2023
1c0ddbc
feat: switch on/off generation of code docs via the parameter gen_cod…
victorgarcia98 May 24, 2023
4e22c78
add docstrings for main modules
nhoening May 26, 2023
a1c64a5
Add docstrings to API modules
nhoening May 26, 2023
7486a87
fix: add autodoc and autosmmary when GEN_CODE_DOCS=True
victorgarcia98 May 29, 2023
7eb4771
fix: set gen_code_docs default to True and False for devs (calling up…
victorgarcia98 May 29, 2023
93c502e
Merge branch 'main' into 52-incomplete-documentation-of-internal-modules
victorgarcia98 May 29, 2023
dc7bf84
Merge branch 'main' into 52-incomplete-documentation-of-internal-modules
victorgarcia98 May 30, 2023
5dba038
move single test from config package into new tests package
nhoening Jun 6, 2023
76c7315
fix: show main modules
victorgarcia98 Jun 7, 2023
6f67b12
fix: remove documentation/_autosummary when gen_code_docs=False
victorgarcia98 Jun 7, 2023
a557df2
fix: make generated rst to live under _autosummary/ folder
victorgarcia98 Jun 7, 2023
a49ae85
add autosummary folder to .gitignore
nhoening Jun 7, 2023
8d7ff4a
add some spellright words
nhoening Jun 7, 2023
a569f3f
try setting FLASK_ENV during RTD building
nhoening Jun 7, 2023
7dadf17
fix: set a fake SQLALCHEMY_DATABASE_URI
victorgarcia98 Jun 7, 2023
fbb5a4f
Merge remote-tracking branch 'origin/52-incomplete-documentation-of-i…
victorgarcia98 Jun 7, 2023
36b47ea
no need to look for config file when building documentation
nhoening Jun 7, 2023
72747a6
Merge branch '52-incomplete-documentation-of-internal-modules' of git…
nhoening Jun 7, 2023
94a00e2
also export SECRET_KEY in RTD
nhoening Jun 7, 2023
cb6d9e8
test add SECRET_KEY
victorgarcia98 Jun 7, 2023
b66ca03
Merge remote-tracking branch 'origin/52-incomplete-documentation-of-i…
victorgarcia98 Jun 7, 2023
23b5595
docs: add private methods
victorgarcia98 Jun 7, 2023
777ee3f
test only with env variables set in conf.py
victorgarcia98 Jun 8, 2023
f0720ce
test
victorgarcia98 Jun 8, 2023
e0c6373
fix: remove exports
victorgarcia98 Jun 8, 2023
78724fa
re-do a change to a comment that is by now inaccurate and improve the…
nhoening Jun 9, 2023
1bfcf83
Merge branch 'main' into 52-incomplete-documentation-of-internal-modules
nhoening Jun 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions documentation/_templates/custom-class-template.rst
@@ -0,0 +1,34 @@
.. Adapted from https://stackoverflow.com/a/62613202

{{ fullname | escape | underline}}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:members:
:show-inheritance:
:inherited-members:

{% block methods %}
.. automethod:: __init__

{% if methods %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
{% for item in methods %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}

.. autosummary::
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
69 changes: 69 additions & 0 deletions documentation/_templates/custom-module-template.rst
@@ -0,0 +1,69 @@
.. Adapted from https://stackoverflow.com/a/62613202
{{ fullname | escape | underline}}

{% block modules %}
{% if modules %}
.. rubric:: Modules

.. autosummary::
:toctree:
:template: custom-module-template.rst
:recursive:
{% for item in modules %}
{% if "test" not in item %}
{{ item }}
{% endif %}
{%- endfor %}
{% endif %}
{% endblock %}

.. automodule:: {{ fullname }}

{% block attributes %}
{% if attributes %}
.. rubric:: Module Attributes

.. autosummary::
:toctree:
{% for item in attributes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block functions %}
{% if functions %}
.. rubric:: {{ _('Functions') }}

.. autosummary::
:toctree:
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block classes %}
{% if classes %}
.. rubric:: {{ _('Classes') }}

.. autosummary::
:toctree:
:template: custom-class-template.rst
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block exceptions %}
{% if exceptions %}
.. rubric:: {{ _('Exceptions') }}

.. autosummary::
:toctree:
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
11 changes: 11 additions & 0 deletions documentation/conf.py
Expand Up @@ -52,11 +52,18 @@
"sphinx_fontawesome",
"sphinxcontrib.autohttp.flask",
"sphinxcontrib.autohttp.flaskqref",
"sphinx.ext.autosummary",
"sphinx.ext.autodoc.typehints",
]

autodoc_default_options = {"members": True, "inherited-members": True}

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# generate autosummary even if no references
victorgarcia98 marked this conversation as resolved.
Show resolved Hide resolved
autosummary_generate = True

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
Expand Down Expand Up @@ -224,3 +231,7 @@ def setup(sphinx_app):
"live",
"env", # hard-coded, documentation is not server-specific for the time being
)

from flexmeasures.app import create

create() # we need to create the app for when sphinx imports modules that use current_app
14 changes: 11 additions & 3 deletions documentation/index.rst
Expand Up @@ -249,11 +249,19 @@ The platform operator of FlexMeasures can be an Aggregator.
dev/docker-compose


.. autosummary::
:caption: Code Documentation
:toctree: _autosummary
:template: custom-module-template.rst
:recursive:

Code documentation
------------------
flexmeasures

Go To :ref:`source`.

.. Code documentation
.. ------------------

.. Go To :ref:`source`.



Expand Down
78 changes: 0 additions & 78 deletions documentation/source.rst

This file was deleted.