comment-parser
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -0,1 +1,5 @@ | ||
# v1.4.1 | ||
- fix .prettierignore | ||
- add source trasformation example | ||
# v1.4.0 | ||
@@ -2,0 +6,0 @@ - ESM compatibility improvements; fixes #159, #161 |
{ | ||
"name": "comment-parser", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Generic JSDoc-like comment parser", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -195,2 +195,42 @@ // This file is a source for playground examples. | ||
function stringify_rename(source, parse, stringify, transforms) { | ||
// You can do any manipulations with the parsed result | ||
// See how each block is being mapped. If you are updating a Block.source | ||
// then rewireSource(block) should be called on each changed block. | ||
// If changes were made to Block.tags[].source then call rewireSpecs(block). | ||
// This example shows how you can "rename" @param tags: value1 -> value11, value2 -> value22 | ||
/** | ||
* Description may go | ||
* over multiple lines followed by @tags | ||
* @param {string} name the name parameter | ||
* @param {any} value1 first value parameter | ||
* with a multipline description | ||
* @param {any} value2 second value parameter | ||
*/ | ||
function renameParam(from, to) { | ||
return (block) => { | ||
for (const tag of block.tags) { | ||
if (tag.tag === 'param' && tag.name === from) { | ||
tag.name = to; | ||
for (const line of tag.source) { | ||
if (line.tokens.name === from) line.tokens.name = to; | ||
} | ||
} | ||
} | ||
return block; | ||
}; | ||
} | ||
const transform = transforms.flow( | ||
renameParam('value1', 'value11'), | ||
renameParam('value2', 'value22'), | ||
stringify | ||
); | ||
const parsed = parse(source); | ||
const stringified = parsed.map(transform); | ||
} | ||
(typeof window === 'undefined' ? module.exports : window).examples = [ | ||
@@ -204,2 +244,3 @@ parse_defaults, | ||
stringify_formatting, | ||
stringify_rename, | ||
]; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
365999
10179