MCPcopy
hub / github.com/jsdoc/jsdoc / addSignatureReturns

Function addSignatureReturns

templates/default/publish.js:152–182  ·  view source on GitHub ↗
(f)

Source from the content-addressed store, hash-verified

150}
151
152function addSignatureReturns(f) {
153 const attribs = [];
154 let attribsString = '';
155 let returnTypes = [];
156 let returnTypesString = '';
157 const source = f.yields || f.returns;
158
159 // jam all the return-type attributes into an array. this could create odd results (for example,
160 // if there are both nullable and non-nullable return types), but let's assume that most people
161 // who use multiple @return tags aren't using Closure Compiler type annotations, and vice-versa.
162 if (source) {
163 source.forEach(item => {
164 helper.getAttribs(item).forEach(attrib => {
165 if (!attribs.includes(attrib)) {
166 attribs.push(attrib);
167 }
168 });
169 });
170
171 attribsString = buildAttribsString(attribs);
172 }
173
174 if (source) {
175 returnTypes = addNonParamAttributes(source);
176 }
177 if (returnTypes.length) {
178 returnTypesString = util.format( ' → %s{%s}', attribsString, returnTypes.join('|') );
179 }
180
181 f.signature = `<span class="signature">${f.signature || ''}</span><span class="type-signature">${returnTypesString}</span>`;
182}
183
184function addSignatureTypes(f) {
185 const types = f.type ? buildItemTypeStrings(f) : [];

Callers 1

publish.jsFile · 0.85

Calls 2

buildAttribsStringFunction · 0.85
addNonParamAttributesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…