问题
I'm working on a project that requires Numpy documentation. In my Java days, I remember having linters that checked for Javadoc adherence in Eclipse/IDEA; is there an equivalent that checks for Numpy documentation style adherence?
I know about PEP257, but it doesn't seem to have any specific checks for Numpy documentation.
回答1:
Pylint seems to support that. Take a look at pylint.extensions.docparams.
To sum it up. You activate this checker of pylint by adding
load-plugins=pylint.extensions.docparams
in the Master section of your .pylintrc
.
This checker verifies that all function, method, and constructor docstrings include documentation of the
parameters and their types
return value and its type
exceptions raised
Actually pydocstyle (formerly pep257) recently added support for the numpy docstring convention. Although, it's not perfect I think it's the closest to what you want to achieve and it will probably improve in the near future.
pydocstyle --convention=numpy example.py
来源:https://stackoverflow.com/questions/42123798/is-there-any-way-to-lint-a-python-file-to-check-for-numpy-documentation-style-ad