tree-sitter / tree-sitter-graph

Construct graphs from parsed source code

Home Page:https://docs.rs/tree-sitter-graph/*/tree_sitter_graph/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CMD usage

gystar opened this issue · comments

commented

Hi, guys!
I want to know how to convert an AST file (generated by the tree-sitter) to a graph file for visualization.
I find the CMD of the tree-sitter-graph needs tsg file and source file. but I do not know what is the tsg file and how to write it.
Can you present an exact example? The best format of output should be DOT.

The tsg file is a program specifying what nodes should be constructed given some specific AST. Its documentation is reasonably thorough, but you may wish to see examples from the tests or part of our code navigation service.

I don't believe tree-sitter-graph offers DOT output at present. We typically use it by linking against it as a library and inspecting the resulting graph in memory, but the --json output flag was added to support more workflows wishing to use it as a separate tool, if you'd prefer that. It formats the graph as an adjacency list.