$process()

in jsdoc/processors/extractJSDocComments.js [33:75]


    $process(docs) {

      const commentDocs = [];
      const processor = this;

      // Extract all the `jsFile` docs from the docs collection
      docs = docs.filter(doc => {

        if ( doc.docType !== 'jsFile' ) {
          return true;
        }

        // Generate a doc for each jsdoc style comment
        doc.fileInfo.ast.comments.forEach(comment => {

          // To test for a jsdoc comment (i.e. starting with /** ), we need to check for a
          // star in the first character since the parser strips off the "/*" comment identifier
          if ( comment.type === 'Block' && comment.value.charAt(0) === '*' ) {
            // Strip off any leading stars and
            // trim off leading and trailing whitespace
            const text = comment.value.replace(LEADING_STAR, '').trim();

            // Extract the information about the code directly after this comment
            const codeLocation = findNodeAfter(doc.fileInfo.ast, comment.range[1]);

            // Create a doc from this comment
            commentDocs.push({
              fileInfo: doc.fileInfo,
              startingLine: comment.loc.start.line,
              endingLine: comment.loc.end.line,
              content: text,
              codeNode: codeLocation.node,
              codeAncestors: codeLocation.path,
              docType: 'js'
            });
          }
        });
        return !processor.removeJsFileDocs;
      });

      // Add the new comment docs to the docs collection
      return docs.concat(commentDocs);
    }