tree-sitter-cypherdoc
v0.2.0
Published
Tree-sitter grammar for Cypherdoc structured comments
Maintainers
Readme
tree-sitter-cypherdoc
Tree-sitter grammar for structured /** */ documentation comments in .cypher files.
This grammar is injected into Cypher doc_comment nodes by tree-sitter-cypher via queries/injections.scm.
Comment Format
/**
* find_person_by_name
*
* Find a Person node by exact name match.
*
* @param {string} name - The full name to search for
* @returns {[person: node<Person>]} - The matching person, or no rows if not found
*/
MATCH (person:Person {name: $name})
RETURN person| Part | Required | Description |
|------|----------|-------------|
| name | Yes | Identifier on the first line — used as the query/tool name |
| description | No | Free-text lines below the name |
| @param {type} name | No | Required parameter |
| @param {type} [name="default"] | No | Optional parameter with a typed default value |
| @returns {[col: type, ...]} | No | Return columns as a named tuple |
Install
Node.js
npm install tree-sitter-cypherdoc tree-sitterRust
cargo add tree-sitter-cypherdocUsage
Normally consumed via the injection in tree-sitter-cypher. To parse cypherdoc comments directly:
Node.js
import Parser from "tree-sitter";
import Cypherdoc from "tree-sitter-cypherdoc";
const parser = new Parser();
parser.setLanguage(Cypherdoc);
const tree = parser.parse(`/**
* say_hello
* @param {string} name - The name to greet
* @returns {[greeting: string]}
*/`);
console.log(tree.rootNode.toString());Rust
let mut parser = tree_sitter::Parser::new();
parser
.set_language(&tree_sitter_cypherdoc::LANGUAGE.into())
.expect("Error loading Cypherdoc parser");License
MIT
