summaryrefslogtreecommitdiff
path: root/tools/doc/common.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2016-05-01 01:51:38 +0200
committerAnna Henningsen <anna@addaleax.net>2016-05-05 01:15:10 +0200
commit00ffa335641b20118fed6ae9b005154fa28e1ea7 (patch)
tree35c031095bf2d238984c3b55760fe727439925eb /tools/doc/common.js
parent1b365f60f047f8f2b9846286819b0b06b3a66fbf (diff)
downloadandroid-node-v8-00ffa335641b20118fed6ae9b005154fa28e1ea7.tar.gz
android-node-v8-00ffa335641b20118fed6ae9b005154fa28e1ea7.tar.bz2
android-node-v8-00ffa335641b20118fed6ae9b005154fa28e1ea7.zip
tools: allow multiple added: version entries
Allow multiple `added:` version entries, since semver-minors can trickle down to previous major versions, and thus features may have been added in multiple versions. Also include `deprecated:` entries and apply the same logic to them for consistency. Stylize the added HTML as `Added in:` and `Deprecated since:`. PR-URL: https://github.com/nodejs/node/pull/6495 Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'tools/doc/common.js')
-rw-r--r--tools/doc/common.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/tools/doc/common.js b/tools/doc/common.js
index 72bb1eb749..c2f561da80 100644
--- a/tools/doc/common.js
+++ b/tools/doc/common.js
@@ -8,6 +8,10 @@ function isYAMLBlock(text) {
exports.isYAMLBlock = isYAMLBlock;
+function arrify(value) {
+ return Array.isArray(value) ? value : [value];
+}
+
function extractAndParseYAML(text) {
text = text.trim();
@@ -15,7 +19,22 @@ function extractAndParseYAML(text) {
.replace(/-->$/, '');
// js-yaml.safeLoad() throws on error
- return yaml.safeLoad(text);
+ const meta = yaml.safeLoad(text);
+
+ const added = meta.added || meta.Added;
+ if (added) {
+ // Since semver-minors can trickle down to previous major versions,
+ // features may have been added in multiple versions.
+ meta.added = arrify(added);
+ }
+
+ const deprecated = meta.deprecated || meta.Deprecated;
+ if (deprecated) {
+ // Treat deprecated like added for consistency.
+ meta.deprecated = arrify(deprecated);
+ }
+
+ return meta;
}
exports.extractAndParseYAML = extractAndParseYAML;