@code-to-json/comments

Comment-parsing utilities for code-to-json

Usage no npm install needed!

<script type="module">
  import codeToJsonComments from 'https://cdn.skypack.dev/@code-to-json/comments';
</script>

README

@code-to-json/comments

Parse JSDoc or TSDoc style comments into structured data

Build Status Build Status Version codecov Total alerts


Usage

First, install this package as a dependency

yarn add @code-to-json/comments

Then, import the parseCommentString function, and pass it stringified code comment

import { parseCommentString } from '@code-to-json/comments';

parseCommentString(`
/**
 * This is only a comment in a file
 *
 * @example
 *
 * function foo() {}
 * foo(); // equal: undefined
 *
 */
`);

which should return a CommentData value like this

{
  "summary": ["This is only a comment in a file"],
  "customTags": [
    {
      "content": ["function foo() {} ", "\n", "foo(); // equal: undefined"],
      "kind": "blockTag",
      "tagName": "example"
    }
  ]
}

© 2018 LinkedIn