Skip to content

Commit

Permalink
DOC: document all default templates (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw authored Jan 10, 2024
1 parent 4d63ee5 commit 08b8b6f
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,23 @@ to specify how classes are rendered.
You will need to add ``templates_path = ["_templates"]``
to your sphinx_ config file
(e.g. ``docs/conf.py``).

Inside the template you can access the ``apipages_hidden_methods`` list
by ``hidden_methods``.
The default template for classes is:

.. code-block:: rst
The default templates for classes is ``autosummary/class.rst``:

.. literalinclude:: ../sphinx_apipages/templates/autosummary/class.rst
:language: rst

{{ objname | escape | underline}}
The default template for functions is ``autosummary/function.rst``:

.. currentmodule:: {{ module }}
.. literalinclude:: ../sphinx_apipages/templates/autosummary/function.rst
:language: rst

.. autoclass:: {{ objname }}
The default template otherwise is ``autosummary/base.rst``:

{% block methods %}
{%- for item in (all_methods + attributes)|sort %}
{%- if not item.startswith('_') or item in hidden_methods %}
{%- if item in all_methods %}
{{ (item + '()') | escape | underline(line='-') }}
.. automethod:: {{ name }}.{{ item }}
{%- elif item in attributes %}
{{ item | escape | underline(line='-') }}
.. autoattribute:: {{ name }}.{{ item }}
{%- endif %}
{% endif %}
{%- endfor %}
{% endblock %}
.. literalinclude:: ../sphinx_apipages/templates/autosummary/base.rst
:language: rst


.. _sphinx: https://www.sphinx-doc.org
Expand Down

0 comments on commit 08b8b6f

Please sign in to comment.