MCPcopy Create free account
hub / github.com/Automattic/mongoose / processFile

Function processFile

docs/source/api.js:373–582  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

371}
372
373function processFile(props) {
374 const { docName: name, docFileName } = processName(props.file);
375 /** @type {DocsObj} */
376 const data = {
377 title: name,
378 fileName: docFileName,
379 props: []
380 };
381
382 for (const prop of props) {
383 if (prop.ignore || prop.isPrivate) {
384 continue;
385 }
386
387 /** @type {PropContext} */
388 const ctx = prop.ctx || {};
389
390 // somehow in "dox", it is named "receiver" sometimes, not "constructor"
391 // this is used as a fall-back if the handling below does not overwrite it
392 if ('receiver' in ctx) {
393 ctx.constructor = ctx.receiver;
394 delete ctx.receiver;
395 }
396
397 // in some cases "dox" has "ctx.constructor" defined but set to "undefined", which will later be used for setting "ctx.string"
398 if ('constructor' in ctx && ctx.constructor === undefined) {
399 ctx.constructorWasUndefined = true;
400 }
401 if (!prop.tags) continue;
402 for (const __tag of prop.tags) {
403 // the following has been done, because otherwise no type could be applied for intellisense
404 /** @type {TagObject} */
405 const tag = __tag;
406 switch (tag.type) {
407 case 'see':
408 if (!Array.isArray(ctx.see)) {
409 ctx.see = [];
410 }
411
412 // for this type, it needs to be parsed from the string itself to support more than 1 word
413 // this is required because "@see" is kinda badly defined and mongoose uses a slightly customized way (longer text and different kinds of links)
414
415 ctx.see.push(extractTextUrlFromTag(tag, ctx, true));
416 break;
417 case 'receiver':
418 console.warn(`Found "@receiver" tag in ${ctx.constructor} ${ctx.name}`);
419 break;
420 case 'property':
421 ctx.type = 'property';
422
423 // using "name" over "string" because "string" also contains the type and maybe other stuff
424 ctx.name = tag.name;
425 // only assign "type" if there are types
426 if (tag.types.length > 0) {
427 ctx.type = convertTypesToString(tag.types, tag.typesDescription);
428 }
429
430 break;

Callers 1

parseFileFunction · 0.85

Calls 7

processNameFunction · 0.85
extractTextUrlFromTagFunction · 0.85
convertTypesToStringFunction · 0.85
normalizeHtmlDescriptionFunction · 0.85
buildMarkdownFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected