MCPcopy
hub / github.com/jsdoc/jsdoc / addTutorialConf

Function addTutorialConf

lib/jsdoc/tutorial/resolver.js:48–75  ·  view source on GitHub ↗

* Helper function that adds tutorial configuration to the `conf` variable. This helps when multiple * tutorial configurations are specified in one object, or when a tutorial's children are specified * as tutorial configurations as opposed to an array of tutorial names. * * Recurses as necessary

(name, meta)

Source from the content-addressed store, hash-verified

46 * child tutorials.
47 */
48function addTutorialConf(name, meta) {
49 let names;
50
51 if (isTutorialJSON(meta)) {
52 // if the children are themselves tutorial defintions as opposed to an
53 // array of strings, add each child.
54 if (hasOwnProp.call(meta, 'children') && !Array.isArray(meta.children)) {
55 names = Object.keys(meta.children);
56 for (let childName of names) {
57 addTutorialConf(childName, meta.children[childName]);
58 }
59 // replace with an array of names.
60 meta.children = names;
61 }
62 // check if the tutorial has already been defined...
63 if (hasOwnProp.call(conf, name)) {
64 logger.warn(`Metadata for the tutorial ${name} is defined more than once. Only the first definition will be used.`);
65 } else {
66 conf[name] = meta;
67 }
68 } else {
69 // keys are tutorial names, values are `Tutorial` instances
70 names = Object.keys(meta);
71 for (let tutorialName of names) {
72 addTutorialConf(tutorialName, meta[tutorialName]);
73 }
74 }
75}
76
77/**
78 * Add a tutorial.

Callers 1

resolver.jsFile · 0.85

Calls 1

isTutorialJSONFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…