numpy / numpydoc

Numpy's Sphinx extensions
https://numpydoc.readthedocs.io/
Other
304 stars 161 forks source link

Make numpydoc respect `autodoc_member_order` #142

Open falexwolf opened 7 years ago

falexwolf commented 7 years ago

autodoc comes with the parameter autodoc_member_order, which can be set to one of {'alphabetical', 'groubwise', 'bysource'}: http://www.sphinx-doc.org/en/stable/ext/autodoc.html#confval-autodoc_member_order

numpydoc doesn't respect that parameter, but always orders class attributes and methods alphabetically, first here, through inspect https://github.com/numpy/numpydoc/blob/8c1e85c746d1c95b9433b2ae97057b7f447c83d1/numpydoc/docscrape.py#L613 and then again here https://github.com/numpy/numpydoc/blob/8c1e85c746d1c95b9433b2ae97057b7f447c83d1/numpydoc/docscrape.py#L591

wouldn't it be relatively simple to make numpydoc respect the parameter by following what autodoc does?

it retrieves the order of definitions in the source file via the Parser attribute .deforder https://github.com/sphinx-doc/sphinx/blob/a605f2b61907ec768c79890b5073089c1931ac4e/sphinx/pycode/parser.py#L464 and orders attributes using this line where tagorder is the deforder above https://github.com/sphinx-doc/sphinx/blob/a605f2b61907ec768c79890b5073089c1931ac4e/sphinx/ext/autodoc/__init__.py#L786

cheers, alex

jnothman commented 7 years ago

PR welcome, I suppose!

falexwolf commented 7 years ago

OK, I'll give it a try as soon as possible!