@geut/jsdast

0.0.10 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i @geut/jsdast

Weekly Downloads

12

Version

0.0.10

License

MIT

Unpacked Size

27.9 kB

Total Files

8

Last publish

Collaborators

  • geutuser
  • the-real-dk
  • tinchoz49
  • estebanprimost