<commit_before>import * as fs from 'fs-extra';
import * as schema from './api-schema';
import {
  ApiDefinitions, asArray, ExtendedApi, getTitle, readJsonDefs, hasChangeEvent, plainType, isInterfaceReference,
  isUnion, isTuple, isMap, isIndexedMap, isCallback, getEventTypeName, getJSXChildElementType, supportsJsx,
  getJSXContentType
} from './common';
import {join, parse, resolve} from 'path';

type Link = {href?: string, title?: string};
type TypeLinks = {[type: string]: Link};
type NamedEvents = Array<schema.Event & {name: string}>;
type Config = {sourcePath: string, targetPath: string, snippetsPath: string, version: string};
type Member = schema.Method | schema.Method[] | schema.Property;
type TocEntry = {title: string, url: string, priority?: boolean};

const HTML_LT = '&lt;';
const HTML_GT = '&gt;';
const HTML_QUOT = '&quot;';
const HTML_PIPE = '&#124;';
const CHANGE_EVENT_INTERFACE = 'PropertyChangedEvent';
const quot = (...str) => HTML_QUOT + str.join('') + HTML_QUOT;
const tag = (...str) => HTML_LT + str.join('') + HTML_GT;
const code = (...str) => '<code style="white-space: nowrap">' + str.join('') + '</code>';
const nbsp = (count: number) => new Array(count + 1).join('&nbsp;');
const pipeOr = (arr: string[], indent = null) => (indent !== null && arr.length > 1)
  ? nbsp(indent) + arr.join('<br/>' + nbsp(indent) + HTML_PIPE + ' ')
  : arr.join(' ' + HTML_PIPE + ' ');
