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

Function extractEntry

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

Source from the content-addressed store, hash-verified

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