Skip to content

Latest commit

 

History

History
108 lines (91 loc) · 4.2 KB

README.md

File metadata and controls

108 lines (91 loc) · 4.2 KB

jsdast

Syntax tree JSDoc based on Unist spec

Build Status JavaScript Style Guide standard-readme compliant

Made by GEUT

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

🐛 If you found an issue we encourage you to report it on github. Please specify your OS and the actions to reproduce it.

Contributing

👥 Ideas and contributions to the project are welcome. You must follow this guideline.

License

MIT © A GEUT project