autoattribute for parallel assignment

13 views
Skip to first unread message

Buken Li

unread,
Jun 1, 2014, 3:40:14 PM6/1/14
to sphinx...@googlegroups.com
 

When documenting instance variables, I can do

class Foo:
    def __init__(self):
        self.spam = 4
        """Docstring for instance attribute spam."""

This doesn't work for parallel assignment

class Foo:
    def __init__(self):
        self.spam, self.bar, self.moo = 4, 5, 6
        """Docstring for instance attribute spam."""

Is there any way I can document variables when using parallel assignment? Thanks.

Takayuki Shimizukawa

unread,
Jun 15, 2014, 3:33:05 AM6/15/14
to sphinx...@googlegroups.com
Hi, 

I think there is no way to document for parallel assigned attributes.
Please write each attribute documentation in separated lines.

Technically: sphinx.pycode.AttrDocVisitor.add_docstring function interpret a attribute documentation.
IF block at line 146 invoked only when `self.variable = value` style line placed before/after a doc-comment.

Regards,

--
Takayuki SHIMIZUKAWA
http://about.me/shimizukawa


--
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 http://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.

Buken Li

unread,
Jun 16, 2014, 11:31:44 AM6/16/14
to sphinx...@googlegroups.com
Sometimes parallel assignment is the cleanest way to write. For example

class Foo:
    def __init__(self):
        self.spam, self.bar, self.moo = baz()

Its too bad that
sphinx doesn't support this.
btw it is possible to manually write the doc in these situations. See http://stackoverflow.com/a/24046052/1993391

Takayuki Shimizukawa

unread,
Jun 16, 2014, 8:58:59 PM6/16/14
to sphinx...@googlegroups.com
Hi,

2014-06-17 0:31 GMT+09:00 Buken Li <gga...@gmail.com>:
> Sometimes parallel assignment is the cleanest way to write. For example
>
> class Foo:
> def __init__(self):
> self.spam, self.bar, self.moo = baz()
>
> Its too bad that sphinx doesn't support this.

It makes sense.
Please post a feature request to the issue tracker :)

> btw it is possible to manually write the doc in these situations. See http://stackoverflow.com/a/24046052/1993391

Yeah, autodoc creates intermediate reST text internally as the
stackoverflow's comment described.
Reply all
Reply to author
Forward
0 new messages