<commit_before>/// @ts-check
const createEmitter = require('./emit');

function position(file, line) {
  return file + ', line ' + line;
}

function classitemPosition(classitem) {
  return position(classitem.file, classitem.line);
}

function overloadPosition(classitem, overload) {
  return position(classitem.file, overload.line);
}

// mod is used to make yuidocs "global". It actually just calls generate()
// This design was selected to avoid rewriting the whole file from
// https://github.com/toolness/friendly-error-fellowship/blob/2093aee2acc53f0885fcad252a170e17af19682a/experiments/typescript/generate-typescript-annotations.js
function mod(yuidocs, localFileame, globalFilename, sourcePath) {

  var emit;
  var constants = {};
  var missingTypes = {};

  // http://stackoverflow.com/a/2008353/2422398
  var JS_SYMBOL_RE = /^[$A-Z_][0-9A-Z_$]*$/i;

  var P5_CLASS_RE = /^p5\.([^.]+)$/;

  var P5_ALIASES = [
    'p5',
    // These are supposedly "classes" in our docs, but they don't exist
    // as objects, and their methods are all defined on p5.
    'p5.dom',
    'p5.sound'
  ];

  var EXTERNAL_TYPES = new Set([
    'HTMLCanvasElement',
    'Float32Array',
    'AudioParam',
    'AudioNode',
    'GainNode',
    'DelayNode',
    'ConvolverNode',
    'Event'
  ]);

  var YUIDOC_TO_TYPESCRIPT_PARAM_MAP = {
    'Object': 'object',
    'Any': 'any',
    'Number': 'number',
    'Integer': 'number',
    'String': 'string',
    'Constant': 'any',
    'undefined': 'undefined',
    'Null': 'null',
    'Array': 'any[]',
    'Boolean': 'boolean',
    '*': 'any',
    'Void': 'void',
    'P5': 'p5',
    // When the docs don't specify what kind of function we expect,
    // then we need to use the global type `Function`
    'Function': 'Function',
  };

  function getClassitems(className) {
    return yuidocs.classitems.filter(function (classitem) {
      // Note that we first find items with the right class name,
      // but we also check for classitem.name because
      // YUIDoc includes classitems that we want to be undocumented
      // just because we used block comments.
      // We have other checks in place for finding missing method names
      // on public methods so a missing classitem.name implies that
      // the method is undocumented on purpose.
      // See https://github.com/processing/p5.js/issues/1252 and
      // https://github.com/processing/p5.js/pull/2301<commit_msg>Ignore hard to fix YUIDoc types<commit_after>/// @ts-check
const createEmitter = require('./emit');

function position(file, line) {
  return file + ', line ' + line;
}

function classitemPosition(classitem) {
  return position(classitem.file, classitem.line);
}

function overloadPosition(classitem, overload) {
  return position(classitem.file, overload.line);
}

// mod is used to make yuidocs "global". It actually just calls generate()
// This design was selected to avoid rewriting the whole file from
// https://github.com/toolness/friendly-error-fellowship/blob/2093aee2acc53f0885fcad252a170e17af19682a/experiments/typescript/generate-typescript-annotations.js
function mod(yuidocs, localFileame, globalFilename, sourcePath) {

  var emit;
  var constants = {};
  var missingTypes = {};

  // http://stackoverflow.com/a/2008353/2422398
  var JS_SYMBOL_RE = /^[$A-Z_][0-9A-Z_$]*$/i;

  var P5_CLASS_RE = /^p5\.([^.]+)$/;

  var P5_ALIASES = [
    'p5',
    // These are supposedly "classes" in our docs, but they don't exist
    // as objects, and their methods are all defined on p5.
    'p5.dom',
    'p5.sound'
  ];

  var EXTERNAL_TYPES = new Set([
    'HTMLCanvasElement',
    'Float32Array',
    'AudioParam',
    'AudioNode',
    'GainNode',
    'DelayNode',
    'ConvolverNode',
    'Event'
  ]);

  var YUIDOC_TO_TYPESCRIPT_PARAM_MAP = {
    'Object': 'object',
    'Any': 'any',
    'Number': 'number',
    'Integer': 'number',
    'String': 'string',
    'Constant': 'any',
    'undefined': 'undefined',
    'Null': 'null',
    'Array': 'any[]',
    'Boolean': 'boolean',
    '*': 'any',
    'Void': 'void',
    'P5': 'p5',
    // When the docs don't specify what kind of function we expect,
    // then we need to use the global type `Function`
    'Function': 'Function',
    // Special ignore for hard to fix YUIDoc from p5.sound
    'Tone.Signal': 'any',
    'SoundObject': 'any',
  };

  function getClassitems(className) {
    return yuidocs.classitems.filter(function (classitem) {
      // Note that we first find items with the right class name,
      // but we also check for classitem.name because
      // YUIDoc includes classitems that we want to be undocumented
      // just because we used block comments.
      // We have other checks in place for finding missing method names
      // on public methods so a missing classitem.name implies that
      // the method is undocumented on purpose.
      // See https://github.com/processing/p5.js/issues/1252 and
      // https://github.com/processing/p5.js/pull/2301
{'fraction_non_alphanumeric': 0.1369035635192269, 'fraction_numerical': 0.02476343869538957, 'mean_word_length': 3.1331114808652245, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, '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': '5390464', 'n_tokens_mistral': 1679, 'n_tokens_neox': 1580, 'n_words': 457}