Skip to content

Commit ba652c1

Browse files
authored
docs: inline parsing should honor template location (#6289)
1 parent bb84539 commit ba652c1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

utils/doclint/api_parser.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ function applyTemplates(body, params) {
228228
if (node.text && node.text.includes('-inline- = %%')) {
229229
const [name, key] = node.text.split('-inline- = ');
230230
const list = paramsMap.get(key);
231+
const newChildren = [];
231232
if (!list)
232233
throw new Error('Bad template: ' + key);
233234
for (const prop of list.children) {
@@ -236,12 +237,14 @@ function applyTemplates(body, params) {
236237
throw new Error('Bad template: ' + prop.text);
237238
const children = childrenWithoutProperties(template);
238239
const { name: argName } = parseVariable(children[0].text);
239-
parent.children.push({
240+
newChildren.push({
240241
type: node.type,
241242
text: name + argName,
242243
children: template.children.map(c => md.clone(c))
243244
});
244245
}
246+
const nodeIndex = parent.children.indexOf(node);
247+
parent.children = [...parent.children.slice(0, nodeIndex), ...newChildren, ...parent.children.slice(nodeIndex + 1)];
245248
} else if (node.text && node.text.includes(' = %%')) {
246249
const [name, key] = node.text.split(' = ');
247250
node.text = name;

0 commit comments

Comments
 (0)