napoleon and numpy style docstrings: no `Attributes' heading

405 views
Skip to first unread message

Nicolas Chopin

unread,
Apr 22, 2019, 10:33:16 AM4/22/19
to sphinx-users
 Dear list,
I use the napoleon extension to parse my "numpy-style" docstrings. It works great for functions, but for classes, I have the following problem. The "Attributes" section list the attributes (as it should), but the header "Attributes" does not show. For instance, I get this:
(shortened url: https://bit.ly/2IyxR1F)

where X, A, etc are attributes of this class ParticleHistory. You can click on [source] to see how the class is defined; or more simply see below for a simplified version.
Am I doing something wrong? This page:
says that Attributes is a supported header.

I'm using sphinx 1.8.2 on Ubuntu 18.04.
Many thanks in advance
Nicolas


class History(object):
    """Stores history.   

    Blah, blah, blah.

    Attributes
    ----------
    X: list
        X[t] is the object that represents the N particles at iteration t
    A: list
        A[t] is the vector of ancestor indices at time t

    """

    def __init__(self, N):
        """
        Constructor.

        Parameters
        ----------

        N: int
            number of particles
        """
        self.N = N


Komiya Takeshi

unread,
May 6, 2019, 9:03:58 AM5/6/19
to sphinx...@googlegroups.com
Hi Nicolas,

It seems napoleon does not output Attribute headers ever even if
specified. It seems intended behavior.

Thanks,
Takeshi KOMIYA

2019年4月22日(月) 23:33 Nicolas Chopin <n.chop...@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 post to this group, send email to sphinx...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sphinx-users.
> For more options, visit https://groups.google.com/d/optout.

n.chop...@gmail.com

unread,
May 6, 2019, 12:28:03 PM5/6/19
to sphinx-users
Hi,
sorry, but I don't think that's true? For instance, the header "Parameters"
*does* appear in functions and class methods. Plus, in the documentation:
no distinction is made between these two types of headers, so why
the "Attributes" header should be treated differently than "Parameters"?

Anyway, thanks for your input.
Nicolas


On Monday, 6 May 2019 15:03:58 UTC+2, Komiya Takeshi wrote:
Hi Nicolas,

It seems napoleon does not output Attribute headers ever even if
specified. It seems intended behavior.

Thanks,
Takeshi KOMIYA

2019年4月22日(月) 23:33 Nicolas Chopin <n.cho...@gmail.com>:
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx...@googlegroups.com.

Komiya Takeshi

unread,
May 13, 2019, 12:27:51 PM5/13/19
to sphinx...@googlegroups.com
Sorry, I can't answer you why napoleon behaves so because I'm not an
author of the extension.

All I can say is handler for parameter generates "Parameters" as a header.
https://github.com/sphinx-doc/sphinx/blob/f63abac2cad2664a8af816017f0f997bae510d14/sphinx/ext/napoleon/docstring.py#L690-L696

On the other hand, handler for attributes does generates no headers.
https://github.com/sphinx-doc/sphinx/blob/f63abac2cad2664a8af816017f0f997bae510d14/sphinx/ext/napoleon/docstring.py#L602-L622

Thanks,
Takeshi KOMIYA

2019年5月7日(火) 1:28 <n.chop...@gmail.com>:
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To post to this group, send email to sphinx...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sphinx-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/b29b0d21-850c-4d6f-9213-5e09dd6e2360%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages