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!
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-----
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
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-----
Indeed, this is working now! Thanks again :)
Pierre