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

Show which examples use an object in the API documentation #683

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dist/

# autogenerated docs
_autosummary

_gallery_backreferences

# Testing
.coverage
Expand Down
2 changes: 1 addition & 1 deletion doc/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ goto end

:clean
rmdir /s /q %BUILDDIR% > /NUL 2>&1
for /d /r %SOURCEDIR% %%d in (_autosummary) do @if exist "%%d" rmdir /s /q "%%d"
for /d /r %SOURCEDIR% %%d in (_autosummary,_gallery_backreferences) do @if exist "%%d" rmdir /s /q "%%d"
rmdir /s /q %SOURCEDIR%\examples\gallery_examples
goto end

Expand Down
12 changes: 12 additions & 0 deletions doc/source/_templates/autosummary/base.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. vale off

{{ name | escape | underline}}

.. currentmodule:: {{ module }}

.. auto{{ objtype }}:: {{ objname }}

.. minigallery::
:add-heading: Examples using {{ objname }}

{{ module }}.{{ objname }}
39 changes: 39 additions & 0 deletions doc/source/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.. vale off

{{ objname | escape | underline}}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}

{% block methods %}

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

.. autosummary::
:toctree:
{% for item in methods %}
{% if item != "__init__" %}
{{ name }}.{{ item }}
{% endif %}
{%- endfor %}
{% endif %}
{% endblock %}

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

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

.. minigallery::
:add-heading: Examples using {{ objname }}

{{ module }}.{{ objname }}
14 changes: 14 additions & 0 deletions doc/source/_templates/autosummary/experimental/base.rst.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{ name | escape | underline}}

.. currentmodule:: {{ module }}

.. warning::

This is an experimental feature. The API is subject to change without notice.

.. auto{{ objtype }}:: {{ objname }}

.. minigallery::
:add-heading: Examples using {{ objname }}

{{ module }}.{{ objname }}
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@
{%- endfor %}
{% endif %}
{% endblock %}


.. minigallery::
:add-heading: Examples using {{ objname }}

{{ module }}.{{ objname }}
7 changes: 4 additions & 3 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,10 @@ def _signature(
# Sort gallery example by filename instead of number of lines (default)
"within_subsection_order": "FileNameSortKey",
# directory where function granular galleries are stored
"backreferences_dir": None,
# Modules for which function level galleries are created. In
"doc_module": "ansys-acp-core",
"backreferences_dir": "api/_gallery_backreferences",
# Modules for which function level galleries are created.
"doc_module": ("ansys.acp.core"),
"exclude_implicit_doc": {"ansys\\.acp\\.core\\._.*"}, # ignore private submodules
"image_scrapers": (DynamicScraper(), "matplotlib"),
"ignore_pattern": r"__init__\.py",
"thumbnail_size": (350, 350),
Expand Down