Comments (8)
I agree - this plugin is a great big hack to glue docutils into flake8.
If you know lots about AST, you could be very well placed to clean this up. If you want to work on this, I would be happy to look at a pull request.
from flake8-rst-docstrings.
From what I can tell (having used AST very briefly yesterday), the docstring is stored as an ast.Expr
object in the "body" of an ast.FunctionDef
object representing the function. Classes are presumably represented differently in the AST.
From the ast.Expr
object the following can be accessed:
- the docstring text, via the
.value.s
attribute - the lineno, via the
.lineno
attribute - the col_offset, the the
.col_offset
attribute
I've put together a rough example of how to extract the docstrings from an AST, modelled after Anthony Sottile's flake8_2020 plugin, so I assume this is the correct way to do it. I imagine this could then be passed to docutils for it to do its thing?
I'll try and explore this further over the weekend.
from flake8-rst-docstrings.
That sounds very promising @domdfcoding
from flake8-rst-docstrings.
Pull request #33 will clean this up a lot but just importing the pydocstyle parser, but does not address this point directly: We still reparse the Python file when flake8 already did it and can share the AST.
from flake8-rst-docstrings.
I made some time to look at this today, what do you think of the code on PR #35 using the AST?
from flake8-rst-docstrings.
Looks good. I've noticed some workarounds for ancient python versions. Maybe it's time to drop this?
from flake8-rst-docstrings.
Yeah, the workaround for Python 3.3 and 3.4 was trivial though, so I decided to leave it in for now. I'm expecting and hoping no one complains about my dropping Python 2.7 support yesterday.
from flake8-rst-docstrings.
Closed by #35 and the release of v0.2.0, thank you for the suggestion.
from flake8-rst-docstrings.
Related Issues (20)
- False positive for RST213 and RST210 from *arg and **kwargs HOT 14
- Reading from a closed stdin buffer error HOT 7
- RST299 Cannot analyze code. Pygments package not found. HOT 5
- Add test cases for python3.7 and python3.8 HOT 3
- Consider adding rstcheck integration HOT 7
- False positive RST902 (tuple without redundant parentheses) HOT 10
- Identifier with trailing underscore HOT 2
- Need new validation code for Error in "XXX" directive: HOT 9
- AttributeError: 'FlakesChecker' object has no attribute 'CONSTANT' HOT 2
- Issues with multiline arg descriptions HOT 5
- Wrong line numbers reported under Python 3.8 with v0.2.x HOT 13
- AssertionError: Bad start line with v0.2.2 HOT 3
- Add check for empty line between description and parameter list HOT 3
- Replace TravisCI for continuous integration testing HOT 1
- Add support for signature overloading HOT 9
- Verify violation line numbers in test suite HOT 10
- Bug with single word on first line of docstring HOT 2
- Inconsistent false positive RST214 HOT 10
- Is it possible to support Sphinx more holistically, as some kind of extension/addon? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flake8-rst-docstrings.