Skip to content

Commit

Permalink
#14 updated configuration to use autoapi
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelweinold committed Nov 30, 2022
1 parent ce14a5a commit d3f3278
Show file tree
Hide file tree
Showing 276 changed files with 26,265 additions and 9,592 deletions.
1 change: 1 addition & 0 deletions setup/conda_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ dependencies:
- sphinx-gallery # support for a specific part of the website theme
- myst-parser # Markdown support
- sphinx-autobuild # live-html support
- sphinx-autoapi # to build docs from source code instead of package import
# pip packages
- pip
3 changes: 2 additions & 1 deletion setup/pip_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ ipython
nbsphinx
sphinx-gallery
pydata-sphinx-theme
myst-parser
myst-parser
sphinx-autoapi
15 changes: 15 additions & 0 deletions sphinx/_autoapi_templates/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
API Reference
=============

This page contains auto-generated API reference documentation [#f1]_.

.. toctree::
:titlesonly:

{% for page in pages %}
{% if page.top_level_object and page.display %}
{{ page.include_path }}
{% endif %}
{% endfor %}

.. [#f1] Created with `sphinx-autoapi <https://github.com/readthedocs/sphinx-autoapi>`_
1 change: 1 addition & 0 deletions sphinx/_autoapi_templates/python/attribute.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends "python/data.rst" %}
58 changes: 58 additions & 0 deletions sphinx/_autoapi_templates/python/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{% if obj.display %}
.. py:{{ obj.type }}:: {{ obj.short_name }}{% if obj.args %}({{ obj.args }}){% endif %}
{% for (args, return_annotation) in obj.overloads %}
{{ " " * (obj.type | length) }} {{ obj.short_name }}{% if args %}({{ args }}){% endif %}
{% endfor %}


{% if obj.bases %}
{% if "show-inheritance" in autoapi_options %}
Bases: {% for base in obj.bases %}{{ base|link_objs }}{% if not loop.last %}, {% endif %}{% endfor %}
{% endif %}


{% if "show-inheritance-diagram" in autoapi_options and obj.bases != ["object"] %}
.. autoapi-inheritance-diagram:: {{ obj.obj["full_name"] }}
:parts: 1
{% if "private-members" in autoapi_options %}
:private-bases:
{% endif %}

{% endif %}
{% endif %}
{% if obj.docstring %}
{{ obj.docstring|indent(3) }}
{% endif %}
{% if "inherited-members" in autoapi_options %}
{% set visible_classes = obj.classes|selectattr("display")|list %}
{% else %}
{% set visible_classes = obj.classes|rejectattr("inherited")|selectattr("display")|list %}
{% endif %}
{% for klass in visible_classes %}
{{ klass.render()|indent(3) }}
{% endfor %}
{% if "inherited-members" in autoapi_options %}
{% set visible_properties = obj.properties|selectattr("display")|list %}
{% else %}
{% set visible_properties = obj.properties|rejectattr("inherited")|selectattr("display")|list %}
{% endif %}
{% for property in visible_properties %}
{{ property.render()|indent(3) }}
{% endfor %}
{% if "inherited-members" in autoapi_options %}
{% set visible_attributes = obj.attributes|selectattr("display")|list %}
{% else %}
{% set visible_attributes = obj.attributes|rejectattr("inherited")|selectattr("display")|list %}
{% endif %}
{% for attribute in visible_attributes %}
{{ attribute.render()|indent(3) }}
{% endfor %}
{% if "inherited-members" in autoapi_options %}
{% set visible_methods = obj.methods|selectattr("display")|list %}
{% else %}
{% set visible_methods = obj.methods|rejectattr("inherited")|selectattr("display")|list %}
{% endif %}
{% for method in visible_methods %}
{{ method.render()|indent(3) }}
{% endfor %}
{% endif %}
32 changes: 32 additions & 0 deletions sphinx/_autoapi_templates/python/data.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% if obj.display %}
.. py:{{ obj.type }}:: {{ obj.name }}
{%+ if obj.value is not none or obj.annotation is not none -%}
:annotation:
{%- if obj.annotation %} :{{ obj.annotation }}
{%- endif %}
{%- if obj.value is not none %} = {%
if obj.value is string and obj.value.splitlines()|count > 1 -%}
Multiline-String

.. raw:: html

<details><summary>Show Value</summary>

.. code-block:: text
:linenos:
{{ obj.value|indent(width=8) }}
.. raw:: html

</details>

{%- else -%}
{{ obj.value|string|truncate(100) }}
{%- endif %}
{%- endif %}
{% endif %}


{{ obj.docstring|indent(3) }}
{% endif %}
1 change: 1 addition & 0 deletions sphinx/_autoapi_templates/python/exception.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends "python/class.rst" %}
15 changes: 15 additions & 0 deletions sphinx/_autoapi_templates/python/function.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% if obj.display %}
.. py:function:: {{ obj.short_name }}({{ obj.args }}){% if obj.return_annotation is not none %} -> {{ obj.return_annotation }}{% endif %}
{% for (args, return_annotation) in obj.overloads %}
{{ obj.short_name }}({{ args }}){% if return_annotation is not none %} -> {{ return_annotation }}{% endif %}

{% endfor %}
{% for property in obj.properties %}
:{{ property }}:
{% endfor %}

{% if obj.docstring %}
{{ obj.docstring|indent(3) }}
{% endif %}
{% endif %}
19 changes: 19 additions & 0 deletions sphinx/_autoapi_templates/python/method.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{%- if obj.display %}
.. py:method:: {{ obj.short_name }}({{ obj.args }}){% if obj.return_annotation is not none %} -> {{ obj.return_annotation }}{% endif %}
{% for (args, return_annotation) in obj.overloads %}
{{ obj.short_name }}({{ args }}){% if return_annotation is not none %} -> {{ return_annotation }}{% endif %}

{% endfor %}
{% if obj.properties %}
{% for property in obj.properties %}
:{{ property }}:
{% endfor %}

{% else %}

{% endif %}
{% if obj.docstring %}
{{ obj.docstring|indent(3) }}
{% endif %}
{% endif %}
114 changes: 114 additions & 0 deletions sphinx/_autoapi_templates/python/module.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{% if not obj.display %}
:orphan:

{% endif %}
:py:mod:`{{ obj.name }}`
=========={{ "=" * obj.name|length }}

.. py:module:: {{ obj.name }}
{% if obj.docstring %}
.. autoapi-nested-parse::

{{ obj.docstring|indent(3) }}

{% endif %}

{% block subpackages %}
{% set visible_subpackages = obj.subpackages|selectattr("display")|list %}
{% if visible_subpackages %}
Subpackages
-----------
.. toctree::
:titlesonly:
:maxdepth: 3

{% for subpackage in visible_subpackages %}
{{ subpackage.short_name }}/index.rst
{% endfor %}


{% endif %}
{% endblock %}
{% block submodules %}
{% set visible_submodules = obj.submodules|selectattr("display")|list %}
{% if visible_submodules %}
Submodules
----------
.. toctree::
:titlesonly:
:maxdepth: 1

{% for submodule in visible_submodules %}
{{ submodule.short_name }}/index.rst
{% endfor %}


{% endif %}
{% endblock %}
{% block content %}
{% if obj.all is not none %}
{% set visible_children = obj.children|selectattr("short_name", "in", obj.all)|list %}
{% elif obj.type is equalto("package") %}
{% set visible_children = obj.children|selectattr("display")|list %}
{% else %}
{% set visible_children = obj.children|selectattr("display")|rejectattr("imported")|list %}
{% endif %}
{% if visible_children %}
{{ obj.type|title }} Contents
{{ "-" * obj.type|length }}---------

{% set visible_classes = visible_children|selectattr("type", "equalto", "class")|list %}
{% set visible_functions = visible_children|selectattr("type", "equalto", "function")|list %}
{% set visible_attributes = visible_children|selectattr("type", "equalto", "data")|list %}
{% if "show-module-summary" in autoapi_options and (visible_classes or visible_functions) %}
{% block classes scoped %}
{% if visible_classes %}
Classes
~~~~~~~

.. autoapisummary::

{% for klass in visible_classes %}
{{ klass.id }}
{% endfor %}


{% endif %}
{% endblock %}

{% block functions scoped %}
{% if visible_functions %}
Functions
~~~~~~~~~

.. autoapisummary::

{% for function in visible_functions %}
{{ function.id }}
{% endfor %}


{% endif %}
{% endblock %}

{% block attributes scoped %}
{% if visible_attributes %}
Attributes
~~~~~~~~~~

.. autoapisummary::

{% for attribute in visible_attributes %}
{{ attribute.id }}
{% endfor %}


{% endif %}
{% endblock %}
{% endif %}
{% for obj_item in visible_children %}
{{ obj_item.render()|indent(0) }}
{% endfor %}
{% endif %}
{% endblock %}
1 change: 1 addition & 0 deletions sphinx/_autoapi_templates/python/package.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends "python/module.rst" %}
15 changes: 15 additions & 0 deletions sphinx/_autoapi_templates/python/property.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{%- if obj.display %}
.. py:property:: {{ obj.short_name }}
{% if obj.annotation %}
:type: {{ obj.annotation }}
{% endif %}
{% if obj.properties %}
{% for property in obj.properties %}
:{{ property }}:
{% endfor %}
{% endif %}

{% if obj.docstring %}
{{ obj.docstring|indent(3) }}
{% endif %}
{% endif %}
18 changes: 14 additions & 4 deletions sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,35 @@
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.mathjax',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
'sphinx.ext.intersphinx',
'sphinx.ext.extlinks',
'sphinx.ext.napoleon',
'sphinx.ext.autosummary',
'IPython.sphinxext.ipython_directive',
'IPython.sphinxext.ipython_console_highlighting',
'sphinx.ext.doctest',
'nbsphinx',
'sphinx_gallery.load_style',
'myst_parser'
'myst_parser',
'autoapi'
]

templates_path = ['source/_templates']
html_static_path = ["source/_static"]
exclude_patterns = ['_build']

autoapi_dirs = [
'../brightway2-analyzer',
'../brightway2-calc',
'../brightway2-data',
'../brightway2-io',
'../brightway2-regional'
]

autoapi_template_dir = '_autoapi_templates'
autoapi_root = 'technical/api'

# The suffix of source filenames.
source_suffix = {
'.rst': 'restructuredtext',
Expand Down
44 changes: 0 additions & 44 deletions sphinx/source/reference/bw2analyzer.rst

This file was deleted.

Loading

0 comments on commit d3f3278

Please sign in to comment.