const mdnTitle = type => `View ${quot(type)} on MDN`;
const MSG_PROVISIONAL = '**Note:** this API is provisional and may change in a future release.';
const LANG_TYPE_LINKS: TypeLinks = {
  Function: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function',
    title: mdnTitle('Function')
  },
  Object: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object',
    title: mdnTitle('Object')
  },
  object: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object',
    title: mdnTitle('Object')
  },
  string: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type',
    title: mdnTitle('string')
  },
  boolean: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type',
    title: mdnTitle('boolean')
  },
  number: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type',
    title: mdnTitle('number')
  },
  null: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Null_type',
    title: mdnTitle('null')
  },
  undefined: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type',
    title: mdnTitle('undefined')
  },
  Promise: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise',
    title: mdnTitle('Promise')
  },
  IterableIterator: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol',
    title: mdnTitle('IterableIterator')
  },
  Array: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array',
    title: mdnTitle('Array')
  },
  ArrayBuffer: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer',
    title: mdnTitle('ArrayBuffer')
  },
  TypedArray: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays',
    title: mdnTitle('typed arrays')
  },
  Selector: {
    href: '../selector.md',
    title: 'More about selectors'
  },
  SelectorString: {
    href: '../selector.md',
    title: 'More about selectors'
  },
  any: {
    title: 'Literally any JavaScript value'
  },
  this: {
    href: '#',
    title: 'This object'
  }
};
const PLAYGROUND = 'https://playground.tabris.com/';
const DECORATORS_TREE = 'https://github.com/eclipsesource/tabris-decorators/tree/';
const FILE_TYPES = {
  js: 'JavaScript',
  jsx: 'JSX',
  ts: 'TypeScript',
  tsx: 'TypeScript/JSX',
  console: 'Interactive Console'
};
const TOC_INCLUDE: {[cat: string]: TocEntry[]} = {
  core: [],
  service: [
    {
      title: 'Worker',
      url: 'w3c-api.html#worker'
    },
    {
      title: 'crypto',
      url: 'w3c-api.html#random-source-crypto'
    }
  ],
  widget: [
    {
      title: 'Overview',
      url: 'api/widget-overview.html',
      priority: true
    }
  ],
  popup: [],
  net: [
    {
      title: 'XMLHttpRequest',
      url: 'w3c-api.html#xmlhttprequest'
    },
    {
      title: 'WebSocket',
      url: 'w3c-api.html#websocket'
    }
  ],<commit_msg>[Doc] Remove duplicate "crypto" entry from TOC<commit_after>import * as fs from 'fs-extra';
import * as schema from './api-schema';
import {
  ApiDefinitions, asArray, ExtendedApi, getTitle, readJsonDefs, hasChangeEvent, plainType, isInterfaceReference,
  isUnion, isTuple, isMap, isIndexedMap, isCallback, getEventTypeName, getJSXChildElementType, supportsJsx,
  getJSXContentType
} from './common';
import {join, parse, resolve} from 'path';

type Link = {href?: string, title?: string};
type TypeLinks = {[type: string]: Link};
type NamedEvents = Array<schema.Event & {name: string}>;
type Config = {sourcePath: string, targetPath: string, snippetsPath: string, version: string};
type Member = schema.Method | schema.Method[] | schema.Property;
type TocEntry = {title: string, url: string, priority?: boolean};

const HTML_LT = '&lt;';
const HTML_GT = '&gt;';
const HTML_QUOT = '&quot;';
const HTML_PIPE = '&#124;';
const CHANGE_EVENT_INTERFACE = 'PropertyChangedEvent';
const quot = (...str) => HTML_QUOT + str.join('') + HTML_QUOT;
const tag = (...str) => HTML_LT + str.join('') + HTML_GT;
const code = (...str) => '<code style="white-space: nowrap">' + str.join('') + '</code>';
const nbsp = (count: number) => new Array(count + 1).join('&nbsp;');
const pipeOr = (arr: string[], indent = null) => (indent !== null && arr.length > 1)
  ? nbsp(indent) + arr.join('<br/>' + nbsp(indent) + HTML_PIPE + ' ')
  : arr.join(' ' + HTML_PIPE + ' ');
const mdnTitle = type => `View ${quot(type)} on MDN`;
const MSG_PROVISIONAL = '**Note:** this API is provisional and may change in a future release.';
const LANG_TYPE_LINKS: TypeLinks = {
  Function: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function',
    title: mdnTitle('Function')
  },
  Object: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object',
    title: mdnTitle('Object')
  },
  object: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object',
    title: mdnTitle('Object')
  },
  string: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type',
    title: mdnTitle('string')
  },
  boolean: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type',
    title: mdnTitle('boolean')
  },
  number: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type',
    title: mdnTitle('number')
  },
  null: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Null_type',
    title: mdnTitle('null')
  },
  undefined: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type',
    title: mdnTitle('undefined')
  },
  Promise: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise',
    title: mdnTitle('Promise')
  },
  IterableIterator: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol',
    title: mdnTitle('IterableIterator')
  },
  Array: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array',
    title: mdnTitle('Array')
  },
  ArrayBuffer: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer',
    title: mdnTitle('ArrayBuffer')
  },
  TypedArray: {
    href: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays',
    title: mdnTitle('typed arrays')
  },
  Selector: {
    href: '../selector.md',
    title: 'More about selectors'
  },
  SelectorString: {
    href: '../selector.md',
    title: 'More about selectors'
  },
  any: {
    title: 'Literally any JavaScript value'
  },
  this: {
    href: '#',
    title: 'This object'
  }
};
const PLAYGROUND = 'https://playground.tabris.com/';
const DECORATORS_TREE = 'https://github.com/eclipsesource/tabris-decorators/tree/';
const FILE_TYPES = {
  js: 'JavaScript',
  jsx: 'JSX',
  ts: 'TypeScript',
  tsx: 'TypeScript/JSX',
  console: 'Interactive Console'
};
const TOC_INCLUDE: {[cat: string]: TocEntry[]} = {
  core: [],
  service: [
    {
      title: 'Worker',
      url: 'w3c-api.html#worker'
    }
  ],
  widget: [
    {
      title: 'Overview',
      url: 'api/widget-overview.html',
      priority: true
    }
  ],
  popup: [],
  net: [
    {
      title: 'XMLHttpRequest',
      url: 'w3c-api.html#xmlhttprequest'
    },
    {
      title: 'WebSocket',
      url: 'w3c-api.html#websocket'
    }
  ],
{'fraction_non_alphanumeric': 0.1732972972972973, 'fraction_numerical': 0.0018378378378378379, 'mean_word_length': 3.8358599059069522, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 30, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2447953', 'n_tokens_mistral': 3296, 'n_tokens_neox': 3164, 'n_words': 600}