autodoc doesn't detect all module attributes

335 views
Skip to first unread message

pipoun

unread,
Feb 4, 2010, 7:04:10 AM2/4/10
to sphinx-dev
Hi all,

I've got a strange behavior with sphinx and autodoc, regarding the
documentation of some module attributes.

here is the .txt
.. automodule:: mymodule
:members:
:undoc-members:
:show-inheritance:

here is the .py

from enum import Enum
#: doc enum
EFooBar = Enum("FOO", "BAR")
#: doc enum 2
EFooBar2 = "string"
#: foo
g_FOO = EFooBar.FOO
#: foo 2
g_FOO2 = 1

In the html file, I only have doc for EFooBar2 and g_FOO2 and nothing
for EFooBar nor g_FOO

I can add a .. attribute:: g_FOO in the class docstring, but they are
not placed in the same groups of attributes than EFooBar2 and g_FOO2
(in the html file).
autodoc_member_order is set to 'groupwise'

I'm using the latest code from the mercurial repository.

Thanks for the help!

Georg Brandl

unread,
Feb 21, 2010, 9:53:20 AM2/21/10
to sphin...@googlegroups.com, pip...@gmail.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This may be caused by the specific Enum class you're using. Could you
show me how enum.py looks?

Thanks,
Georg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)

iEYEARECAAYFAkuBSOAACgkQN9GcIYhpnLDYJgCbBUxnT09aIZfy1EDEKRvAsLdd
NcIAoLAilJpCFAvTq8dVVrC9Rfu8PIT5
=m8K6
-----END PGP SIGNATURE-----

pipoun

unread,
Feb 28, 2010, 6:12:29 AM2/28/10
to sphinx-dev

Thanks for your answer. I'm using the enum module from pypi:
http://pypi.python.org/pypi/enum/

There's only one module. Here is the Enum constructor, dunno if it can
help at first sight (there's a EnumValue class to look at perhaps
too):

def __init__(self, *keys, **kwargs):
""" Create an enumeration instance. """

value_type = kwargs.get('value_type', EnumValue)

if not keys:
raise EnumEmptyError()

keys = tuple(keys)
values = [None] * len(keys)

for i, key in enumerate(keys):
value = value_type(self, i, key)
values[i] = value
try:
super(Enum, self).__setattr__(key, value)
except TypeError:
raise EnumBadKeyError(key)

self.__dict__['_keys'] = keys
self.__dict__['_values'] = values

By the way, I think this behavior might be reproducible with variables
assigned to a class instance.

Thanks again,
Pierre

Georg Brandl

unread,
Feb 28, 2010, 9:21:36 AM2/28/10
to sphin...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 28.02.2010 12:12, schrieb pipoun:

>> There's only one module. Here is the Enum constructor, dunno if it can
>> help at first sight (there's a EnumValue class to look at perhaps
>> too):
>
>> def __init__(self, *keys, **kwargs):
>> """ Create an enumeration instance. """
>
>> value_type = kwargs.get('value_type', EnumValue)
>
>> if not keys:
>> raise EnumEmptyError()
>
>> keys = tuple(keys)
>> values = [None] * len(keys)
>
>> for i, key in enumerate(keys):
>> value = value_type(self, i, key)
>> values[i] = value
>> try:
>> super(Enum, self).__setattr__(key, value)
>> except TypeError:
>> raise EnumBadKeyError(key)
>
>> self.__dict__['_keys'] = keys
>> self.__dict__['_values'] = values
>
>> By the way, I think this behavior might be reproducible with variables
>> assigned to a class instance.

OK, this actually wasn't a problem with the Enum, but generally with class
instances documented as module globals. Should be fixed now with changeset
3e17dadbad20 in 0.6 and trunk.

cheers,


Georg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)

iEYEARECAAYFAkuKe/AACgkQN9GcIYhpnLDN4gCdHJKk+KKeTaurLA8APsPRC1Wb
fnkAn1Zvh9r5jAZlZ+K3WoIsyAToZCIW
=zQhl
-----END PGP SIGNATURE-----

pipoun

unread,
Mar 9, 2010, 4:09:44 AM3/9/10
to sphinx-dev

Indeed, this is working now! Thanks again :)
Pierre

Reply all
Reply to author
Forward
0 new messages