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

Function extractEntry

packages/dev/s2-docs/scripts/generateAgentSkills.mjs:279–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277 };
278
279 const extractEntry = listItem => {
280 const paragraph = listItem.children?.find(child => child.type === 'paragraph');
281 if (!paragraph || !Array.isArray(paragraph.children)) {
282 return null;
283 }
284
285 const linkIndex = paragraph.children.findIndex(child => child.type === 'link');
286 if (linkIndex === -1) {
287 return null;
288 }
289
290 const link = paragraph.children[linkIndex];
291 const title = toText(link).trim();
292 const entryPath = link.url;
293 if (!title || !entryPath) {
294 return null;
295 }
296
297 let description = paragraph.children
298 .slice(linkIndex + 1)
299 .map(toText)
300 .join('')
301 .trim();
302
303 if (description.startsWith(':')) {
304 description = description.slice(1).trim();
305 }
306
307 return {
308 title,
309 path: entryPath,
310 description
311 };
312 };
313
314 const walk = node => {
315 if (!node || !Array.isArray(node.children)) {

Callers 1

walkFunction · 0.85

Calls 2

toTextFunction · 0.85
sliceMethod · 0.80

Tested by

no test coverage detected