Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
cdocparser
Advanced tools
CDocParser is a language agonistc C style comments parser that uses block comments to make it easer to generate documenation.
npm install --save cdocparser
CDocParser consists of two parts the CommentExtractor
and a CommentParser
.
var CDocParser = require('cdocparser');
var extractor = new CDocParser.CommentExtractor( /* contextParser */ );
var parser = new CDocParser.CommentParser(/* Annotations */);
var comments = extractor.extract( /* code */);
var parsedComments = parser.parse( comments );
console.log(parsedComments);
The ComemntExtractor is used to extract C-Style comments from source and attach context infromation to it.
new CommentExtractor( contextParser )
Create a CommentExtractor to extract block comment like:
/**
*
* CDocComment
*
*/
You need to pass in a function that is used to generate a context
object used to specify the context of the, comment.
A context obj:
{
type : 'contextType'
}
The type
attribute is mandatory, you can add as much attributes as you would like.
#extract(code)
This method will return an Array of all comments in the form of
[
{ lines : {}, context : [context object generated by contextParser] }
]
new CommentParser( annotations )
Create a new CommentParser
where annotaions
is an object like:
{
_ : {
alias : {
'aliasName' : 'aRealAnnotation'
}
},
aRealAnnotation : function( annotationLine ){
}
}
This object is used to provide parser for various types of annotations. It also includes tha ability to include aliases.
#parse ( comments )
This methods takes an comments array provided by CommentExtractor#extract
and parses all annotations. The resulting
object will look like:
{
"[context.type]" : [
{
description : "[Contains all commetn lines without an annotation]",
[annotationName] : [resultOfAnnotationParser]
}
]
}
Use mocha test
to run the unit tests
FAQs
Extract C style comments and extract context from source
The npm package cdocparser receives a total of 6,459 weekly downloads. As such, cdocparser popularity was classified as popular.
We found that cdocparser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.