Skip to content

Commit 2925412

Browse files
style: fix format
1 parent 404bfa9 commit 2925412

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

migrate/migrate-bot.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,26 +100,32 @@ async function fetchPageContent(
100100
async function loadSlugMap(): Promise<Map<string, string | null>> {
101101
const mapPath = path.join(__dirname, "slug_map.json");
102102
const data = await readFile(mapPath, "utf8");
103-
const arr = JSON.parse(data) as Array<{ cppref: string; cppdoc: string | null }>;
103+
const arr = JSON.parse(data) as Array<{
104+
cppref: string;
105+
cppdoc: string | null;
106+
}>;
104107
const map = new Map<string, string | null>();
105108
for (const entry of arr) {
106109
map.set(entry.cppref, entry.cppdoc);
107110
}
108111
return map;
109112
}
110113

111-
function replaceDocLinks(content: string, slugMap: Map<string, string | null>): string {
114+
function replaceDocLinks(
115+
content: string,
116+
slugMap: Map<string, string | null>
117+
): string {
112118
const docLinkRegex = /<DocLink\s+([^>]*)>/g;
113119
return content.replace(docLinkRegex, (match, attributes) => {
114120
const srcMatch = attributes.match(/src\s*=\s*["']([^"']+)["']/);
115121
if (!srcMatch) {
116122
return match;
117123
}
118124
const src = srcMatch[1];
119-
if (!src.startsWith('/')) {
125+
if (!src.startsWith("/")) {
120126
return match;
121127
}
122-
const key = src.slice(1).replace(/\.html$/, '');
128+
const key = src.slice(1).replace(/\.html$/, "");
123129
const mapped = slugMap.get(key);
124130
let newSrc: string;
125131
if (mapped === undefined) {
@@ -143,7 +149,7 @@ async function convertToMDX(
143149
"{{LLM_DOCS}}",
144150
await readFile(
145151
__dirname +
146-
"/../src/content/docs/development/guide/component-docs-for-llm.mdx",
152+
"/../src/content/docs/development/guide/component-docs-for-llm.mdx",
147153
"utf8"
148154
)
149155
);
@@ -308,7 +314,7 @@ async function writeMDXFile(
308314
await fs.mkdir(dir, { recursive: true });
309315
const frontmatter = `---
310316
title: ${JSON.stringify(title)}
311-
cppref-url: ${cpprefUrl ? JSON.stringify(cpprefUrl) : 'null'}
317+
cppref-url: ${cpprefUrl ? JSON.stringify(cpprefUrl) : "null"}
312318
---\n\n`;
313319
await fs.writeFile(filePath, frontmatter + content, "utf8");
314320
console.log(`Written to ${filePath}`);
@@ -509,11 +515,11 @@ async function main() {
509515
if (res.status !== 0) {
510516
throw new Error(
511517
"Build failed, possibly due to issues with the generated MDX:" +
512-
res.stderr?.toString() +
513-
res.stdout?.toString() +
514-
res.error?.toString() +
515-
" exit code " +
516-
res.status
518+
res.stderr?.toString() +
519+
res.stdout?.toString() +
520+
res.error?.toString() +
521+
" exit code " +
522+
res.status
517523
);
518524
}
519525

migrate/update-migrate-progress.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ async function isMigrated(entry: string): Promise<boolean> {
3535
return (await fileExists(mdxPath)) || (await fileExists(indexPath));
3636
}
3737

38-
function generateUrls(entry: SlugMapItem): Omit<EntryStatus, "entry" | "migrated"> {
38+
function generateUrls(
39+
entry: SlugMapItem
40+
): Omit<EntryStatus, "entry" | "migrated"> {
3941
const cpprefUrl = `http://en.cppreference.com/w/${entry.cppref}.html`;
4042
const cppdocUrl = `http://cppdoc.cc/${entry.cppdoc}`;
4143
const issueUrl = `https://github.com/cppdoc-cc/cppdoc/issues/new?title=${encodeURIComponent(cpprefUrl)}&labels=migrate-cppref-page`;
@@ -47,8 +49,9 @@ function generateMarkdown(status: EntryStatus): string {
4749
if (migrated) {
4850
return `| ✅ | [cppref](${cpprefUrl}) | [cppdoc](${cppdocUrl}) | \`${entry}\` | `;
4951
} else {
50-
return `| ❌ | [cppref](${cpprefUrl}) | ${entry.cppdoc ? `[create](${issueUrl})` : "N/A"
51-
} | \`${entry}\` |`;
52+
return `| ❌ | [cppref](${cpprefUrl}) | ${
53+
entry.cppdoc ? `[create](${issueUrl})` : "N/A"
54+
} | \`${entry}\` |`;
5255
}
5356
}
5457

0 commit comments

Comments
 (0)