Add CodeQL CLI missing heading (#43114)
This commit is contained in:
@@ -14,7 +14,7 @@ const { targetDirectory, removeKeywords } = JSON.parse(
|
||||
await readFile(path.join('src/codeql-cli/lib/config.json'), 'utf-8'),
|
||||
)
|
||||
const RELATIVE_LINK_PATH = targetDirectory.replace('content', '')
|
||||
const LAST_PRIMARY_HEADING = 'Options'
|
||||
const LAST_PRIMARY_HEADING = 'Primary options'
|
||||
const HEADING_BEGIN = '::: {.option}\n'
|
||||
const END_SECTION = '\n:::'
|
||||
const PROGRAM_SECTION = '::: {.program}\n'
|
||||
@@ -37,11 +37,6 @@ export async function convertContentToDocs(content, frontmatterDefaults = {}) {
|
||||
frontmatter.title = node.children[0].value
|
||||
}
|
||||
|
||||
// The level 2 heading "Options" should be displayed as "Primary options"
|
||||
if (node.depth === 2 && node.children[0].value === 'Options') {
|
||||
node.children[0].value = 'Primary options'
|
||||
}
|
||||
|
||||
// There are some headings that include a title followed by
|
||||
// some markup that looks like
|
||||
// {#options-to-configure-the-package-manager.}
|
||||
|
||||
@@ -35,7 +35,17 @@ async function main() {
|
||||
|
||||
for (const file of markdownFiles) {
|
||||
const sourceContent = await readFile(file, 'utf8')
|
||||
const { data, content } = await convertContentToDocs(sourceContent)
|
||||
// There is a missing heading in the source content called "Primary Options"
|
||||
// It should be directory under the "Options" heading.
|
||||
// It's a quite a bit more complicated to add new nodes in the AST when
|
||||
// the node isn't a child of the previous heading. It's pretty easy to
|
||||
// just append a second heading here.
|
||||
const matchHeading = '## Options\n'
|
||||
const primaryHeadingSourceContent = sourceContent.replace(
|
||||
matchHeading,
|
||||
matchHeading + '\n### Primary Options\n',
|
||||
)
|
||||
const { data, content } = await convertContentToDocs(primaryHeadingSourceContent)
|
||||
await writeFile(file, matter.stringify(content, data))
|
||||
const targetFilename = path.join(targetDirectory, path.basename(file))
|
||||
const sourceData = { ...data, ...frontmatterDefaults }
|
||||
|
||||
Reference in New Issue
Block a user