0.0.10 • Published 4 years ago
@geut/jsdast v0.0.10
jsdast
Syntax tree JSDoc based on Unist spec
Install
$ npm install @geut/jsdast
Usage
const unified = require('unified')
const { parser } = require('@geut/jsdast')
const tree = unified().use(parser).parse(`
/**
* @param {number} a
* @param {number} b
* @returns {number}
*/
function sum(a, b) {
return a + b
}
`)
console.log(JSON.stringify(tree, null, 2))
/*
{
"type": "Root",
"children": [
{
"type": "Module",
"name": "Index",
"doc": {
"description": "",
"tags": []
},
"children": [
{
"type": "FunctionDeclaration",
"name": "sum",
"doc": {
"tags": [
{
"tagName": "returns",
"fullText": "@returns {number}",
"typeExpression": "number"
}
]
},
"isExported": false,
"isDefaultExport": false,
"valueType": "number",
"isGenerator": false,
"isAsync": false,
"children": [
{
"type": "Parameter",
"name": "a",
"doc": {
"tags": []
},
"isRestParameter": false,
"valueType": "number",
"isOptional": false
},
{
"type": "Parameter",
"name": "b",
"doc": {
"tags": []
},
"isRestParameter": false,
"valueType": "number",
"isOptional": false
}
]
}
]
}
]
}
*/
Issues
:bug: If you found an issue we encourage you to report it on github. Please specify your OS and the actions to reproduce it.
Contributing
:busts_in_silhouette: Ideas and contributions to the project are welcome. You must follow this guideline.
License
MIT © A GEUT project