Skip to content

Commit 124c2b3

Browse files
welfozlpinca
authored andcommitted
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: #45670 Co-authored-by: Luigi Pinca <luigipinca@gmail.com> PR-URL: #45728 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 27cf389 commit 124c2b3

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

test/doctool/test-doctool-html.mjs

+3-2
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ const testData = [
7979
'<div class="api_metadata">' +
8080
'<details class="changelog"><summary>History</summary>' +
8181
'<table><tbody><tr><th>Version</th><th>Changes</th></tr>' +
82+
'<tr><td>v4.2.0</td><td><p>The <code>error</code> parameter can now be' +
83+
'an arrow function.</p></td></tr>' +
8284
'<tr><td>v5.3.0, v4.2.0</td>' +
8385
'<td><p><span>Added in: v5.3.0, v4.2.0</span></p></td></tr>' +
84-
'<tr><td>v4.2.0</td><td><p>The <code>error</code> parameter can now be' +
85-
'an arrow function.</p></td></tr></tbody></table></details></div> ' +
86+
'</tbody></table></details></div> ' +
8687
'<p>Describe <code>Foobar II</code> in more detail here.' +
8788
'<a href="http://man7.org/linux/man-pages/man1/fg.1.html"><code>fg(1)' +
8889
'</code></a></p></section><section>' +

tools/doc/html.mjs

+7-7
Original file line numberDiff line numberDiff line change
@@ -325,27 +325,27 @@ function parseYAML(text) {
325325
const removed = { description: '' };
326326

327327
if (meta.added) {
328-
added.version = meta.added.join(', ');
329-
added.description = `<span>Added in: ${added.version}</span>`;
328+
added.version = meta.added;
329+
added.description = `<span>Added in: ${added.version.join(', ')}</span>`;
330330
}
331331

332332
if (meta.deprecated) {
333-
deprecated.version = meta.deprecated.join(', ');
333+
deprecated.version = meta.deprecated;
334334
deprecated.description =
335-
`<span>Deprecated since: ${deprecated.version}</span>`;
335+
`<span>Deprecated since: ${deprecated.version.join(', ')}</span>`;
336336
}
337337

338338
if (meta.removed) {
339-
removed.version = meta.removed.join(', ');
340-
removed.description = `<span>Removed in: ${removed.version}</span>`;
339+
removed.version = meta.removed;
340+
removed.description = `<span>Removed in: ${removed.version.join(', ')}</span>`;
341341
}
342342

343343
if (meta.changes.length > 0) {
344-
if (added.description) meta.changes.push(added);
345344
if (deprecated.description) meta.changes.push(deprecated);
346345
if (removed.description) meta.changes.push(removed);
347346

348347
meta.changes.sort((a, b) => versionSort(a.version, b.version));
348+
if (added.description) meta.changes.push(added);
349349

350350
result += '<details class="changelog"><summary>History</summary>\n' +
351351
'<table>\n<tr><th>Version</th><th>Changes</th></tr>\n';

0 commit comments

Comments
 (0)