Comments (9)
@jack1142 I can definitely see how this would be useful. As far as I know, we don't have any doc string APIs. The recommended way of doing something like this would be to create a Metadata Provider and reference that in your visitor/transforms in order to determine if a module/class/function has a docstring and making the appropriate action based on that.
I'm sure that's something that would be useful for others, so feel free to put up a PR if you're interested in putting that together =)
from libcst.
Yeah, build a DocstringProvider will be very useful.
from libcst.
I'll let someone else make this, I won't have enough time to make this, just wanted to put up this feature request :)
from libcst.
@jack1142 Will you accept a PR for this or it would be done by someone from your team?
from libcst.
@lensvol I'm not in the team :) But from what I know, maintainers of this project are welcome to PRs from outside.
from libcst.
@jack1142 Sorry, I was actually trying to mention @mvismonte but my thumb slipped :) I am currently working on something similar, will try to see if it fits the purpose of this issue.
from libcst.
@lensvol Yes, your PR will be very welcome! We've accepted PRs from a couple external contributors. https://github.com/Instagram/LibCST/graphs/contributors
from libcst.
We recently start adding more helper functions to achieve write less and do more
.
We recommend add simple and read-only helpers as attributes of CSTNode, e.g. SimpleString.prefix, quote, raw_value.
https://libcst.readthedocs.io/en/latest/nodes.html#libcst.SimpleString
Docstring is the first string literal statement of module, function or class. It falls under the simple and read-only helper category. So make them as Node.docstring with type Optionoal[str]
makes sense.
from libcst.
get_docstring
helper is implemented in #254
It'll be available in the next LibCST release.
from libcst.
Related Issues (20)
- ParserSyntaxError for "unmatched ']'" faults wrong location
- AttributeError: module 'libcst' has no attribute '_InverseOf'
- Issue with `whitespace_after_*` not fixable HOT 2
- MaybeSentinel not dataclass
- Implement PEP 696 (defaults for type params) HOT 3
- pyright + `__or__` in generic type annotations gives unknown type HOT 1
- Python 3.13.0b1: Segmentation fault when running tests HOT 2
- Indentation wart when removing an Arg from a Call - is whitespace being represented in the right place? HOT 3
- `ApplyTypeAnnotationsVisitor` does not respect `overwrite_existing_annotations` for attributes
- CST validation error on multiline match-case-if blocks
- Failing to build wheel HOT 1
- Accessing .code attribute fails with "TypeError: CSTNode._codegen() missing 1 required positional argument: 'state'" HOT 3
- Importable libcst.tests.pyre
- [support] running test suite doesnโt find libcst.native HOT 2
- Recursion depth exceeded when applying MetadataWrapper on a very long concatenated string HOT 2
- test_parse_error for native parser HOT 1
- [Windows, Mac, Linux in future] Can't use call_if_inside/call_if_not_inside matcher decorators with multiprocessing
- Warnings persist in Context HOT 2
- Link https://libcst.me/ in the docs? HOT 1
- No mute option for reels
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 libcst.