<commit_before>var _ = require('lodash');

module.exports = function extractDecoratedClassesProcessor(EXPORT_DOC_TYPES) {

  // Add the "directive" docType into those that can be exported from a module
  EXPORT_DOC_TYPES.push('directive', 'pipe');

  return {
    $runAfter: ['processing-docs'],
    $runBefore: ['docs-processed'],
    decoratorTypes: ['Directive', 'Component', 'Pipe', 'NgModule'],
    $process: function(docs) {
      var decoratorTypes = this.decoratorTypes;

      _.forEach(docs, function(doc) {

        _.forEach(doc.decorators, function(decorator) {

          if (decoratorTypes.indexOf(decorator.name) !== -1) {
            doc.docType = decorator.name.toLowerCase();
            // Directives do not always have an argument (i.e. abstract directives).
            // We still create options for those, as an empty object literal is equal
            // to just having an empty object literal as decorator argument.
            doc[doc.docType + 'Options'] = decorator.argumentInfo[0] || {};
          }
        });
      });

      return docs;
    }
  };
};<commit_msg>refactor(docs-infra): refactors `extractDecoratedClasses` (#37135)<commit_after>module.exports = function extractDecoratedClassesProcessor(EXPORT_DOC_TYPES) {

  // Add the "directive" docType into those that can be exported from a module
  EXPORT_DOC_TYPES.push('directive', 'pipe');

  return {
    $runAfter: ['processing-docs'],
    $runBefore: ['docs-processed'],
    decoratorTypes: ['Directive', 'Component', 'Pipe', 'NgModule'],
    $process: function(docs) {
      const decoratorTypes = this.decoratorTypes;
      docs.forEach(doc => {
        (doc.decorators || []).forEach(decorator => {
          if (decoratorTypes.indexOf(decorator.name) !== -1) {
            doc.docType = decorator.name.toLowerCase();
            // Directives do not always have an argument (i.e. abstract directives).
            // We still create options for those, as an empty object literal is equal
            // to just having an empty object literal as decorator argument.
            doc[doc.docType + 'Options'] = decorator.argumentInfo[0] || {};
          }
        });
      });

      return docs;
    }
  };
};
{'fraction_non_alphanumeric': 0.12907608695652173, 'fraction_numerical': 0.004076086956521739, 'mean_word_length': 2.8151986183074267, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1568447', 'n_tokens_mistral': 646, 'n_tokens_neox': 621, 'n_words': 164}