Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
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 60 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.