
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
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 139 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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.