Add documentation for how to use Query API
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,parametersandbodyand my goal is to get the parameter data, how do I get each parameter? Should I just useparameters: (parameters (identifier) (identifier)) @function.parametersand then loop over the result and filter the child nodes viaresult.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.
- After capturing a node, how do I get a node inside this result? Python example: if I capture a function/method it's
- How queries work
Thanks.
Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.61. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!
Links: app homepage, dashboard and code for this bot.
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?
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
@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?