Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
doc-parser
Advanced tools
This library is a javascript LALR(1) parser that parses docblocks and extracts annotations under an structured syntax tree.
npm install doc-parser --save
And simple usage :
var DocParser = require('doc-parser');
var reader = new DocParser();
var data = reader.parse('/** @hello world */');
/**
* Some description
* @return boolean
* @return map<string, SomeClass>
* @author Ioan CHIRIAC <me@domain.com>
* @throws Exception
* @deprecated
* @table('tableName', true)
* @table(
* name='tableName',
* primary=true
* )
* @annotation1 @annotation2
* @Target(["METHOD", "PROPERTY"])
* @Attributes([
* @Attribute("stringProperty", type = "string"),
* @Attribute("annotProperty", type = "SomeAnnotationClass"),
* ])
* @json({
* "key": "value",
* "object": { "inner": true },
* "list": [1, 2, 3]
* })
* <node>
* Some inner multi line content
* </node>
*/
{
kind: 'doc',
summary: 'Some description retrieved from the first line of the coment',
body: [
{
kind: 'return',
type: 'void',
description: 'Some extra informations'
}
]
}
By default, doc-parser
supports @return
,@param
,@throws
and @deprecated
doc blocks.
You can extend the support to any doc block :
// lets handle @global (type) (var) (description)
var DocParser = require('doc-parser');
var reader = new DocParser({
'global': [
{
property: 'type',
parser: 'type',
optional: true
},
{
property: 'what',
parser: 'variable',
optional: true
},
{
property: 'description',
parser: 'text',
optional: true,
default: ''
}
]
});
var data = reader.parse('/** @global string some description */');
This will result in a new kind of doc block with the specified properties. Here a list of supported parsers :
This library is released under BSD-3 license clause.
FAQs
Parses docblocks comments
The npm package doc-parser receives a total of 90 weekly downloads. As such, doc-parser popularity was classified as not popular.
We found that doc-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.