Skip to content

Docs: Member order of classes is sometimes alphabetical instead of by source #4393

@provinzkraut

Description

@provinzkraut

Summary

Looking at e.g. https://docs.litestar.dev/main/reference/middleware/index.html#litestar.middleware.ASGIMiddleware, we can see that the order the class members appear in is alphabetical, instead of by source. This is quite jarring, because it mixes e.g. methods with class variables, making it much harder to read.

Now, we do set autodoc_member_order = "bysource", which should make it so the order is by source and not alphabetical, however, this seems to be disregarded in some cases.

There is a known quirk where placing something into a module's __all__ will mean the order of members therein is takes precedence over whatever autodoc_member_order, however, that should not apply to the class members itself.

It seems to have something to do with __all__ though, as adding a class to e.g. litestar.middleware.__init__ and adding that class to the module's __all__ will result in its member appearing in alphabetical order, and removing it from __all__ results in it being ordered as expected. However, I could not reproduce this behaviour in a new sphinx project (using the same sphinx version that is).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions