Skip to content

Commit cdd3a0e

Browse files
authored
Merge pull request #28481 from github/repo-sync
Repo sync
2 parents 9ed10cf + e5aece3 commit cdd3a0e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/codeql-cli/scripts/convert-markdown-for-docs.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const { targetDirectory, removeKeywords } = JSON.parse(
1414
await readFile(path.join('src/codeql-cli/lib/config.json'), 'utf-8'),
1515
)
1616
const RELATIVE_LINK_PATH = targetDirectory.replace('content', '')
17-
const LAST_PRIMARY_HEADING = 'Options'
17+
const LAST_PRIMARY_HEADING = 'Primary options'
1818
const HEADING_BEGIN = '::: {.option}\n'
1919
const END_SECTION = '\n:::'
2020
const PROGRAM_SECTION = '::: {.program}\n'
@@ -37,11 +37,6 @@ export async function convertContentToDocs(content, frontmatterDefaults = {}) {
3737
frontmatter.title = node.children[0].value
3838
}
3939

40-
// The level 2 heading "Options" should be displayed as "Primary options"
41-
if (node.depth === 2 && node.children[0].value === 'Options') {
42-
node.children[0].value = 'Primary options'
43-
}
44-
4540
// There are some headings that include a title followed by
4641
// some markup that looks like
4742
// {#options-to-configure-the-package-manager.}

src/codeql-cli/scripts/sync.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,17 @@ async function main() {
3535

3636
for (const file of markdownFiles) {
3737
const sourceContent = await readFile(file, 'utf8')
38-
const { data, content } = await convertContentToDocs(sourceContent)
38+
// There is a missing heading in the source content called "Primary Options"
39+
// It should be directory under the "Options" heading.
40+
// It's a quite a bit more complicated to add new nodes in the AST when
41+
// the node isn't a child of the previous heading. It's pretty easy to
42+
// just append a second heading here.
43+
const matchHeading = '## Options\n'
44+
const primaryHeadingSourceContent = sourceContent.replace(
45+
matchHeading,
46+
matchHeading + '\n### Primary Options\n',
47+
)
48+
const { data, content } = await convertContentToDocs(primaryHeadingSourceContent)
3949
await writeFile(file, matter.stringify(content, data))
4050
const targetFilename = path.join(targetDirectory, path.basename(file))
4151
const sourceData = { ...data, ...frontmatterDefaults }

0 commit comments

Comments
 (0)