customizing the class template

48 views
Skip to first unread message

Danylo Ulianych

unread,
May 11, 2020, 2:10:37 PM5/11/20
to sphinx-users
Hello, sphinx community,

I have `kernels.py` file with the following doc header:



.. autosummary::
:toctree: toctree/kernels/

RectangularKernel

which produces 

.. currentmodule:: elephant.kernels

.. autoclass:: RectangularKernel

.. rubric:: Methods

..
autosummary::

~RectangularKernel.__init__
      ...

However, I want to show the documentation of the `RectangularKernel.__call__` function instead of __init__ (default by autosummary). How can I do it? I guess, the answer is in templates, but I don't know how to use them (sphinx templates documentation
 does not cover it).
Note: I have a bunch of kernel classes (not just one) that need to be treated in the same way.
Thank you.

Danylo.

Komiya Takeshi

unread,
May 13, 2020, 9:09:40 AM5/13/20
to sphinx...@googlegroups.com
Hi,

To customize output of autosummary, using own custom template is a good idea.
But it is hard to replace __init__ method description by __call__
method even if you're using template.
I don't have idea to realize it...

Note: To create a custom template:

1. Create a directory named autosummary under your templates path (see
your conf.py)
2. Download base template from github into the autosummary directory
https://github.com/sphinx-doc/sphinx/tree/3.x/sphinx/ext/autosummary/templates/autosummary
3. Modify the template file.

Thanks,
Takeshi KOMIYA

2020年5月12日(火) 3:10 Danylo Ulianych <diz...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/6fdcf684-e0c7-470c-9bb5-99b3075d467d%40googlegroups.com.

Danylo Ulianych

unread,
Sep 22, 2020, 6:24:14 AM9/22/20
to sphinx-users
Thank you.
I see 

.. autosummary::
{% for item in methods %}

block in class.rst template. How do I dynamically populate `methods`? I tried


.. autosummary::
   :methods: forward

but it complains
unknown option: "methods".

Daniel Scott

unread,
Nov 25, 2020, 10:30:07 PM11/25/20
to sphinx...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages