From 80ff6f6e64d435076c15ab02e850cd8387595da8 Mon Sep 17 00:00:00 2001 From: Fabien MICHEL Date: Sat, 3 Dec 2022 19:53:55 +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. Therefore, 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. Co-authored-by: Luigi Pinca Fixes: https://github.com/nodejs/node/issues/45670 --- 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