Skip to content

Commit 4e21715

Browse files
committed
Generate llms.txt and llms-full.txt files per section
1 parent 8fc2621 commit 4e21715

File tree

4 files changed

+260
-3
lines changed

4 files changed

+260
-3
lines changed

docusaurus.config.js

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,169 @@ const config = {
317317
containerId: 'GTM-5FGPLC2Q',
318318
},
319319
],
320+
[
321+
'docusaurus-plugin-llms',
322+
{
323+
// Set docsDir to site root to collect from all directories
324+
docsDir: '.',
325+
// Disable default files since we're generating section-specific files
326+
generateLLMsTxt: false,
327+
generateLLMsFullTxt: false,
328+
// Ignore common non-doc directories
329+
// Note: src/pages/** is not ignored so tutorials can be collected
330+
// Each customLLMFiles entry filters by includePatterns, so only matching files are included
331+
ignoreFiles: [
332+
'node_modules/**',
333+
'build/**',
334+
'.docusaurus/**',
335+
'static/**',
336+
'src/components/**',
337+
'src/theme/**',
338+
'src/lib/**',
339+
'src/config/**',
340+
'src/hooks/**',
341+
'src/utils/**',
342+
'src/plugins/**',
343+
'src/specs/**',
344+
'src/client/**',
345+
'src/scss/**',
346+
'i18n/**',
347+
'*.config.js',
348+
'*.json',
349+
'*.lock',
350+
'README.md', // Ignore root-level README
351+
'CONTRIBUTING.md', // Ignore root-level CONTRIBUTING
352+
'gator_versioned_docs/**', // Versioned docs handled separately
353+
],
354+
// Content cleaning options
355+
excludeImports: true,
356+
removeDuplicateHeadings: true,
357+
// Generate separate files for each section
358+
// Files will be organized into subdirectories by the post-build script
359+
customLLMFiles: [
360+
// Embedded Wallets
361+
{
362+
filename: 'llms-embedded-wallets.txt',
363+
includePatterns: ['embedded-wallets/**/*.{md,mdx}'],
364+
fullContent: false,
365+
title: 'MetaMask Embedded Wallets Documentation',
366+
description: 'Documentation links for MetaMask Embedded Wallets',
367+
},
368+
{
369+
filename: 'llms-embedded-wallets-full.txt',
370+
includePatterns: ['embedded-wallets/**/*.{md,mdx}'],
371+
fullContent: true,
372+
title: 'MetaMask Embedded Wallets Documentation',
373+
description: 'Complete documentation for MetaMask Embedded Wallets',
374+
},
375+
// SDK
376+
{
377+
filename: 'llms-sdk.txt',
378+
includePatterns: ['sdk/**/*.{md,mdx}'],
379+
fullContent: false,
380+
title: 'MetaMask SDK Documentation',
381+
description: 'Documentation links for MetaMask SDK',
382+
},
383+
{
384+
filename: 'llms-sdk-full.txt',
385+
includePatterns: ['sdk/**/*.{md,mdx}'],
386+
fullContent: true,
387+
title: 'MetaMask SDK Documentation',
388+
description: 'Complete documentation for MetaMask SDK',
389+
},
390+
// Smart Accounts Kit
391+
{
392+
filename: 'llms-smart-accounts-kit.txt',
393+
includePatterns: ['smart-accounts-kit/**/*.{md,mdx}'],
394+
fullContent: false,
395+
title: 'MetaMask Smart Accounts Kit Documentation',
396+
description: 'Documentation links for MetaMask Smart Accounts Kit',
397+
},
398+
{
399+
filename: 'llms-smart-accounts-kit-full.txt',
400+
includePatterns: ['smart-accounts-kit/**/*.{md,mdx}'],
401+
fullContent: true,
402+
title: 'MetaMask Smart Accounts Kit Documentation',
403+
description: 'Complete documentation for MetaMask Smart Accounts Kit',
404+
},
405+
// Snaps
406+
{
407+
filename: 'llms-snaps.txt',
408+
includePatterns: ['snaps/**/*.{md,mdx}'],
409+
fullContent: false,
410+
title: 'MetaMask Snaps Documentation',
411+
description: 'Documentation links for MetaMask Snaps',
412+
},
413+
{
414+
filename: 'llms-snaps-full.txt',
415+
includePatterns: ['snaps/**/*.{md,mdx}'],
416+
fullContent: true,
417+
title: 'MetaMask Snaps Documentation',
418+
description: 'Complete documentation for MetaMask Snaps',
419+
},
420+
// Wallet
421+
{
422+
filename: 'llms-wallet.txt',
423+
includePatterns: ['wallet/**/*.{md,mdx}'],
424+
fullContent: false,
425+
title: 'MetaMask Wallet API Documentation',
426+
description: 'Documentation links for MetaMask Wallet API',
427+
},
428+
{
429+
filename: 'llms-wallet-full.txt',
430+
includePatterns: ['wallet/**/*.{md,mdx}'],
431+
fullContent: true,
432+
title: 'MetaMask Wallet API Documentation',
433+
description: 'Complete documentation for MetaMask Wallet API',
434+
},
435+
// Tutorials
436+
{
437+
filename: 'llms-tutorials.txt',
438+
includePatterns: ['src/pages/tutorials/**/*.{md,mdx}'],
439+
fullContent: false,
440+
title: 'MetaMask Tutorials',
441+
description: 'Documentation links for MetaMask tutorials',
442+
},
443+
{
444+
filename: 'llms-tutorials-full.txt',
445+
includePatterns: ['src/pages/tutorials/**/*.{md,mdx}'],
446+
fullContent: true,
447+
title: 'MetaMask Tutorials',
448+
description: 'Complete MetaMask tutorials documentation',
449+
},
450+
// Dashboard
451+
{
452+
filename: 'llms-dashboard.txt',
453+
includePatterns: ['developer-tools/dashboard/**/*.{md,mdx}'],
454+
fullContent: false,
455+
title: 'MetaMask Developer Dashboard Documentation',
456+
description: 'Documentation links for MetaMask Developer Dashboard',
457+
},
458+
{
459+
filename: 'llms-dashboard-full.txt',
460+
includePatterns: ['developer-tools/dashboard/**/*.{md,mdx}'],
461+
fullContent: true,
462+
title: 'MetaMask Developer Dashboard Documentation',
463+
description: 'Complete documentation for MetaMask Developer Dashboard',
464+
},
465+
// Services
466+
{
467+
filename: 'llms-services.txt',
468+
includePatterns: ['services/**/*.{md,mdx}'],
469+
fullContent: false,
470+
title: 'MetaMask Services Documentation',
471+
description: 'Documentation links for MetaMask Services',
472+
},
473+
{
474+
filename: 'llms-services-full.txt',
475+
includePatterns: ['services/**/*.{md,mdx}'],
476+
fullContent: true,
477+
title: 'MetaMask Services Documentation',
478+
description: 'Complete documentation for MetaMask Services',
479+
},
480+
],
481+
},
482+
],
320483
],
321484
clientModules: [require.resolve('./src/client/scroll-fix.js')],
322485
themeConfig:

