From a48eb0c9566f3acb207b5cc49adad012b48d0a7f Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Sat, 4 May 2024 12:10:04 -0500 Subject: [PATCH 1/2] 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 22ee034..4197611 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 0000000..16ebb2f --- /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 0000000..7407835 --- /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 26b947c..9634b6a 100644 --- a/docs/_toc.yml +++ b/docs/_toc.yml @@ -6,4 +6,5 @@ chapters: - file: example.ipynb - file: command.md - file: advanced.md -- file: debug.md \ No newline at end of file +- file: debug.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 0000000..717074c --- /dev/null +++ b/docs/api.rst @@ -0,0 +1,11 @@ +Interface +========= + +Documentation of the classes and functions defined in the :code:`pysqa` package. + +.. autosummary:: + :toctree: _autosummary + :template: custom-module-template.rst + :recursive: + + pympipool \ No newline at end of file From d39ca591427869c34c2171535559207609f448b7 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Sat, 4 May 2024 12:11:34 -0500 Subject: [PATCH 2/2] Update api.rst --- docs/api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api.rst b/docs/api.rst index 717074c..5e350dc 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -8,4 +8,4 @@ Documentation of the classes and functions defined in the :code:`pysqa` package. :template: custom-module-template.rst :recursive: - pympipool \ No newline at end of file + pysqa