Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Stream source code documentation block to json object
Install the module with: npm install docflux
var docflux = require('docflux');
process.stdin(docflux())
.on('data', function(jsdoc) {
console.log(JSON.stringify(jsdoc, null, 2))
})
Yield (see docflux json object below)
{"token": "MyClass#foo(a,b,[c])", "description": "...", "tags": [{...}]}
{"token": "MyClass#bar(a,b,[c])", "description": "...", "tags": [{...}]}
Install the command line tool with: npm install -g docflux
Usage: docflux docflux <file>
Options:
-h, --help output usage information
-V, --version output the version number
-m --markdown Output a markdown formated documentation (default to json)
-o --output <file> Output to this file
-i --indent [size] Indent json output
-d --depth <size> Minimal header depth for markdown output
# Pipe to another json consumer
cat input.js | docflux | consumejson
# Use input and output
docflux input.js -o output.md
# Or write markdown output ...
docflux --markdown input.js > output.md
# Or write json output with indentation...
docflux input.js -i 4 > output.json
Docflux support most of the jsdoc-like simple doc-block (see tests for more examples)
Short & compact doc-block style
/**
* Create new user
* Long description of this method
* @param {String} name User name
* @param {String|String[]} groupId Group id or array of group id
* @param {Object} [options]
* @returns {Boolean}
*/
MyClass.prototype.createUser(name, groupId, options) { //...
Long doc-block style
/**
* Create new user
*
* Long description of this method with list and examples
*
* - Do this
* - And this
*
* Example:
*
* var my = new MyClass();
* my.createUser('Foo',['admin','staff'], { silent: true });
*
* @param {String} name
* Username with some restrictions
* - Must be lower-case
* - Must be funny
*
* @param {String|String[]} groupId Group id or array of group id
* Put some markdow here too:
*
* // Example
*
* @param {Object} [options]
* Options are always optional
* but params description alignement is based on first line indentation
*
* @returns {Boolean}
*
* @thows {InvalidUsernameException} Not funny (maybe)
*
* @see http://www.gelule.net/
*
* @memberOf MyClass
*/
createUser: function(name, groupId, options) { //...
Output examples
Opinionated stream that transform a docflux stream to markdown (see markdown output example) (nb: this is more a demo usage of docflux's json stream)
var docflux = require('docflux');
process.stdin(docflux())
.pipe(docflux.markdown())
.on('data', function(jsdoc) {
console.log(JSON.stringify(jsdoc, null, 2))
})
@memberOf
tagThe @memberOf
associate a backbone-like method with a class.
var MyClass = ClassCreator({
/**
* Create new user
* @memberOf MyClass
*/
createUser: function () { //...
})
Yield the following docflux.signature
(with markdown transform):
## MyClass#createUser()
Add a dot to the memberOf tag (@memberOf MyClass.
) to force a static method signature:
## MyClass.createUser()
For each jsdoc-style block in the source code, docflux provide a pojo javascript object with those fields:
token
:
The documented function or class or methodparams
:
Formated parameters list (expl: a, b, [options]
)memberOf
:
According to the @memberOf
tag if present, the class of the currently
documented method. Useful with backbone-like code (expl: MyClass
)signature
:
A formated signature (expl: MyClass#foo(a, b, [options])
)description
:
The full description part of the doc-block commentsummary
:
Only the summary part of the doc-block commentbody
:
The extended description part of the doc-block commenttags
:
An array of tag object with:
type
: The tag nametypes
: Array of types (for tags like @param {Object|String}
)token
: The param token (for @param {Type} token
)description
: The full tag descriptionsummary
: Only the summary part of the description (first line)body
: The extended part of the tag descriptionraw
: The raw tag extracted from the doc-block commentflags
:
An array of all tags name (type): can be used as flag to check
a tag presenceisClass
:
True if this comment concern a Class (see isClass())isFunction
:
True if this comment concern a functionisExports
:
True if this comment concern a module.exportsignore
:
a @ignore
tag existsfirstLine
:
The first line of code used to generated the tokenraw
:
The full raw doc-blockThe MIT license (see LICENSE.md)
FAQs
Stream jsdoc block to json object and markdown
The npm package docflux receives a total of 1 weekly downloads. As such, docflux popularity was classified as not popular.
We found that docflux 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.