-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add get_members function to apidoc templates
The `module.rst_t` and `package.rst_t` templates used by apidoc now have a `get_members` function that allows to obtain the member of the current module or package in various forms and filtered by "type" (exception, class, function, data). This provides a powerful mechanism for writing more advanced templates. Specifically, it allows to generate structured summaries of the contents of a module, preceding the detailed `automodule` references. See https://krotov.readthedocs.io/en/stable/API/krotov.html for an example. Extensive documentation of all the templating capabilities is included in the apidoc man page in the documentation. This functionality is a backport of the "better-apidoc" package (https://github.com/goerz/better-apidoc).
- Loading branch information
Showing
16 changed files
with
1,371 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
These template file serve as an example of how to use the `get_members` function. | ||
|
||
They are included in the `apidoc` man page. | ||
|
||
A slightly expanded version of these templates is part of the [automated tests | ||
for `apidoc` with templates](../../../tests/roots/test-apidoc-templates/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{%- set members = get_members() %} | ||
{%- set all = get_members(in_list='__all__', include_imported=True) %} | ||
{%- set all_refs = get_members(in_list='__all__', include_imported=True, out_format='refs', known_refs='__known_refs__') -%} | ||
{%- set exceptions = get_members(typ='exception') -%} | ||
{%- set classes = get_members(typ='class') -%} | ||
{%- set functions = get_members(typ='function') -%} | ||
{%- set data = get_members(typ='data', in_list='__all__') -%} | ||
|
||
{{ [qualname, "module"] | join(" ") | e | heading }} | ||
|
||
.. currentmodule:: {{ qualname }} | ||
|
||
.. automodule:: {{ qualname }} | ||
{%- if members %} | ||
:members: {{ members|join(", ") }} | ||
:undoc-members: | ||
:show-inheritance: | ||
{% endif -%} | ||
|
||
{%- if members or all %}{# summary_members_or_all #} | ||
|
||
Summary | ||
------- | ||
|
||
{%- if exceptions %} | ||
|
||
Exceptions: | ||
|
||
.. autosummary:: | ||
:nosignatures: | ||
{% for item in exceptions %} | ||
{{ item }} | ||
{%- endfor %} | ||
{%- endif %} | ||
|
||
{%- if classes %} | ||
|
||
Classes: | ||
|
||
.. autosummary:: | ||
:nosignatures: | ||
{% for item in classes %} | ||
{{ item }} | ||
{%- endfor %} | ||
{%- endif %} | ||
|
||
{%- if functions %} | ||
|
||
Functions: | ||
|
||
.. autosummary:: | ||
:nosignatures: | ||
{% for item in functions %} | ||
{{ item }} | ||
{%- endfor %} | ||
{%- endif %} | ||
|
||
{%- if data %} | ||
|
||
Data: | ||
|
||
.. autosummary:: | ||
:nosignatures: | ||
{% for item in data %} | ||
{{ item }} | ||
{%- endfor %} | ||
{%- endif %} | ||
|
||
{%- if all_refs %} | ||
|
||
``__all__``: {{ all_refs|join(", ") }} | ||
{%- endif %} | ||
|
||
|
||
{%- endif %}{# summary_members_or_all #} | ||
|
||
|
||
{%- if members %} | ||
|
||
Reference | ||
--------- | ||
|
||
{% endif %} |
Oops, something went wrong.