Subject: autodoc_member_order = 'bysource' does not work for modules containing __all__
When setting autodoc_member_order to 'bysource' in conf.py, it does not work entirely as expected on modules that contain __all__. The members are listed in the order dictated by __all__, which is expected. But the members of the members are listed alphabetically.
- I have a module `foo` in `foo/__init__.py`
- `__init__.py` itself contains no code other than import
statements from private modules
(e.g., `from ._bar import spam, eggs`)
- `__init__.py` has a line that says `__all__ = ['spam', 'eggs']`
- `spam`, in this scenario, is a class that contains two
methods in this order: `b` and `a`.
- Apply Sphinx magic.
- Module foo in Sphinx is listed in this order:
- spam
- a
- b
- eggs
N/A
b and a should be swapped.
make html in the docs directory.I have _almost_ the same issue:
__init__.py only contains Docstring and imports__init__.py does not have an __all__ assignmentautodoc_member_order = 'bysource' at the end of my conf.pyOS: macOS 10.12.6
Python version: 3.6.1
Sphinx version: 1.6.2
I'm working on a package, there is nothing in __init__.py.
When I add the line autodoc_member_order = 'bysource' in my conf.py, in the documentation some modules are still ordered alphabetically. I can't find why some of them are well ordered by source and some of them aren't. It seems that the problem occurs more when a module contains class declaration.
The comment https://github.com/sphinx-doc/sphinx/issues/2042#issuecomment-203033366 suggests bysource fails if Sphinx failed to parse the Python code, which might be related to the pattern you are seeing?
bysourcefails if Sphinx failed to parse the Python code, which might be related to the pattern you are seeing?
I've seen this happen for class definitions where cls.__module__ is overloaded, as this results in inspect.getsource failing.