numpydoc icon indicating copy to clipboard operation
numpydoc copied to clipboard

Make numpydoc respect `autodoc_member_order`

Open falexwolf opened this issue 8 years ago • 2 comments

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

falexwolf avatar Nov 12 '17 07:11 falexwolf

PR welcome, I suppose!

jnothman avatar Nov 13 '17 07:11 jnothman

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

falexwolf avatar Nov 14 '17 21:11 falexwolf