in jsdoc/processors/parse-tags.js [56:137]
function createTagParser(tagDefinitions, parserAdapters) {
const END_OF_LINE = /\r?\n/;
const TAG_MARKER = /^\s*@(\S+)\s*(.*)$/;
const tagDefMap = createTagDefMap(tagDefinitions);
/**
* tagParser
* @param {string} content The text to parse for tags
* @param {number} startingLine The line in the doc file where this text begins
* @return {TagCollection} A collection of tags that were parsed
*/
return function tagParser(content, startingLine) {
const lines = content.split(END_OF_LINE);
let lineNumber = 0;
const descriptionLines = [];
let current; // The current that that is being extracted
const tags = new TagCollection(); // Contains all the tags that have been found
init(lines, tags);
// Extract the description block
do {
let line = lines[lineNumber];
nextLine(line, lineNumber);
if (parseForTags()) {
const match = TAG_MARKER.exec(line);
const tagDef = match && tagDefMap.get(match[1]);
if ( match && ( !tagDef || !tagDef.ignore ) ) {
// Only store tags that are unknown or not ignored
current = new Tag(tagDef, match[1], match[2], startingLine + lineNumber);
break;
}
}
lineNumber += 1;
descriptionLines.push(line);
} while(lineNumber < lines.length);
tags.description = descriptionLines.join('\n');
lineNumber += 1;
// Extract the tags
while(lineNumber < lines.length) {
const line = lines[lineNumber];
nextLine(line, lineNumber);
const match = TAG_MARKER.exec(line);
const tagDef = match && tagDefMap.get(match[1]);
if (parseForTags() && match && (!tagDef || !tagDef.ignore) ) {
tags.addTag(current);
current = new Tag(tagDef, match[1], match[2], startingLine + lineNumber);
} else {
current.description = current.description ? (current.description + '\n' + line) : line;
}
lineNumber += 1;
}
if ( current ) {
tags.addTag(current);
}
return tags;
};
function init(lines, tags) {
parserAdapters.forEach(adapter => adapter.init(lines, tags));
}
function nextLine(line, lineNumber) {
parserAdapters.forEach(adapter => adapter.nextLine(line, lineNumber));
}
function parseForTags() {
return parserAdapters.every(adapter => adapter.parseForTags());
}
}