Open falexwolf opened 6 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
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
inspect
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
.deforder
tagorder
deforder
cheers, alex
PR welcome, I suppose!
OK, I'll give it a try as soon as possible!
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_ordernumpydoc 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#L591wouldn'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 wheretagorder
is thedeforder
above https://github.com/sphinx-doc/sphinx/blob/a605f2b61907ec768c79890b5073089c1931ac4e/sphinx/ext/autodoc/__init__.py#L786cheers, alex