From e0cda56204c760d574bb38c7ac011615b9ea72dc Mon Sep 17 00:00:00 2001 From: Fabien Michel <104162117+welfoz@users.noreply.github.com> Date: Wed, 14 Dec 2022 10:38:36 +0100 Subject: [PATCH] tools: fix incorrect version history order This fixes an error in parseYAML(text), the version sorting coudn't be right as we compared an arrify string (ie. a = ["v18.11, v16.7.0"]) with an array of strings (ie. b = ["v18.07", "v16.7.0"]) in versionSort(a, b). minVersion(a) couldn't find the minimum version with an arrify string like a = ["v18.11, v16.7.0"]. That's why incorrect version history orders sometimes appeared. Furthermore, no need to sort the added version as it always comes first. So, it can be the last one to be pushed in the meta.changes array. Fixes: https://github.com/nodejs/node/issues/45670 Co-authored-by: Luigi Pinca PR-URL: https://github.com/nodejs/node/pull/45728 Reviewed-By: Luigi Pinca --- test/doctool/test-doctool-html.mjs | 5 +++-- tools/doc/html.mjs | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/test/doctool/test-doctool-html.mjs b/test/doctool/test-doctool-html.mjs index 9323548221b599..6fbca131851f3b 100644 --- a/test/doctool/test-doctool-html.mjs +++ b/test/doctool/test-doctool-html.mjs @@ -79,10 +79,11 @@ const testData = [ ' ' + + ' ' + '

Describe Foobar II in more detail here.' + 'fg(1)' + '

' + diff --git a/tools/doc/html.mjs b/tools/doc/html.mjs index 373f5487a31d4b..8e85b8abec32a1 100644 --- a/tools/doc/html.mjs +++ b/tools/doc/html.mjs @@ -325,27 +325,27 @@ function parseYAML(text) { const removed = { description: '' }; if (meta.added) { - added.version = meta.added.join(', '); - added.description = `Added in: ${added.version}`; + added.version = meta.added; + added.description = `Added in: ${added.version.join(', ')}`; } if (meta.deprecated) { - deprecated.version = meta.deprecated.join(', '); + deprecated.version = meta.deprecated; deprecated.description = - `Deprecated since: ${deprecated.version}`; + `Deprecated since: ${deprecated.version.join(', ')}`; } if (meta.removed) { - removed.version = meta.removed.join(', '); - removed.description = `Removed in: ${removed.version}`; + removed.version = meta.removed; + removed.description = `Removed in: ${removed.version.join(', ')}`; } if (meta.changes.length > 0) { - if (added.description) meta.changes.push(added); if (deprecated.description) meta.changes.push(deprecated); if (removed.description) meta.changes.push(removed); meta.changes.sort((a, b) => versionSort(a.version, b.version)); + if (added.description) meta.changes.push(added); result += '
History\n' + '\n\n';
VersionChanges