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

Add documentation for how to use Query API #70

Open
kkoomen opened this issue Oct 25, 2020 · 4 comments
Open

Add documentation for how to use Query API #70

kkoomen opened this issue Oct 25, 2020 · 4 comments

Comments

@kkoomen
Copy link

kkoomen commented Oct 25, 2020

Hi,

I've noticed that #62 did implement the Query API and I sort of did figure it out on my own by just backtracing the packages, the functions being exposed etc, but only because I couldn't find any documentation on how to use the Query API in JavaScript/TypeScript.

Please add the required documentation in the README about how to use this. I personally feel it should include examples of the following

  • How to create a query
  • How to capture a node with a query
    • After capturing a node, how do I get a node inside this result? Python example: if I capture a function/method it's name, parameters and body and my goal is to get the parameter data, how do I get each parameter? Should I just use parameters: (parameters (identifier) (identifier)) @function.parameters and then loop over the result and filter the child nodes via result.node.children.filter((node) => node.type === 'identifier')? Or can this capturing be handled with queries as well? I'd like to get more information about this, since I can't find anything about this.
  • How queries work

Thanks.

@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.61. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@braebo
Copy link

braebo commented Apr 5, 2021

Hey @kkoomen - I'm really struggling with this as well. I'm hoping comeone could perhaps share a brief example of how to effectively isolate nodes by type and extract their contents using queries in TS/JS?

@weeman1337
Copy link

As long there is no real documentation yet, you could at least have a look into the tests: https://github.com/tree-sitter/node-tree-sitter/blob/master/test/query_test.js

@kkoomen
Copy link
Author

kkoomen commented May 6, 2021

@weeman1337 I think by now more people had no choice but to look through tests yet, but there are so many questions and cases that are not covered in those tests. Is there any plan to write documentation? I'm still waiting for this and it seems the development on the tree-sitter modules are slow, including response time from maintainers. Can this be more active as well?

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

No branches or pull requests

3 participants