Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9564f7a

Browse filesBrowse files
tniessentargos
authored andcommitted
tools: fix doc tool behavior for version arrays
Even though the doc tool supports version arrays in theory, it fails to sort them properly causing the tool to crash. PR-URL: #22766 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent bda3311 commit 9564f7a
Copy full SHA for 9564f7a

File tree

Expand file treeCollapse file tree

2 files changed

+12
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-4
lines changed
Open diff view settings
Collapse file

‎tools/doc/common.js‎

Copy file name to clipboardExpand all lines: tools/doc/common.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ function extractAndParseYAML(text) {
4343
return meta;
4444
}
4545

46-
module.exports = { isYAMLBlock, extractAndParseYAML };
46+
module.exports = { arrify, isYAMLBlock, extractAndParseYAML };
Collapse file

‎tools/doc/html.js‎

Copy file name to clipboardExpand all lines: tools/doc/html.js
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,9 @@ function parseYAML(text) {
308308
.use(htmlStringify)
309309
.processSync(change.description).toString();
310310

311-
result += `<tr><td>${change.version}</td>\n` +
311+
const version = common.arrify(change.version).join(', ');
312+
313+
result += `<tr><td>${version}</td>\n` +
312314
`<td>${description}</td></tr>\n`;
313315
});
314316

@@ -326,10 +328,16 @@ function parseYAML(text) {
326328
return result;
327329
}
328330

331+
function minVersion(a) {
332+
return common.arrify(a).reduce((min, e) => {
333+
return !min || versionSort(min, e) < 0 ? e : min;
334+
});
335+
}
336+
329337
const numberRe = /^\d*/;
330338
function versionSort(a, b) {
331-
a = a.trim();
332-
b = b.trim();
339+
a = minVersion(a).trim();
340+
b = minVersion(b).trim();
333341
let i = 0; // Common prefix length.
334342
while (i < a.length && i < b.length && a[i] === b[i]) i++;
335343
a = a.substr(i);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.