MCPcopy
hub / github.com/jsdoc/jsdoc / setModuleScopeMemberOf

Function setModuleScopeMemberOf

lib/jsdoc/src/handlers.js:92–142  ·  view source on GitHub ↗
(parser, doclet)

Source from the content-addressed store, hash-verified

90}
91
92function setModuleScopeMemberOf(parser, doclet) {
93 let parentDoclet;
94 let skipMemberof;
95
96 // handle module symbols that are _not_ assigned to module.exports
97 if (currentModule && currentModule.longname !== doclet.name) {
98 if (!doclet.scope) {
99 // is this a method definition? if so, we usually get the scope from the node directly
100 if (doclet.meta && doclet.meta.code && doclet.meta.code.node &&
101 doclet.meta.code.node.type === Syntax.MethodDefinition) {
102 // special case for constructors of classes that have @alias tags
103 if (doclet.meta.code.node.kind === 'constructor') {
104 parentDoclet = parser._getDocletById(
105 doclet.meta.code.node.parent.parent.nodeId
106 );
107
108 if (parentDoclet && parentDoclet.alias) {
109 // the constructor should use the same name as the class
110 doclet.addTag('alias', parentDoclet.alias);
111 doclet.addTag('name', parentDoclet.alias);
112
113 // and we shouldn't try to set a memberof value
114 skipMemberof = true;
115 }
116 }
117 else if (doclet.meta.code.node.static) {
118 doclet.addTag('static');
119 }
120 else {
121 doclet.addTag('instance');
122 }
123 }
124 // is this something that the module exports? if so, it's a static member
125 else if (doclet.meta && doclet.meta.code && doclet.meta.code.node &&
126 doclet.meta.code.node.parent &&
127 doclet.meta.code.node.parent.type === Syntax.ExportNamedDeclaration) {
128 doclet.addTag('static');
129 }
130 // otherwise, it must be an inner member
131 else {
132 doclet.addTag('inner');
133 }
134 }
135
136 // if the doclet isn't a memberof anything yet, and it's not a global, it must be a memberof
137 // the current module (unless we were told to skip adding memberof)
138 if (!doclet.memberof && doclet.scope !== SCOPE_NAMES.GLOBAL && !skipMemberof) {
139 doclet.addTag('memberof', currentModule.longname);
140 }
141 }
142}
143
144function setDefaultScope(doclet) {
145 // module doclets don't get a default scope

Callers 2

addSymbolMemberofFunction · 0.85
handlers.jsFile · 0.85

Calls 2

_getDocletByIdMethod · 0.80
addTagMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…