in site/src/buildtime/fetchFusionDocFromGithub/fetchFusionDoc.ts [89:121]
function getAPINodes(ast: mdast.Root) {
let startIndex = -1
let endIndex = -1
let APIheaderLevel = -1
ast.children.forEach((node: mdast.Content, index: number) => {
if (
startIndex < 0 &&
node.type === 'heading' &&
node.children[0] &&
node.children[0].type === 'text' &&
/^APIs?$/i.test(node.children[0].value as string)
) {
startIndex = index
APIheaderLevel = node.depth
return
}
if (startIndex < 0) return
if (
endIndex < 0 &&
node.type === 'heading' &&
node.depth <= APIheaderLevel
) {
endIndex = index
}
})
if (startIndex < 0) {
throw new Error(`can't find API header!`)
}
if (endIndex < 0) {
endIndex = ast.children.length
}
return ast.children.slice(startIndex + 1, endIndex)
}