Skip to content

Repo sync #28481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/codeql-cli/scripts/convert-markdown-for-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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.}
Expand Down
12 changes: 11 additions & 1 deletion src/codeql-cli/scripts/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down