diff --git a/doc/api_assets/style.css b/doc/api_assets/style.css
index f45c4672af88f8..7889389f59b251 100644
--- a/doc/api_assets/style.css
+++ b/doc/api_assets/style.css
@@ -470,6 +470,12 @@ th > *:last-child, td > *:last-child {
margin-bottom: 0;
}
+.changelog > summary {
+ margin: .5rem 0;
+ padding: .5rem 0;
+ cursor: pointer;
+}
+
/* simpler clearfix */
.clearfix:after {
content: ".";
diff --git a/test/doctool/test-doctool-html.js b/test/doctool/test-doctool-html.js
index 442381b54d7b72..a990d35507a7b7 100644
--- a/test/doctool/test-doctool-html.js
+++ b/test/doctool/test-doctool-html.js
@@ -47,7 +47,15 @@ const testData = [
'
Describe Foobar
in more detail here.
' +
'Foobar II#
' +
- 'Added in: v5.3.0, v4.2.0
' +
+ ' ' +
'Describe Foobar II
in more detail here.
' +
'Deprecated thingy#' +
diff --git a/test/doctool/test-doctool-json.js b/test/doctool/test-doctool-json.js
index ae7b2007b7d2ef..1019728f0fe1f5 100644
--- a/test/doctool/test-doctool-json.js
+++ b/test/doctool/test-doctool-json.js
@@ -89,7 +89,8 @@ const testData = [
textRaw: 'Foobar',
name: 'foobar',
meta: {
- added: ['v1.0.0']
+ added: ['v1.0.0'],
+ changes: []
},
desc: 'Describe Foobar
in more detail ' +
'here.
\n',
@@ -100,7 +101,14 @@ const testData = [
textRaw: 'Foobar II',
name: 'foobar_ii',
meta: {
- added: ['v5.3.0', 'v4.2.0']
+ added: ['v5.3.0', 'v4.2.0'],
+ changes: [
+ { version: 'v4.2.0',
+ 'pr-url': 'https://github.com/nodejs/node/pull/3276',
+ description: 'The `error` parameter can now be ' +
+ 'an arrow function.'
+ }
+ ]
},
desc: 'Describe Foobar II
in more detail ' +
'here.
\n',
@@ -112,7 +120,8 @@ const testData = [
name: 'deprecated_thingy',
meta: {
added: ['v1.0.0'],
- deprecated: ['v2.0.0']
+ deprecated: ['v2.0.0'],
+ changes: []
},
desc: 'Describe Deprecated thingy
in more ' +
'detail here.
\n',
diff --git a/test/fixtures/doc_with_yaml.md b/test/fixtures/doc_with_yaml.md
index 493c2e7e4268b2..cf039c243a482b 100644
--- a/test/fixtures/doc_with_yaml.md
+++ b/test/fixtures/doc_with_yaml.md
@@ -12,6 +12,10 @@ Describe `Foobar` in more detail here.
added:
- v5.3.0
- v4.2.0
+changes:
+ - version: v4.2.0
+ pr-url: https://github.com/nodejs/node/pull/3276
+ description: The `error` parameter can now be an arrow function.
-->
Describe `Foobar II` in more detail here.
diff --git a/tools/doc/common.js b/tools/doc/common.js
index c2f561da806577..ce4995ddff39d1 100644
--- a/tools/doc/common.js
+++ b/tools/doc/common.js
@@ -34,6 +34,11 @@ function extractAndParseYAML(text) {
meta.deprecated = arrify(deprecated);
}
+ meta.changes = meta.changes || [];
+ meta.changes.forEach((entry) => {
+ entry.description = entry.description.replace(/^\^\s*/, '');
+ });
+
return meta;
}
diff --git a/tools/doc/html.js b/tools/doc/html.js
index 3dd6f83da503df..bc5d3167f7bbb4 100644
--- a/tools/doc/html.js
+++ b/tools/doc/html.js
@@ -269,12 +269,40 @@ function parseYAML(text) {
const meta = common.extractAndParseYAML(text);
const html = ['');
@@ -390,3 +418,14 @@ function getId(text) {
}
return text;
}
+
+const numberRe = /^(\d*)/;
+function versionSort(a, b) {
+ a = a.trim();
+ b = b.trim();
+ let i = 0; // common prefix length
+ while (i < a.length && i < b.length && a[i] === b[i]) i++;
+ a = a.substr(i);
+ b = b.substr(i);
+ return +b.match(numberRe)[1] - +a.match(numberRe)[1];
+}