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

Function processFile

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

Source from the content-addressed store, hash-verified

240}
241
242function processFile(props) {
243 const { docName: name, docFileName } = processName(props.file);
244 /** @type {DocsObj} */
245 const data = {
246 title: name,
247 fileName: docFileName,
248 props: []
249 };
250
251 for (const prop of props) {
252 if (prop.ignore || prop.isPrivate) {
253 continue;
254 }
255
256 /** @type {PropContext} */
257 const ctx = prop.ctx || {};
258
259 // somehow in "dox", it is named "receiver" sometimes, not "constructor"
260 // this is used as a fall-back if the handling below does not overwrite it
261 if ('receiver' in ctx) {
262 ctx.constructor = ctx.receiver;
263 delete ctx.receiver;
264 }
265
266 // in some cases "dox" has "ctx.constructor" defined but set to "undefined", which will later be used for setting "ctx.string"
267 if ('constructor' in ctx && ctx.constructor === undefined) {
268 ctx.constructorWasUndefined = true;
269 }
270
271 for (const __tag of prop.tags) {
272 // the following has been done, because otherwise no type could be applied for intellisense
273 /** @type {TagObject} */
274 const tag = __tag;
275 switch (tag.type) {
276 case 'see':
277 if (!Array.isArray(ctx.see)) {
278 ctx.see = [];
279 }
280
281 // for this type, it needs to be parsed from the string itself to support more than 1 word
282 // this is required because "@see" is kinda badly defined and mongoose uses a slightly customized way (longer text and different kinds of links)
283
284 ctx.see.push(extractTextUrlFromTag(tag, ctx, true));
285 break;
286 case 'receiver':
287 console.warn(`Found "@receiver" tag in ${ctx.constructor} ${ctx.name}`);
288 break;
289 case 'property':
290 ctx.type = 'property';
291
292 // using "name" over "string" because "string" also contains the type and maybe other stuff
293 ctx.name = tag.name;
294 // only assign "type" if there are types
295 if (tag.types.length > 0) {
296 ctx.type = convertTypesToString(tag.types);
297 }
298
299 break;

Callers 1

parseFileFunction · 0.85

Calls 4

processNameFunction · 0.85
extractTextUrlFromTagFunction · 0.85
convertTypesToStringFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected