|
1 | 1 | import { execFile } from 'node:child_process'; |
2 | | -import { cp, readFile, writeFile } from 'node:fs/promises'; |
| 2 | +import { cp, readFile } from 'node:fs/promises'; |
3 | 3 | import { statSync } from 'node:fs'; |
4 | 4 | import { promisify } from 'node:util'; |
5 | 5 |
|
6 | 6 | const execFileAsync = promisify(execFile); |
7 | 7 |
|
8 | | -// TODO: Have doc-kit understand that some pages don't have meaningful information |
9 | | -// The llms-txt generator lists every page with a depth-1 heading. JSX-driven |
10 | | -// pages like the homepage produce entries with no title or description — drop |
11 | | -// them, they carry no information for LLMs. |
12 | | -const cleanLlmsTxt = async path => { |
13 | | - const content = await readFile(path, 'utf8'); |
14 | | - const cleaned = content |
15 | | - .split('\n') |
16 | | - .filter(line => !line.startsWith('- [](')) |
17 | | - .join('\n'); |
18 | | - await writeFile(path, cleaned); |
19 | | -}; |
20 | | - |
21 | 8 | const runDocKit = version => |
22 | 9 | execFileAsync( |
23 | 10 | 'npx', |
@@ -50,10 +37,8 @@ const versions = JSON.parse(await readFile('./versions.json')); |
50 | 37 |
|
51 | 38 | for (const version of versions) { |
52 | 39 | await runDocKit(version); |
53 | | - await cleanLlmsTxt(`./out/docs/api/v${version.match(/\d+/)[0]}.x/llms.txt`); |
54 | 40 | } |
55 | 41 | await runDocKit(); |
56 | | -await cleanLlmsTxt('./out/llms.txt'); |
57 | 42 |
|
58 | 43 | // Publish the markdown sources next to the rendered pages so the llms.txt |
59 | 44 | // links (`{path}.md`) resolve to LLM-friendly raw markdown. |
|
0 commit comments