Skip to content

Commit 7f0b962

Browse files
committed
chore: Regenerate llms.txs and add new shared section
1 parent 4721b02 commit 7f0b962

3 files changed

Lines changed: 70 additions & 24 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ In the case you want to setup an automated GitHub workflow to create these API d
114114
3. Follow existing directory structure for consistency
115115
4. Update navigation if adding new product categories
116116

117+
### Updating `llms.txt`
118+
119+
The `public/llms.txt` file is generated from the navigation tree and MDX frontmatter. Run the generator whenever you add, remove, rename, or reorder navigation items, or when you update page descriptions that should appear in `llms.txt`.
120+
121+
```bash
122+
pnpm run generate:llms-txt
123+
```
124+
117125
### Versioning
118126

119127
- Version-specific content in numbered subdirectories (e.g., `contracts/4.x/`)

public/llms.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> Security-first libraries, tools, and infrastructure for building on Ethereum and other blockchains. Covers smart contract libraries for Solidity, Cairo, Stylus, Sui, Midnight, Stellar, Zama FHEVM, and Polkadot; operational tools (Defender, Monitor, Relayer, UI Builder); and the Upgrades Plugins and Contract Wizard.
44

5-
Each ecosystem section lists the smart-contract libraries and language-specific guides for that chain. Cross-ecosystem tools — Defender, Monitor, Relayer, UI Builder, Role Manager — are grouped at the end under "Open Source Tools" to avoid duplication. Unversioned URLs (for example `/contracts/`) redirect to the latest supported version.
5+
Each ecosystem section lists the smart-contract libraries and language-specific guides for that chain. Cross-ecosystem developer libraries and tools are grouped at the end to avoid duplication. Unversioned URLs (for example `/contracts/`) redirect to the latest supported version.
66

77
## Ethereum & EVM
88

