MCPcopy Create free account
hub / github.com/adobe/react-spectrum / parseCodeMeta

Function parseCodeMeta

packages/dev/s2-docs/scripts/generateMarkdownDocs.mjs:2370–2396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2368 if (codeChildren.length > 0) {
2369 // Parse metadata from code blocks to extract type and files
2370 const parseCodeMeta = meta => {
2371 if (!meta) {
2372 return {};
2373 }
2374 const result = {};
2375
2376 // Extract type
2377 const typeMatch = meta.match(/type=["']([^"']+)["']/);
2378 if (typeMatch) {
2379 result.type = typeMatch[1];
2380 }
2381
2382 // Extract files={[...]}
2383 const filesMatch = meta.match(/files=\{(\[[^\]]+\])\}/);
2384 if (filesMatch) {
2385 try {
2386 result.files = JSON.parse(filesMatch[1]);
2387 } catch {
2388 const parsed = parseExpression(filesMatch[1], file);
2389 if (Array.isArray(parsed)) {
2390 result.files = parsed;
2391 }
2392 }
2393 }
2394
2395 return result;
2396 };
2397
2398 const typeToTitle = {
2399 vanilla: 'Vanilla CSS',

Callers 1

Calls 2

parseExpressionFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected