remark-usage
Advanced tools
Comparing version 4.0.1 to 5.0.0
78
index.js
@@ -1,9 +0,1 @@ | ||
/** | ||
* @author Titus Wormer | ||
* @copyright 2015 Titus Wormer | ||
* @license MIT | ||
* @module remark:usage | ||
* @fileoverview Add a usage example to your README. | ||
*/ | ||
'use strict'; | ||
@@ -19,5 +11,7 @@ | ||
var cept = require('cept'); | ||
var unified = require('unified'); | ||
var markdown = require('remark-parse'); | ||
/* Expose `attacher`. */ | ||
module.exports = attacher; | ||
module.exports = usage; | ||
@@ -31,2 +25,4 @@ /* Methods. */ | ||
var processor = unified().use(markdown); | ||
/* List of locations to look for an example. */ | ||
@@ -49,11 +45,4 @@ var EXAMPLES = [ | ||
/** | ||
* Post-process the example document. | ||
* | ||
* @param {string} value - Content to process. | ||
* @param {Object} logs - List of logs. | ||
* @param {Object} options - Configuration. | ||
* @return {Array.<Node>} - List of mdast nodes. | ||
*/ | ||
function postprocess(value, logs, options, processor) { | ||
/* Post-process the example document. */ | ||
function postprocess(value, logs, options) { | ||
var tokens = []; | ||
@@ -105,3 +94,3 @@ var start = 0; | ||
if (token.type === 'markdown') { | ||
markdown = markdown.concat(parse(token.value, processor)); | ||
markdown = markdown.concat(parse(token.value)); | ||
} else { | ||
@@ -136,10 +125,4 @@ prev = markdown[markdown.length - 1]; | ||
/** | ||
* Adds an npm version badge to the main heading, | ||
* when available. | ||
* | ||
* @param {Unified} processor - Instance | ||
* @param {Object?} options - Configuration. | ||
*/ | ||
function attacher(processor, options) { | ||
/* Update the example section. */ | ||
function usage(options) { | ||
var settings = {}; | ||
@@ -195,22 +178,13 @@ var pack; | ||
return function (tree) { | ||
heading(tree, header, runFactory(settings, processor)); | ||
heading(tree, header, runFactory(settings)); | ||
}; | ||
} | ||
/** | ||
* Construct a transformer based on `options`. | ||
* | ||
* @param {Object} options - Configuration. | ||
* @return {function(node)} - Bound heading-range callback. | ||
*/ | ||
function runFactory(options, processor) { | ||
/** | ||
* Adds an example section based on a valid example | ||
* JavaScript document to a `Usage` section. | ||
* | ||
* @param {Node} start - Starting heading. | ||
* @param {Array.<Node>} nodes - Content. | ||
* @param {Node} end - Ending heading. | ||
*/ | ||
return function (start, nodes, end) { | ||
/* Construct a transformer based on `options`. */ | ||
function runFactory(options) { | ||
return run; | ||
/* Add an example section based on a valid example | ||
* JavaScript document to a `Usage` section. */ | ||
function run(start, nodes, end) { | ||
var logs = {}; | ||
@@ -270,17 +244,11 @@ var example; | ||
return [start].concat( | ||
postprocess(source, logs, options, processor), | ||
postprocess(source, logs, options), | ||
end | ||
); | ||
}; | ||
} | ||
} | ||
/** | ||
* Transform a script into an intermediate nodes, | ||
/* Transform a script into an intermediate nodes, | ||
* removes the IDs from `console.log` invocations, | ||
* and resolves the main `require` call. | ||
* | ||
* @param {string} source - Scripts source. | ||
* @param {Object} options - Configuration. | ||
* @return {Array.<Object>} - List of tokens. | ||
*/ | ||
* and resolves the main `require` call. */ | ||
function script(source, options) { | ||
@@ -340,3 +308,3 @@ var tokens; | ||
* information. */ | ||
function parse(value, processor) { | ||
function parse(value) { | ||
return processor.parse(value, {position: false}).children; | ||
@@ -343,0 +311,0 @@ } |
{ | ||
"name": "remark-usage", | ||
"version": "4.0.1", | ||
"version": "5.0.0", | ||
"description": "Add a usage example to your README", | ||
@@ -24,4 +24,6 @@ "license": "MIT", | ||
"mdast-util-heading-range": "^2.0.0", | ||
"remark-parse": "^3.0.0", | ||
"require-uncached": "^1.0.2", | ||
"trim-trailing-lines": "^1.0.0", | ||
"unified": "^6.0.0", | ||
"unquote": "^1.1.0" | ||
@@ -32,11 +34,11 @@ }, | ||
"negate": "^1.0.0", | ||
"nyc": "^8.1.0", | ||
"remark": "^6.0.0", | ||
"remark-cli": "^2.0.0", | ||
"remark-preset-wooorm": "^1.0.0", | ||
"nyc": "^10.0.0", | ||
"remark": "^7.0.0", | ||
"remark-cli": "^3.0.0", | ||
"remark-preset-wooorm": "^2.0.0", | ||
"tape": "^4.0.0", | ||
"xo": "^0.16.0" | ||
"xo": "^0.17.1" | ||
}, | ||
"scripts": { | ||
"build-md": "remark *.md --quiet --frail", | ||
"build-md": "remark *.md -qfo", | ||
"build": "npm run build-md", | ||
@@ -58,3 +60,4 @@ "lint": "xo", | ||
"max-lines": "off", | ||
"no-cond-assign": "off" | ||
"no-cond-assign": "off", | ||
"import/no-dynamic-require": "off" | ||
}, | ||
@@ -67,10 +70,8 @@ "ignore": [ | ||
"output": true, | ||
"presets": "wooorm", | ||
"plugins": { | ||
"./": null, | ||
"lint": { | ||
"fenced-code-flag": false | ||
} | ||
} | ||
"plugins": [ | ||
"preset-wooorm", | ||
["remark-lint-fenced-code-flag", false], | ||
"./" | ||
] | ||
} | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
13103
7
247
+ Addedremark-parse@^3.0.0
+ Addedunified@^6.0.0
+ Addedbail@1.0.5(transitive)
+ Addedcharacter-entities@1.2.4(transitive)
+ Addedcharacter-entities-legacy@1.1.4(transitive)
+ Addedcharacter-reference-invalid@1.1.4(transitive)
+ Addedcollapse-white-space@1.0.6(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedhas@1.0.4(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-alphabetical@1.0.4(transitive)
+ Addedis-alphanumerical@1.0.4(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-decimal@1.0.4(transitive)
+ Addedis-hexadecimal@1.0.4(transitive)
+ Addedis-plain-obj@1.1.0(transitive)
+ Addedis-whitespace-character@1.0.4(transitive)
+ Addedis-word-character@1.0.4(transitive)
+ Addedmarkdown-escapes@1.0.4(transitive)
+ Addedparse-entities@1.2.2(transitive)
+ Addedremark-parse@3.0.1(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedreplace-ext@1.0.0(transitive)
+ Addedstate-toggle@1.0.3(transitive)
+ Addedtrim@0.0.1(transitive)
+ Addedtrough@1.0.5(transitive)
+ Addedunherit@1.1.3(transitive)
+ Addedunified@6.2.0(transitive)
+ Addedunist-util-is@3.0.0(transitive)
+ Addedunist-util-remove-position@1.1.4(transitive)
+ Addedunist-util-stringify-position@1.1.2(transitive)
+ Addedunist-util-visit@1.4.1(transitive)
+ Addedunist-util-visit-parents@2.1.2(transitive)
+ Addedvfile@2.3.0(transitive)
+ Addedvfile-location@2.0.6(transitive)
+ Addedvfile-message@1.1.1(transitive)
+ Addedx-is-string@0.1.0(transitive)
+ Addedxtend@4.0.2(transitive)