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

Function extractLabel

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

Source from the content-addressed store, hash-verified

2565 const newNodes = [];
2566
2567 const extractLabel = itemNode => {
2568 const labelAttr = itemNode.attributes?.find(a => a.name === 'label');
2569 if (!labelAttr) {
2570 return null;
2571 }
2572
2573 if (labelAttr.value?.type === 'mdxJsxAttributeValueExpression') {
2574 return labelAttr.value.value.replace(/['"`]/g, '').trim();
2575 }
2576
2577 if (typeof labelAttr.value === 'string') {
2578 return labelAttr.value.trim();
2579 }
2580
2581 return null;
2582 };
2583
2584 bundlerItems.forEach(itemNode => {
2585 const label = extractLabel(itemNode) || 'Configuration';

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected