Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validating docstrings in Python files as RST #34

Closed
peterjc opened this issue Jul 28, 2016 · 7 comments
Closed

Validating docstrings in Python files as RST #34

peterjc opened this issue Jul 28, 2016 · 7 comments
Labels

Comments

@peterjc
Copy link
Contributor

peterjc commented Jul 28, 2016

As I understand it, rst-lint *.rst works great on plain text files using reStructuredText.

I would like to be able to do rst-lint *.py and have it pull out the Python docstrings, and check if they are valid reStructuredText.

Ideally any errors would retain the original line number from the Python file. That can probably be done via an offset if processing each docstring alone.

@twolfson
Copy link
Owner

I would like to keep this module as 1 thing well and defer to using a bash/Python glue script for that behavior. I don't know any programs off the top of my head to pull out docstrings but I'm sure they exist due to automated documentation creation. An example script would look like:

for file in *.py; do
  extract-docstrings "$file" | rst-lint -
done

@peterjc
Copy link
Contributor Author

peterjc commented Jul 28, 2016

OK, if we discover such a extract-docstrings tool, then it would be good to add an example like this to the documentation for your tool.

@twolfson
Copy link
Owner

Yea, I would be open to adding that in the "Examples" section 👍

@peterjc
Copy link
Contributor Author

peterjc commented Jun 7, 2017

In pull request PyCQA/pydocstyle#254 I wrote a proof-of-principle extending pydocstyle to validate Python docstrings as RST using the approach from Todd's restructuredtext-lint code.

However, the pydocstyle team recommend this functionality instead be written as a new plugin for flake8 - see https://gitlab.com/pycqa/flake8/issues/337

@twolfson
Copy link
Owner

twolfson commented Jun 7, 2017

Both make sense (i.e. flake8 plugin, CLI tool) but it seems that both pydocstyle and myself concur that it should be another library that finds/extracts the docstrings for comparison

@peterjc
Copy link
Contributor Author

peterjc commented Jun 8, 2017

I've started working on this as a flake8 plugin under the name flake8-rst-docstrings,

https://github.com/peterjc/flake8-rst-docstrings

@peterjc
Copy link
Contributor Author

peterjc commented Jun 16, 2017

I've made the first release of the new plugin flake8-rst-docstrings on PyPI, which uses restructuredtext-lint internally:

https://pypi.python.org/pypi/flake8-rst-docstrings

(I'll stop commenting on this issue now - thanks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants