Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: fix incorrect version history order #45728

Merged
merged 1 commit into from Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions test/doctool/test-doctool-html.mjs
Expand Up @@ -79,10 +79,11 @@ const testData = [
'<div class="api_metadata">' +
'<details class="changelog"><summary>History</summary>' +
'<table><tbody><tr><th>Version</th><th>Changes</th></tr>' +
'<tr><td>v4.2.0</td><td><p>The <code>error</code> parameter can now be' +
'an arrow function.</p></td></tr>' +
'<tr><td>v5.3.0, v4.2.0</td>' +
'<td><p><span>Added in: v5.3.0, v4.2.0</span></p></td></tr>' +
'<tr><td>v4.2.0</td><td><p>The <code>error</code> parameter can now be' +
'an arrow function.</p></td></tr></tbody></table></details></div> ' +
'</tbody></table></details></div> ' +
'<p>Describe <code>Foobar II</code> in more detail here.' +
'<a href="http://man7.org/linux/man-pages/man1/fg.1.html"><code>fg(1)' +
'</code></a></p></section><section>' +
Expand Down
14 changes: 7 additions & 7 deletions tools/doc/html.mjs
Expand Up @@ -325,27 +325,27 @@ function parseYAML(text) {
const removed = { description: '' };

if (meta.added) {
added.version = meta.added.join(', ');
added.description = `<span>Added in: ${added.version}</span>`;
added.version = meta.added;
added.description = `<span>Added in: ${added.version.join(', ')}</span>`;
}

if (meta.deprecated) {
deprecated.version = meta.deprecated.join(', ');
deprecated.version = meta.deprecated;
deprecated.description =
`<span>Deprecated since: ${deprecated.version}</span>`;
`<span>Deprecated since: ${deprecated.version.join(', ')}</span>`;
}

if (meta.removed) {
removed.version = meta.removed.join(', ');
removed.description = `<span>Removed in: ${removed.version}</span>`;
removed.version = meta.removed;
removed.description = `<span>Removed in: ${removed.version.join(', ')}</span>`;
}

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 += '<details class="changelog"><summary>History</summary>\n' +
'<table>\n<tr><th>Version</th><th>Changes</th></tr>\n';
Expand Down