From 9888fb1e83251796c17dcb8aad973c43d10f4612 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Sat, 4 May 2024 12:13:08 -0500 Subject: [PATCH] Add autodoc --- docs/_config.yml | 13 ++++- docs/_templates/custom-class-template.rst | 32 +++++++++++ docs/_templates/custom-module-template.rst | 66 ++++++++++++++++++++++ docs/_toc.yml | 3 +- docs/api.rst | 11 ++++ 5 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 docs/_templates/custom-class-template.rst create mode 100644 docs/_templates/custom-module-template.rst create mode 100644 docs/api.rst diff --git a/docs/_config.yml b/docs/_config.yml index 6cff8b60..9b6f0348 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -11,4 +11,15 @@ repository: launch_buttons: notebook_interface : jupyterlab - binderhub_url : https://mybinder.org \ No newline at end of file + binderhub_url : https://mybinder.org + +sphinx: + extra_extensions: + - 'sphinx.ext.autodoc' + - 'sphinx.ext.napoleon' + - 'sphinx.ext.viewcode' + - 'sphinx.ext.autodoc' + - 'sphinx.ext.autosummary' + config: + autosummary_generate: True + templates_path: ['_templates'] \ No newline at end of file diff --git a/docs/_templates/custom-class-template.rst b/docs/_templates/custom-class-template.rst new file mode 100644 index 00000000..16ebb2f3 --- /dev/null +++ b/docs/_templates/custom-class-template.rst @@ -0,0 +1,32 @@ +{{ 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 %} \ No newline at end of file diff --git a/docs/_templates/custom-module-template.rst b/docs/_templates/custom-module-template.rst new file mode 100644 index 00000000..74078355 --- /dev/null +++ b/docs/_templates/custom-module-template.rst @@ -0,0 +1,66 @@ +{{ fullname | escape | underline}} + +.. 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 %} + +{% block modules %} +{% if modules %} +.. rubric:: Modules + +.. autosummary:: + :toctree: + :template: custom-module-template.rst + :recursive: +{% for item in modules %} + {{ item }} +{%- endfor %} +{% endif %} +{% endblock %} \ No newline at end of file diff --git a/docs/_toc.yml b/docs/_toc.yml index 208a1dec..b8d46617 100644 --- a/docs/_toc.yml +++ b/docs/_toc.yml @@ -9,4 +9,5 @@ chapters: - file: bulk_modulus_with_gpaw.ipynb - file: thermal_expansion_with_lammps.ipynb - file: free_energy_calculation.ipynb - - file: phasediagram.md \ No newline at end of file + - file: phasediagram.md +- file: api.rst \ No newline at end of file diff --git a/docs/api.rst b/docs/api.rst new file mode 100644 index 00000000..042824ad --- /dev/null +++ b/docs/api.rst @@ -0,0 +1,11 @@ +Interface +========= + +Documentation of the classes and functions defined in the :code:`atomistics` package. + +.. autosummary:: + :toctree: _autosummary + :template: custom-module-template.rst + :recursive: + + atomistics \ No newline at end of file