package-lock.json

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"docusaurus": "docusaurus",
88
"start": "docusaurus start -p 3003",
9-
"build": "docusaurus build",
9+
"build": "docusaurus build && node scripts/organize-llms-files.js",
1010
"swizzle": "docusaurus swizzle",
1111
"deploy": "docusaurus deploy",
1212
"clear": "docusaurus clear",
@@ -38,10 +38,10 @@
3838
"@docusaurus/remark-plugin-npm2yarn": "3.9.2",
3939
"@docusaurus/theme-common": "3.9.2",
4040
"@docusaurus/theme-mermaid": "3.9.2",
41-
"@mermaid-js/layout-elk": "^0.1.9",
4241
"@intercom/messenger-js-sdk": "^0.0.14",
4342
"@lottiefiles/react-lottie-player": "^3.6.0",
4443
"@mdx-js/react": "^3.1.0",
44+
"@mermaid-js/layout-elk": "^0.1.9",
4545
"@metamask/design-tokens": "^7.1.0",
4646
"@metamask/eth-sig-util": "^7.0.3",
4747
"@metamask/profile-sync-controller": "^16.0.0",
@@ -95,6 +95,7 @@
9595
"@types/react-alert": "^7.0.6",
9696
"@types/react-modal": "^3.16.3",
9797
"@typescript-eslint/parser": "^8.46.2",
98+
"docusaurus-plugin-llms": "^0.2.2",
9899
"eslint": "^9.35.0",
99100
"eslint-plugin-react": "^7.37.5",
100101
"stylelint": "^15.0.0 ",

