Coder Social home page Coder Social logo

Comments (9)

mvismonte avatar mvismonte commented on August 22, 2024

@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.

jimmylai avatar jimmylai commented on August 22, 2024

Yeah, build a DocstringProvider will be very useful.

from libcst.

Jackenmen avatar Jackenmen commented on August 22, 2024

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.

lensvol avatar lensvol commented on August 22, 2024

@jack1142 Will you accept a PR for this or it would be done by someone from your team?

from libcst.

Jackenmen avatar Jackenmen commented on August 22, 2024

@lensvol I'm not in the team :) But from what I know, maintainers of this project are welcome to PRs from outside.

from libcst.

lensvol avatar lensvol commented on August 22, 2024

@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.

jimmylai avatar jimmylai commented on August 22, 2024

@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.

jimmylai avatar jimmylai commented on August 22, 2024

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.

jimmylai avatar jimmylai commented on August 22, 2024

get_docstring helper is implemented in #254
It'll be available in the next LibCST release.

from libcst.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.