Skip to content

Commit e06269f

Browse files
authored
docs: improve markdown docs script (#8970)
* docs: improve markdown docs script * include page descriptions in initial mcp index build
1 parent ddd77c7 commit e06269f

File tree

4 files changed

+1004
-162
lines changed

4 files changed

+1004
-162
lines changed

packages/dev/mcp/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,18 @@ async function buildPageIndex(library: Library): Promise<PageInfo[]> {
120120
// Read llms.txt to enumerate available pages without downloading them all.
121121
const llmsUrl = `${libBaseUrl(library)}/llms.txt`;
122122
const txt = await fetchText(llmsUrl);
123-
const re = /^\s*-\s*\[([^\]]+)\]\(([^)]+)\)\s*$/;
123+
const re = /^\s*-\s*\[([^\]]+)\]\(([^)]+)\)(?:\s*:\s*(.*))?\s*$/;
124124
for (const line of txt.split(/\r?\n/)) {
125125
const m = line.match(re);
126126
if (!m) {continue;}
127127
const display = (m[1] || '').trim();
128128
const href = (m[2] || '').trim();
129+
const desc = (m[3] || '').trim() || undefined;
129130
if (!href || !/\.md$/i.test(href)) {continue;}
130131
const key = href.replace(/\.md$/i, '').replace(/\\/g, '/');
131132
const title = display || path.basename(key);
132133
const url = `${DEFAULT_CDN_BASE}/${key}.md`;
133-
const info: PageInfo = {key, title, description: undefined, filePath: url, sections: []};
134+
const info: PageInfo = {key, title, description: desc, filePath: url, sections: []};
134135
pages.push(info);
135136
pageCache.set(info.key, info);
136137
}

packages/dev/s2-docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
}
2828
},
2929
"dependencies": {
30+
"@babel/parser": "^7.26.3",
3031
"@parcel/plugin": "^2.16.0",
3132
"@parcel/rsc": "^2.16.0",
3233
"@react-aria/focus": "^3.20.4",

0 commit comments

Comments
 (0)