1
0
mirror of synced 2026-01-20 21:02:43 -05:00

fix markdown content generation in codeql cli manual pages (#36014)

This commit is contained in:
Rachael Sewell
2023-03-30 14:50:17 -07:00
committed by GitHub
parent 2201c9bff4
commit 8585eacd7d
3 changed files with 43 additions and 9 deletions

View File

@@ -174,6 +174,29 @@ export async function convertContentToDocs(content, frontmatterDefaults = {}) {
if (node.type === 'link' && node.url.includes('aka.ms')) {
akaMsLinkMatches.push(node)
}
// There are example links in the format https://containers.GHEHOSTNAME
// that we don't want our link checker to check so we need to make them
// inline code instead of links. Ideally, this should be done in the
// Java program that generates the rst files, but we can do it here for now.
// See https://github.com/syntax-tree/mdast#inlinecode
if (node.type === 'link' && node.url.startsWith('https://containers')) {
// The nodes before and after contain double quotes that we want to remove
const nodeBefore = ancestors[ancestors.length - 1].children[0]
const nodeAfter = ancestors[ancestors.length - 1].children[2]
if (nodeBefore.value.endsWith('"')) {
nodeBefore.value = nodeBefore.value.slice(0, -1)
}
if (nodeAfter.value.startsWith('"')) {
nodeAfter.value = nodeAfter.value.slice(1)
}
// Change the node to an inline code node
node.type = 'inlineCode'
node.value = node.url
node.title = undefined
node.url = undefined
node.children = undefined
}
})
// Convert all aka.ms links to the docs.github.com relative path

View File

@@ -9,10 +9,7 @@ import path from 'path'
import matter from 'gray-matter'
import rimraf from 'rimraf'
import {
updateContentDirectory,
MARKDOWN_COMMENT,
} from '../../automated-pipelines/lib/update-markdown.js'
import { updateContentDirectory } from '../../automated-pipelines/lib/update-markdown.js'
import { convertContentToDocs } from './convert-markdown-for-docs.js'
const { targetDirectory, sourceDirectory, frontmatterDefaults, markdownPrefix } = JSON.parse(
@@ -20,6 +17,7 @@ const { targetDirectory, sourceDirectory, frontmatterDefaults, markdownPrefix }
)
const SOURCE_REPO = sourceDirectory.split('/')[0]
const TEMP_DIRECTORY = path.join(SOURCE_REPO, 'tempCliDocs')
const MARKDOWN_PREFIX = `${markdownPrefix}\n\n`
main()
@@ -41,7 +39,7 @@ async function main() {
await writeFile(file, matter.stringify(content, data))
const targetFilename = path.join(targetDirectory, path.basename(file))
const sourceData = { ...data, ...frontmatterDefaults }
const finalSourceContent = MARKDOWN_COMMENT + `${markdownPrefix}\n\n` + content
const finalSourceContent = MARKDOWN_PREFIX + content
cliMarkdownContents[targetFilename] = { data: sourceData, content: finalSourceContent }
}
// Begin updating Markdown files in the content directory