From 11b8d4793f3057d5fcf72285a538dc40b41fdc9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Wed, 21 Mar 2018 15:37:12 +0100 Subject: [PATCH] tools: shorten metadata parsing PR-URL: https://github.com/nodejs/node/pull/19512 Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- tools/doc/common.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tools/doc/common.js b/tools/doc/common.js index 9f7a25ecd484a3..3a66cbd7b05065 100644 --- a/tools/doc/common.js +++ b/tools/doc/common.js @@ -13,31 +13,28 @@ function arrify(value) { } function extractAndParseYAML(text) { - text = text.trim(); - - text = text.replace(/^$/, ''); // js-yaml.safeLoad() throws on error const meta = yaml.safeLoad(text); - const added = meta.added; - if (added) { + if (meta.added) { // Since semver-minors can trickle down to previous major versions, // features may have been added in multiple versions. - meta.added = arrify(added); + meta.added = arrify(meta.added); } - const deprecated = meta.deprecated; - if (deprecated) { + if (meta.deprecated) { // Treat deprecated like added for consistency. - meta.deprecated = arrify(deprecated); + meta.deprecated = arrify(meta.deprecated); } meta.changes = meta.changes || []; - meta.changes.forEach((entry) => { + for (const entry of meta.changes) { entry.description = entry.description.replace(/^\^\s*/, ''); - }); + } return meta; }