Hi,

Adding this snippet to conf.py works for me - makes the methods of the
class appear in the same order as in the code:

from sphinx.ext import autodoc
from sphinx.ext.autodoc import ClassDocumenter

class MyClassDocumenter(ClassDocumenter):

    def get_object_members(self, want_all):
        members_check_module, members = super(MyClassDocumenter,
self).get_object_members(want_all)
        def key((name, obj)):
            try:
                return obj.im_func.func_code.co_firstlineno
            except AttributeError:
                return 0
        members.sort(key=key)
        return members_check_module, members

autodoc.ClassDocumenter = MyClassDocumenter

This may not work in your case. In particular, it won't work if you
set autodoc_member_order to 'groupwise'.

Would be nice if sphinx had an option to do this without hacking.


On Sep 1, 5:42 am, Elaine Angelino <[email protected]> wrote:
> hi there --
>
> i really like using autodocs in sphinx to complement handwritten
> "tutorial-style" docs
>
> when i use ":members:" to include the members of an automodule, the members
> (e.g. functions inside of the module) appear in the documentation in the
> same order in which they appear in the module, e.g. when i write:
>
> .. automodule:: module.name
>      :members:
>
> however, when i use ":members:" to include the members of an autoclass, the
> members (e.g. class methods) appear in alphabetical order, e.g. when i
> write:
>
> .. autoclass:: class.name
>      :members:
>
> i would really like to have the class methods automatically appear in the
> same order in which they appear in the class.  this can be useful when the
> class methods are grouped conceptually.
>
> is there a configuration setting i am not using properly? something else?
>
> thanks for any help!
>
> elaine

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to