MCPcopy
hub / github.com/jsdoc/jsdoc / codeToKind

Function codeToKind

lib/jsdoc/doclet.js:47–83  ·  view source on GitHub ↗
(code)

Source from the content-addressed store, hash-verified

45// use the meta info about the source code to guess what the doclet kind should be
46// TODO: set this elsewhere (maybe jsdoc/src/astnode.getInfo)
47function codeToKind(code) {
48 const isFunction = jsdoc.src.astnode.isFunction;
49 let kind = 'member';
50 const node = code.node;
51
52 if ( isFunction(code.type) && code.type !== Syntax.MethodDefinition ) {
53 kind = 'function';
54 }
55 else if (code.type === Syntax.MethodDefinition) {
56 if (code.node.kind === 'constructor') {
57 kind = 'class';
58 }
59 else if (code.node.kind !== 'get' && code.node.kind !== 'set') {
60 kind = 'function';
61 }
62 }
63 else if (code.type === Syntax.ClassDeclaration || code.type === Syntax.ClassExpression) {
64 kind = 'class';
65 }
66 else if (code.type === Syntax.ExportAllDeclaration) {
67 // this value will often be an Identifier for a variable, which isn't very useful
68 kind = codeToKind(fakeMeta(node.source));
69 }
70 else if (code.type === Syntax.ExportDefaultDeclaration ||
71 code.type === Syntax.ExportNamedDeclaration) {
72 kind = codeToKind(fakeMeta(node.declaration));
73 }
74 else if (code.type === Syntax.ExportSpecifier) {
75 // this value will often be an Identifier for a variable, which isn't very useful
76 kind = codeToKind(fakeMeta(node.local));
77 }
78 else if ( code.node && code.node.parent && isFunction(code.node.parent) ) {
79 kind = 'param';
80 }
81
82 return kind;
83}
84
85function unwrap(docletSrc) {
86 if (!docletSrc) { return ''; }

Callers 1

postProcessMethod · 0.85

Calls 1

fakeMetaFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…