in jsdoc/processors/extract-tags.js [35:95]
function createTagExtractor(tagDefinitions, defaultTagTransforms) {
// Compute a default transformation function
const defaultTransformFn = getTransformationFn(defaultTagTransforms);
// Add some useful methods to the tagDefs
const tagDefs = tagDefinitions.map(tagDef => {
// Make a copy of the tagDef as we are going to modify it
tagDef = cloneDeep(tagDef);
// Compute this tagDefs specific transformation function
const transformFn = getTransformationFn(tagDef.transforms);
// Attach a transformation function to the cloned tagDef
// running the specific transforms followed by the default transforms
const tagProperty = tagDef.tagProperty || 'description';
tagDef.getProperty = (doc, tag) => {
let value = tag[tagProperty];
value = transformFn(doc, tag, value);
value = defaultTransformFn(doc, tag, value);
return value;
};
return tagDef;
});
return function tagExtractor(doc) {
// Try to extract each of the tags defined in the tagDefs collection
tagDefs.forEach(tagDef => {
log.silly('extracting tags for: ' + tagDef.name);
const docProperty = tagDef.docProperty || tagDef.name;
log.silly(' - to be attached to doc.' + docProperty);
// Collect the tags for this tag def
const tags = doc.tags.getTags(tagDef.name);
// No tags found for this tag def
if ( tags.length === 0 ) {
// This tag is required so throw an error
if ( tagDef.required ) {
throw new Error(createDocMessage('Missing tag "' + tagDef.name, doc));
}
applyDefault(doc, docProperty, tagDef);
} else {
readTags(doc, docProperty, tagDef, tags);
}
});
if ( doc.tags.badTags.length > 0 ) {
log.warn(formatBadTagErrorMessage(doc));
}
};
}