scripts/organize-llms-files.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* Post-build script to organize LLM files into section-specific directories
3+
* This script moves files from the root build directory into their respective section folders
4+
*/
5+
6+
const fs = require('fs');
7+
const path = require('path');
8+
9+
const buildDir = path.join(__dirname, '..', 'build');
10+
11+
// Mapping of source files to destination paths
12+
const fileMappings = [
13+
// Embedded Wallets
14+
{ from: 'llms-embedded-wallets.txt', to: 'embedded-wallets/llms.txt' },
15+
{ from: 'llms-embedded-wallets-full.txt', to: 'embedded-wallets/llms-full.txt' },
16+
// SDK
17+
{ from: 'llms-sdk.txt', to: 'sdk/llms.txt' },
18+
{ from: 'llms-sdk-full.txt', to: 'sdk/llms-full.txt' },
19+
// Smart Accounts Kit
20+
{ from: 'llms-smart-accounts-kit.txt', to: 'smart-accounts-kit/llms.txt' },
21+
{ from: 'llms-smart-accounts-kit-full.txt', to: 'smart-accounts-kit/llms-full.txt' },
22+
// Snaps
23+
{ from: 'llms-snaps.txt', to: 'snaps/llms.txt' },
24+
{ from: 'llms-snaps-full.txt', to: 'snaps/llms-full.txt' },
25+
// Wallet
26+
{ from: 'llms-wallet.txt', to: 'wallet/llms.txt' },
27+
{ from: 'llms-wallet-full.txt', to: 'wallet/llms-full.txt' },
28+
// Tutorials
29+
{ from: 'llms-tutorials.txt', to: 'tutorials/llms.txt' },
30+
{ from: 'llms-tutorials-full.txt', to: 'tutorials/llms-full.txt' },
31+
// Dashboard
32+
{ from: 'llms-dashboard.txt', to: 'developer-tools/dashboard/llms.txt' },
33+
{ from: 'llms-dashboard-full.txt', to: 'developer-tools/dashboard/llms-full.txt' },
34+
// Services
35+
{ from: 'llms-services.txt', to: 'services/llms.txt' },
36+
{ from: 'llms-services-full.txt', to: 'services/llms-full.txt' },
37+
];
38+
39+
function organizeFiles() {
40+
if (!fs.existsSync(buildDir)) {
41+
console.warn(`Build directory not found: ${buildDir}`);
42+
return;
43+
}
44+
45+
let movedCount = 0;
46+
let skippedCount = 0;
47+
48+
for (const mapping of fileMappings) {
49+
const sourcePath = path.join(buildDir, mapping.from);
50+
const destPath = path.join(buildDir, mapping.to);
51+
const destDir = path.dirname(destPath);
52+
53+
// Check if source file exists
54+
if (!fs.existsSync(sourcePath)) {
55+
console.log(`Skipping ${mapping.from} (not found)`);
56+
skippedCount++;
57+
continue;
58+
}
59+
60+
// Create destination directory if it doesn't exist
61+
if (!fs.existsSync(destDir)) {
62+
fs.mkdirSync(destDir, { recursive: true });
63+
console.log(`Created directory: ${destDir}`);
64+
}
65+
66+
// Move the file
67+
fs.renameSync(sourcePath, destPath);
68+
console.log(`Moved: ${mapping.from} -> ${mapping.to}`);
69+
movedCount++;
70+
}
71+
72+
console.log(`\nOrganized ${movedCount} files, skipped ${skippedCount} files`);
73+
}
74+
75+
organizeFiles();
76+

0 commit comments

Comments
 (0)