Skip to content

Commit

Permalink
docs: inline parsing should honor template location (#6289)
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok authored Apr 30, 2021
1 parent bb84539 commit ba652c1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion utils/doclint/api_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ function applyTemplates(body, params) {
if (node.text && node.text.includes('-inline- = %%')) {
const [name, key] = node.text.split('-inline- = ');
const list = paramsMap.get(key);
const newChildren = [];
if (!list)
throw new Error('Bad template: ' + key);
for (const prop of list.children) {
Expand All @@ -236,12 +237,14 @@ function applyTemplates(body, params) {
throw new Error('Bad template: ' + prop.text);
const children = childrenWithoutProperties(template);
const { name: argName } = parseVariable(children[0].text);
parent.children.push({
newChildren.push({
type: node.type,
text: name + argName,
children: template.children.map(c => md.clone(c))
});
}
const nodeIndex = parent.children.indexOf(node);
parent.children = [...parent.children.slice(0, nodeIndex), ...newChildren, ...parent.children.slice(nodeIndex + 1)];
} else if (node.text && node.text.includes(' = %%')) {
const [name, key] = node.text.split(' = ');
node.text = name;
Expand Down

0 comments on commit ba652c1

Please sign in to comment.