@@ -444,6 +444,21 @@ Each ecosystem section lists the smart-contract libraries and language-specific
444444
- [Innovation & Research — Privacy](https://docs.openzeppelin.com/impact/privacy)
445445
- [Innovation & Research — Tokenization & Real World Assets](https://docs.openzeppelin.com/impact/tokenization-and-real-world-assets)
446446

447+
## Developer Libraries
448+
449+
- [Ecosystem Adapters — Overview](https://docs.openzeppelin.com/ecosystem-adapters)
450+
- [Ecosystem Adapters — Architecture](https://docs.openzeppelin.com/ecosystem-adapters/architecture)
451+
- [Ecosystem Adapters — Getting Started](https://docs.openzeppelin.com/ecosystem-adapters/getting-started)
452+
- [Ecosystem Adapters — Supported Ecosystems](https://docs.openzeppelin.com/ecosystem-adapters/supported-ecosystems)
453+
- [Ecosystem Adapters — Building an Adapter](https://docs.openzeppelin.com/ecosystem-adapters/building-an-adapter)
454+
- [UIKit — Overview](https://docs.openzeppelin.com/tools/uikit)
455+
- [UIKit — Getting Started](https://docs.openzeppelin.com/tools/uikit/getting-started)
456+
- [UIKit — Architecture](https://docs.openzeppelin.com/tools/uikit/architecture)
457+
- [UIKit — Components](https://docs.openzeppelin.com/tools/uikit/components)
458+
- [UIKit — React Integration](https://docs.openzeppelin.com/tools/uikit/react-integration)
459+
- [UIKit — Theming & Styling](https://docs.openzeppelin.com/tools/uikit/theming)
460+
- [UIKit — Storage](https://docs.openzeppelin.com/tools/uikit/storage)
461+
447462
## Open Source Tools
448463

449464
- [Relayer — Overview](https://docs.openzeppelin.com/relayer/1.4.x)

scripts/generate-llms-txt.ts

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,15 @@ const INTRO = `# OpenZeppelin Docs
3838
3939
> Security-first libraries, tools, and infrastructure for building on Ethereum and other blockchains. Covers smart contract libraries for Solidity, Cairo, Stylus, Sui, Midnight, Stellar, Zama FHEVM, and Polkadot; operational tools (Defender, Monitor, Relayer, UI Builder); and the Upgrades Plugins and Contract Wizard.
4040
41-
Each ecosystem section lists the smart-contract libraries and language-specific guides for that chain. Cross-ecosystem tools — Defender, Monitor, Relayer, UI Builder, Role Manager — are grouped at the end under "Open Source Tools" to avoid duplication. Unversioned URLs (for example \`/contracts/\`) redirect to the latest supported version.
41+
Each ecosystem section lists the smart-contract libraries and language-specific guides for that chain. Cross-ecosystem developer libraries and tools are grouped at the end to avoid duplication. Unversioned URLs (for example \`/contracts/\`) redirect to the latest supported version.
4242
`;
4343

44-
const SHARED_TOOLS_SEPARATOR = "Open Source Tools";
44+
const SHARED_SECTION_NAMES = [
45+
"Developer Libraries",
46+
"Open Source Tools",
47+
] as const;
48+
type SharedSectionName = (typeof SHARED_SECTION_NAMES)[number];
49+
const SHARED_SECTION_NAME_SET = new Set<string>(SHARED_SECTION_NAMES);
4550

4651
const frontmatterCache = new Map<
4752
string,
@@ -160,18 +165,32 @@ function walk(nodes: NavigationNode[], ctx: WalkContext): void {
160165
}
161166
}
162167

163-
function splitSharedTools(nodes: NavigationNode[]): {
168+
function splitSharedSections(nodes: NavigationNode[]): {
164169
ecosystem: NavigationNode[];
165-
shared: NavigationNode[];
170+
shared: Map<SharedSectionName, NavigationNode[]>;
166171
} {
167-
const separatorIndex = nodes.findIndex(
168-
(n) => n.type === "separator" && n.name === SHARED_TOOLS_SEPARATOR,
169-
);
170-
if (separatorIndex === -1) return { ecosystem: nodes, shared: [] };
171-
return {
172-
ecosystem: nodes.slice(0, separatorIndex),
173-
shared: nodes.slice(separatorIndex + 1),
174-
};
172+
const ecosystem: NavigationNode[] = [];
173+
const shared = new Map<SharedSectionName, NavigationNode[]>();
174+
let currentSharedSection: SharedSectionName | null = null;
175+
176+
for (const node of nodes) {
177+
if (node.type === "separator" && SHARED_SECTION_NAME_SET.has(node.name)) {
178+
currentSharedSection = node.name as SharedSectionName;
179+
if (!shared.has(currentSharedSection)) {
180+
shared.set(currentSharedSection, []);
181+
}
182+
continue;
183+
}
184+
185+
if (currentSharedSection) {
186+
shared.get(currentSharedSection)?.push(node);
187+
continue;
188+
}
189+
190+
ecosystem.push(node);
191+
}
192+
193+
return { ecosystem, shared };
175194
}
176195

177196
function mergeByName(nodes: NavigationNode[]): NavigationNode[] {
@@ -234,12 +253,11 @@ function renderSection(
234253
}
235254

236255
function main(): void {
237-
const sharedSeen = new Set<string>();
238256
const ecosystemSections: string[] = [];
239-
const sharedToolNodes: NavigationNode[] = [];
257+
const sharedSectionNodes = new Map<SharedSectionName, NavigationNode[]>();
240258

241259
for (const tree of TREES) {
242-
const { ecosystem, shared } = splitSharedTools(tree.children);
260+
const { ecosystem, shared } = splitSharedSections(tree.children);
243261

244262
const section = renderSection(
245263
`## ${tree.name}`,
@@ -248,17 +266,22 @@ function main(): void {
248266
);
249267
if (section) ecosystemSections.push(section);
250268

251-
for (const node of shared) sharedToolNodes.push(node);
269+
for (const [sectionName, nodes] of shared) {
270+
const existing = sharedSectionNodes.get(sectionName) ?? [];
271+
sharedSectionNodes.set(sectionName, [...existing, ...nodes]);
272+
}
252273
}
253274

254-
const toolsSection = renderSection(
255-
`## Open Source Tools`,
256-
mergeByName(sharedToolNodes),
257-
sharedSeen,
258-
);
259-
260275
const parts = [INTRO, ...ecosystemSections];
261-
if (toolsSection) parts.push(toolsSection);
276+
for (const sectionName of SHARED_SECTION_NAMES) {
277+
const nodes = sharedSectionNodes.get(sectionName) ?? [];
278+
const section = renderSection(
279+
`## ${sectionName}`,
280+
mergeByName(nodes),
281+
new Set<string>(),
282+
);
283+
if (section) parts.push(section);
284+
}
262285

263286
writeFileSync(OUTPUT_PATH, parts.join("\n"), "utf8");
264287

0 commit comments

Comments
 (0)