From 35de92ffaff2261eae29422474afd4ca674ab473 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Thu, 27 Jan 2022 18:13:29 +0100 Subject: [PATCH 01/10] docs: automatically generate api docs from source (#289) Co-authored-by: Shinigami --- .gitignore | 1 + docs/.vitepress/.gitignore | 1 + docs/.vitepress/config.mjs | 57 +------ docs/api/.gitignore | 3 + docs/api/address.md | 181 --------------------- docs/api/commerce.md | 62 -------- docs/api/company.md | 106 ------------- docs/api/database.md | 35 ---- docs/api/datatype.md | 125 --------------- docs/api/date.md | 129 --------------- docs/api/finance.md | 167 ------------------- docs/api/hacker.md | 51 ------ docs/api/helpers.md | 262 ------------------------------ docs/api/image.md | 318 ------------------------------------- docs/api/internet.md | 186 ---------------------- package.json | 10 +- pnpm-lock.yaml | 83 ++++++++-- scripts/apidoc.ts | 244 ++++++++++++++++++++++++++++ 18 files changed, 333 insertions(+), 1688 deletions(-) create mode 100644 docs/.vitepress/.gitignore create mode 100644 docs/api/.gitignore delete mode 100644 docs/api/address.md delete mode 100644 docs/api/commerce.md delete mode 100644 docs/api/company.md delete mode 100644 docs/api/database.md delete mode 100644 docs/api/datatype.md delete mode 100644 docs/api/date.md delete mode 100644 docs/api/finance.md delete mode 100644 docs/api/hacker.md delete mode 100644 docs/api/helpers.md delete mode 100644 docs/api/image.md delete mode 100644 docs/api/internet.md create mode 100644 scripts/apidoc.ts diff --git a/.gitignore b/.gitignore index a7b1de8c57f..8acf826fc6a 100644 --- a/.gitignore +++ b/.gitignore @@ -72,6 +72,7 @@ versions.json # Dist /dist /docs/.vitepress/dist +/docs/api/typedoc.json /lib # Faker diff --git a/docs/.vitepress/.gitignore b/docs/.vitepress/.gitignore new file mode 100644 index 00000000000..1af560a8a18 --- /dev/null +++ b/docs/.vitepress/.gitignore @@ -0,0 +1 @@ +api-pages.mjs diff --git a/docs/.vitepress/config.mjs b/docs/.vitepress/config.mjs index fe5370c3aab..d35171bbce4 100644 --- a/docs/.vitepress/config.mjs +++ b/docs/.vitepress/config.mjs @@ -1,4 +1,5 @@ import { defineConfig } from 'vitepress'; +import { apiPages } from './api-pages.mjs'; const nav = [ { text: 'Guide', link: '/guide/' }, @@ -22,61 +23,7 @@ const sidebar = { }, { text: 'API', - children: [ - { - text: 'Address', - link: '/api/address', - collapsable: false, // optional, defaults to true - }, - { - text: 'Commerce', - link: '/api/commerce', - }, - { - text: 'Company', - link: '/api/company', - }, - { - text: 'Database', - link: '/api/database', - }, - { - text: 'Datatype', - link: '/api/datatype', - }, - { - text: 'Date', - link: '/api/date', - }, - { - text: 'Fake', - link: '/api/fake', - }, - { - text: 'Finance', - link: '/api/finance', - }, - { - text: 'Hacker', - link: '/api/hacker', - }, - { - text: 'Helpers', - link: '/api/helpers', - }, - { - text: 'Image', - link: '/api/image', - }, - { - text: 'Internet', - link: '/api/internet', - }, - { - text: 'Localization', - link: '/api/localization', - }, - ], + children: apiPages, }, { text: 'Migrating from Faker v5', diff --git a/docs/api/.gitignore b/docs/api/.gitignore new file mode 100644 index 00000000000..73d5e0860e2 --- /dev/null +++ b/docs/api/.gitignore @@ -0,0 +1,3 @@ +*.md +!fake.md +!localization.md diff --git a/docs/api/address.md b/docs/api/address.md deleted file mode 100644 index 421aad7ead5..00000000000 --- a/docs/api/address.md +++ /dev/null @@ -1,181 +0,0 @@ -# Address - -[[toc]] - -## City - -::: v-pre -Generates a random localized city name. The format string can contain any method provided by faker wrapped in `{{}}`, e.g. `{{name.firstName}}` in order to build the city name. - -::: tip -If no format string is provided one of the following is randomly used: - -- `{{address.cityPrefix}} {{name.firstName}}{{address.citySuffix}}` -- `{{address.cityPrefix}} {{name.firstName}}` -- `{{name.firstName}}{{address.citySuffix}}` -- `{{name.lastName}}{{address.citySuffix}}` - ::: - -```js -faker.address.city(); // Lake Raoulfort -faker.address.city('{{name.lastName}}{{address.citySuffix}}'); // Powlowski port -``` - -## City Prefix - -Return a random localized city prefix - -```js -faker.address.cityPrefix(); // South -``` - -## City Suffix - -Return a random localized city suffix - -```js -faker.address.citySuffix(); // burgh -``` - -## County - -Returns a random county - -```js -faker.address.county(); // Cambridgeshire -``` - -## Country - -Returns a random country - -```js -faker.address.country(); // Papua New Guinea -``` - -## Country Code - -Returns a random country code - -```js -faker.address.countryCode(); // SN -``` - -## Latitude - -Returns a random latitude. - -::: warning Params Available -| Param | Type | Default | -| ----- | ------ | :-----: | -| max | number | `90` | -| min | number | `-90` | -::: - -```js -faker.address.latitude(); // 78.9197 -faker.address.latitude(70, 10); // 40.1239 -``` - -## Longitude - -Returns a random longitude. - -::: warning Params Available -| Param | Type | Default | -| ----- | ------ | :-----: | -| max | number | `180` | -| min | number | `-180` | -::: - -```js -faker.address.longitude(); // 78.9197 -faker.address.longitude(70, 10); // 40.1239 -``` - -## State - -Returns a random state - -```js -faker.address.state(); // Montana -``` - -## State Abbreviation - -Returns a random state abbreviation - -```js -faker.address.stateAbbr(); // WV -``` - -## Street Name - -Returns a random localized street name - -```js -faker.address.streetName(); // Rowe Coves -``` - -## Street Address - -Returns a random localized street address. Pass in optional object boolean to get a full address. - -::: tip -| Param | Type | Default | -| -------------- | ------- | :-----: | -| useFullAddress | boolean | `false` | -::: - -```js -faker.address.streetAddress(); // 294 White Parkways -faker.address.streetAddress(true); // 294 White Parkways Apt. 506 -``` - -## Street Suffix - -Returns a random localized street suffix. - -```js -faker.address.streetSuffix(); // Garden -``` - -## Street Prefix - -Returns a random localized street prefix. - -```js -faker.address.streetPrefix(); // c -``` - -## Secondary Address - -Returns a random Secondary Address - -```js -faker.address.secondaryAddress(); // Suite 123 -``` - -## Zip Code - -Generates random zip code. If format is not specified, the locale's zip format is used. Use formats that are supported with [replaceSymbols](/api/helpers.html#replacesymbols-format) - -::: tip -| Param | Type | Default | -| ------ | ------ | :---------: | -| format | string | `undefined` | -::: - -```js -faker.address.zipCode(); // 98101-1234 -faker.address.zipCode('#####'); // 98101 -``` - -## Zip Code By State - -Generates random Zip Code from state abbreviation. If state abbreviation is not specified, a random zip code is generated according to the locale's zip format. Only works for locales with `postcode_by_state` definition. If a locale does not have a `postcode_by_state` definition, a random zip code is generated according to the locale's zip format. - -```js -faker.address.zipCodeByState(); // 12302 -faker.address.zipCodeByState('wa'); // 98101 -``` diff --git a/docs/api/commerce.md b/docs/api/commerce.md deleted file mode 100644 index a7809709f46..00000000000 --- a/docs/api/commerce.md +++ /dev/null @@ -1,62 +0,0 @@ -# Commerce - -[[toc]] - -## Color - -Return random color name - -```js -faker.commerce.color(); // fuchsia -``` - -## Department - -Return random department name - -```js -faker.commerce.department(); // Grocery -``` - -## Price - -Generates random price - -::: tip -| Param | Type | Default | -| ------ | ------ | :-----: | -| min | number | `1` | -| max | number | `1000` | -| dec | number | `2` | -| symbol | string | `` | -::: - -```js -faker.commerce.price(); // 4.00 -faker.commerce.price(2, 22, 1, '$'); // $7.0 -``` - -## Product - -Return random product - -```js -faker.commerce.product(); // Gloves -faker.commerce.productName(); // Rustic Granite Shirt -``` - -## Product Adjective - -Return random product adjective - -```js -faker.commerce.productAdjective(); // Handmade -``` - -## Product Material - -Return random product material - -```js -faker.commerce.productMaterial(); // Steel -``` diff --git a/docs/api/company.md b/docs/api/company.md deleted file mode 100644 index c2919d6f9cd..00000000000 --- a/docs/api/company.md +++ /dev/null @@ -1,106 +0,0 @@ -# Company - -[[toc]] - -## Company Name - -Return random company name. Using one of the following format options -::: v-pre - -- `{{name.lastName}} {{company.companySuffix}}` -- `{{name.lastName}} - {{name.lastName}}` -- `{{name.lastName}}, {{name.lastName}} and {{name.lastName}}` - ::: - -::: tip -| Param | Type | Default | -| ----------- | ------ | :-----: | -| formatIndex | number | `0-2` | -::: - -```js -faker.company.companyName(); // Zboncak and Sons -faker.company.companyName(0); // Nikolaus Group -faker.company.companyName(1); // Keeling - Lind -faker.company.companyName(2); // Swaniawski, Howe and Leffler -``` - -## Company Suffix - -Return random company suffix - -```js -faker.company.companySuffix(); // and Sons -``` - -## Company Suffixes - -Return **array** of company suffixes - -```js -faker.company.suffixes(); // ["Inc", "and Sons", "LLC", "Group"] -``` - -## Catchphrase - -Return random company catch phrase - -```js -faker.company.catchPhrase(); // Team-oriented context-sensitive conglomeration -``` - -## Catchphrase Adjective - -Return random catch phrase adjective - -```js -faker.company.catchPhraseAdjective(); // Down-sized -``` - -## Catchphrase Descriptor - -Return random catch phrase descriptor - -```js -faker.company.catchPhraseDescriptor(); // bi-directional -``` - -## Catchphrase Noun - -Return random catch phrase noun - -```js -faker.company.catchPhraseNoun(); // complexity -``` - -## Company BS 💩 - -Return random company bs - -```js -faker.company.bs(); // ubiquitous empower e-business -``` - -## BS Adjective - -Return random company bs adjective - -```js -faker.company.bsAdjective(); // granular -``` - -## BS Buzzword - -Return random company bs buzz word - -```js -faker.company.bsBuzz(); // facilitate -``` - -## BS Noun - -Return random company bs noun - -```js -faker.company.bsNoun(); // models -``` diff --git a/docs/api/database.md b/docs/api/database.md deleted file mode 100644 index c9be1533c9d..00000000000 --- a/docs/api/database.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database - -[[toc]] - -## Column - -Return database column name - -```js -faker.database.column(); // createdAt -``` - -## Type - -Return database column type - -```js -faker.database.type(); // text -``` - -## Collation - -Return database collation - -```js -faker.database.collation(); // cp1250_general_ci -``` - -## Engine - -Return database engine - -```js -faker.database.engine(); // MyISAM -``` diff --git a/docs/api/datatype.md b/docs/api/datatype.md deleted file mode 100644 index 35a25716098..00000000000 --- a/docs/api/datatype.md +++ /dev/null @@ -1,125 +0,0 @@ -# Data Type - -[[toc]] - -Generate basic data type, starting from `v5.5.0`. Similar functions from `faker.random` will be deprecated. - -## Number - -Generates random `number` data type. - -::: tip -| Param | Type | Default | -| ------- | ----- | :----------------------------------: | -| options | mixed | `{min: 0, max: 99999, precision: 1}` | - -**NOTE**: passing a number as the param will set the `max` value to that number and use the `min` and `precision` defaults -::: - -```js -faker.datatype.number(); // 3451 -faker.datatype.number(86); // 50 -faker.datatype.number({ min: 10 }); // 45991 -faker.datatype.number({ min: 10, max: 100 }); // 14 -faker.datatype.number({ min: 10, max: 100, precision: 0.25 }); // 44.5 -``` - -## Float - -Generates random `float` data type. - -::: tip -| Param | Type | Default | -| ------- | ----- | :----------------------------------: | -| options | mixed | `{min: 0, max: 99999, precision: 1}` | - -**NOTE 1**: passing a number as the param will set the `max` value to that number and use the `min` and `precision` defaults - -**NOTE 2**: javascript has single data type `number` for all kinds of numbers. Statement `typeof(faker.datatype.number(10)) === typeof(faker.datatype.float(10))` equals `true` -::: - -```js -faker.datatype.float(); // 428 -faker.datatype.float(100); // 23 -faker.datatype.float({ min: 10 }); // 1635 -faker.datatype.float({ min: 10, max: 100 }); // 49 -faker.datatype.float({ min: 10, max: 100, precision: 0.1 }); // 81.8 -``` - -## Array - -Generates array of random number or string. - -::: tip -| Param | Type | Default | -| ----- | ----- | :---------------: | -| length | number | 10 | - -**NOTE**: this method has no fine-grained control to create array of numbers or strings only, or specify criteria for array elements -::: - -```js -faker.datatype.array(); // [13,'hfa&', 41, 8301, '(6$bH', 2354, 'V73!', 'm*he?', 11911, 'gbdX#'] -faker.datatype.array(3); // [47460, 'b&r3#', 9003] -``` - -## UUID - -Generates random UUID - -```js -faker.datatype.uuid(); // 54d13fa1-6d84-4717-8fa2-477a62dac76c -``` - -## Boolean - -Generates random `boolean` data type. - -```js -faker.datatype.boolean(); // true -``` - -## String - -Generates random `string` data type. - -::: tip -| Param | Type | Default | -| ----- | ----- | :---------------: | -| length | number | 10 | -::: - -```js -faker.datatype.string(); // 'Y7=bR1.jpW' -faker.datatype.string(5); // '_9Kss' -``` - -## JSON - -Generates random JSON. It has default length of 7, and no options. - -::: tip -**NOTE**: The generated data type is `string`. To treat it like javascript `object`, use `JSON.parse()` function. -::: - -```js -faker.datatype.json(); // {"foo":61342,"bar":1587,"bike":88807,"a":69894,"b":"A?+(5w)E/Z","name":"U@Y`>Ygls}","prop":35014} (string) -JSON.parse(faker.datatype.json()); // (object) -``` - -## Hexadecimal - -Generates random hex (base-16) number. - -::: tip -| Param | Type | Default | -| ----- | ----- | :---------------: | -| length | number | 1 | -**NOTE**: The generated data type is `string`. To treat it like javascript `number`, use `parseInt()` function. -::: - -```js -faker.datatype.hexaDecimal(); // '0xA' (string) -faker.datatype.hexaDecimal(5); // '0x8D620' (string) -parseInt(faker.datatype.hexaDecimal(2)); // 0xC1 (number) -``` diff --git a/docs/api/date.md b/docs/api/date.md deleted file mode 100644 index 359a77440ae..00000000000 --- a/docs/api/date.md +++ /dev/null @@ -1,129 +0,0 @@ -# Date - -[[toc]] - -## Past - -Return date sometime in the past. - -::: tip -| Param | Type | Default | -| -------- | ------- | :----------: | -| maxYears | number | `1` | -| refDate | Date | `new Date()` | -::: - -```js -faker.date.past(); -// Sat Oct 20 2018 04:19:38 GMT-0700 (Pacific Daylight Time) - -faker.date.past(100); -// Tue Jul 27 1971 21:08:49 GMT-0700 (Pacific Daylight Time) - -faker.date.past(100, new Date(-3000)); -// Wed Dec 07 1881 05:04:18 GMT-0752 (Pacific Standard Time) -``` - -## Future - -Return date sometime in the future. - -::: tip -| Param | Type | Default | -| ------- | ------- | :----------: | -| years | number | `1` | -| refDate | Date | `new Date()` | -::: - -```js -faker.date.future(); -// Mon Sep 02 2019 21:08:33 GMT-0700 (Pacific Daylight Time) - -faker.date.future(100); -// Fri Nov 23 2068 10:43:15 GMT-0800 (Pacific Standard Time) - -faker.date.future(100, new Date(-3000)); -// Mon Jun 26 2051 01:50:51 GMT-0700 (Pacific Daylight Time) -``` - -## Between - -Return date sometime in the future. - -::: tip -| Param | Type | Default | -| ----- | ---- | :------------------------------------------------: | -| from | Date | | -| to | Date | | -::: - -```js -faker.date.between(new Date(0), new Date(365 * 24 * 3600 * 1000)); -// Mon Oct 19 1970 14:12:01 GMT-0700 (Pacific Daylight Time) -``` - -## Recent - -Returns some date recent date - -::: tip -| Param | Type | Default | -| ------- | ------- | :----------: | -| days | number | `1` | -| refDate | Date | `new Date()` | -::: - -```js -faker.date.recent(); -``` - -## Soon - -Return date sometime soon. - -::: tip -| Param | Type | Default | -| ------- | ------- | :----------: | -| days | number | `1` | -| refDate | Date | `new Date()` | -::: - -```js -faker.date.soon(); -``` - -## Month - -Return random month name - -::: tip -| Param | Type | Default | -| ------ | ------ | :-----------------------------: | -| option | object | `{abbr: false, context: false}` | -::: - -```js -faker.date.month(); -// December - -faker.date.month({ abbr: true }); -// Dec -``` - -## Weekday - -Return random weekday name - -::: tip -| Param | Type | Default | -| ------ | ------ | :-----------------------------: | -| option | object | `{abbr: false, context: false}` | -::: - -```js -faker.date.weekday(); -// Sunday - -faker.date.weekday({ abbr: true }); -// Sun -``` diff --git a/docs/api/finance.md b/docs/api/finance.md deleted file mode 100644 index 6035dbccdb0..00000000000 --- a/docs/api/finance.md +++ /dev/null @@ -1,167 +0,0 @@ -# Finance - -[[toc]] - -## Account - -Return random account number - -::: tip -| Param | Type | Default | -| ------ | ------ | :-----: | -| length | number | `8` | -::: - -```js -faker.finance.account(); // 30764440 -faker.finance.account(12); // 194294967472 -``` - -## Account Name - -Return random account name - -```js -faker.finance.accountName(); // Investment Account -``` - -## Routing Number - -Return random routing number - -```js -faker.finance.routingNumber(); -``` - -## Mask - -Return random mask - -::: tip -| Param | Type | Default | -| -------- | ------- | :-----: | -| length | number | `4` | -| parens | boolean | `false` | -| ellipsis | boolean | `false` | -::: - -```js -faker.finance.mask(); // 8493 -faker.finance.mask(5, true); // (17126) -faker.finance.mask(5, true, true); // (...17126) -faker.finance.mask(5, false, true); // ...17126 -``` - -## Amount - -Return random amount - -::: tip -| Param | Type | Default | -| ------ | ------ | :-----: | -| min | number | `0` | -| max | number | `1000` | -| dec | number | `2` | -| symbol | string | `''` | -::: - -```js -faker.finance.amount(); // 466.98 -faker.finance.amount(42); // 197.40 -faker.finance.amount(42, 43); // 42.24 -faker.finance.amount(42, 43, 10); // 42.1601538648 -faker.finance.amount(42, 43, 2, '$'); // $42.89 -``` - -## Transaction Type - -Return random transaction type - -```js -faker.finance.transactionType(); // withdrawal -``` - -## Currency Code - -Return random currency code - -```js -faker.finance.currencyCode(); // HTG USD -``` - -## Currency Name - -Return random currency name - -```js -faker.finance.currencyName(); // Hryvnia -``` - -## Currency Symbol - -Return random currency symbol - -```js -faker.finance.currencySymbol(); // £ -``` - -## Credit Card Number - -Return random credit card number - -::: tip -| Param | Type | Default | -| -------- | ------ | :-----: | -| provider | string | `''` | -::: - -```js -faker.finance.creditCardNumber(); -``` - -## Credit Card CVV - -Return random credit card CVV - -```js -faker.finance.creditCardCVV(); -``` - -## Bitcoin Address - -Return random bitcoin address - -```js -faker.finance.bitcoinAddress(); // 3FINQD7C6JW7XPF4NMNHOJYAXLKLP -``` - -## Ethereum Address - -Return random Ethereum address - -```js -faker.finance.ethereumAddress(); -``` - -## IBAN (Intl. Bank Account Number) - -Return random IBAN (International Bank Account Number) - -::: tip -| Param | Type | Default | -| -------- | ------- | :-----: | -| formated | boolean | `false` | -::: - -```js -faker.finance.iban(); // BE56302102061244 -faker.finance.iban(true); // GI29 MRCH LR1V 0284 KE24 6K8 -``` - -## BIC (Banking Identifier Code) - -Return random BIC (Bank Identifier Code) - -```js -faker.finance.bic(); // OUAIDGK1 -``` diff --git a/docs/api/hacker.md b/docs/api/hacker.md deleted file mode 100644 index d692d4aedb5..00000000000 --- a/docs/api/hacker.md +++ /dev/null @@ -1,51 +0,0 @@ -# Hacker - -[[toc]] - -## Abbreviation - -Return random abbreviation - -```js -faker.hacker.abbreviation(); // SMTP -``` - -## Adjective - -Return random adjective - -```js -faker.hacker.adjective(); // wireless -``` - -## Noun - -Return random noun - -```js -faker.hacker.noun(); // capacitor -``` - -## Phrase - -Return random phrase - -```js -faker.hacker.phrase(); // Try to reboot the SQL bus, maybe it will bypass the virtual application! -``` - -## Verb - -Return random verb - -```js -faker.hacker.verb(); // parse -``` - -## -ing Verb - -Return random ingverb - -```js -faker.hacker.ingverb(); // programming -``` diff --git a/docs/api/helpers.md b/docs/api/helpers.md deleted file mode 100644 index 7a2db0d2f95..00000000000 --- a/docs/api/helpers.md +++ /dev/null @@ -1,262 +0,0 @@ -# Helpers - -[[toc]] - -## Randomize Array - -Returns a random value from the provided array - -::: tip -| Param | Type | Default | -| ----- | ----- | :---------------: | -| array | array | `["a", "b", "c"]` | -::: - -```js -faker.helpers.randomize(); // a -faker.helpers.randomize(['bob', 'joe', 'tim']); // joe -``` - -## Slugify - -slugify the provided string - -::: tip -| Param | Type | Default | -| ------ | ------ | :-----: | -| string | string | `""` | -::: - -```js -faker.helpers.slugify(); // "" -faker.helpers.slugify('bob was here'); // bob-was-here -``` - -## Replace Symbol From Number - -Replace a symbol with a number - -::: tip -| Param | Type | Default | -| ------ | ------ | :-----: | -| string | string | `""` | -| symbol | string | `"#"` | -::: - -```js -faker.helpers.replaceSymbolWithNumber(); // "" -faker.helpers.replaceSymbolWithNumber('bob###@example.com'); // bob790@example.com -faker.helpers.replaceSymbolWithNumber('bob????##???', '?'); // bob6269##849 -``` - -## Replace Symbols - -Parses string for symbols (numbers or letters) and replaces them appropriately. - -- `#` will be replaced with a number, -- `?` with be replaced with a letter -- `*` will be replaced with a number or a letter - -::: tip -| Param | Type | Default | -| ------ | ------ | :-----: | -| format | string | `""` | -::: - -```js -faker.helpers.replaceSymbols('#####'); // 98101 -faker.helpers.replaceSymbols('???'); // ABC -faker.helpers.replaceSymbols('bob-###-42-??'); // bob-226-42-KB -``` - -## Shuffle Array - -Takes an array and returns it randomized - -::: tip -| Param | Type | Default | -| ----- | ----- | :-----: | -| array | array | `[]` | -::: - -```js -faker.helpers.shuffle(); // [] -faker.helpers.shuffle(['a', 'b', 'c']); // ["c", "a", "b"] -``` - -## Mustache - -replaces mustache variable in string with provided key pair - -::: tip -| Param | Type | Default | -| ----- | ------ | :-----: | -| str | string | `n/a` | -| data | object | `n/a` | -::: - -```js -faker.helpers.mustache(); // "" -faker.helpers.mustache('{{foo}} was {{baz}}', { foo: 'bar', baz: 42 }); // bar was 42 -``` - -## Create Card - -Returns an object, but the data is not consistent within itself. Please use [Contextual Card](/api/helpers.html#contextual-card) for data that is self-consistent. - -```js -faker.helpers.createCard(); -``` - -```json -{ - "name": "Glen Hahn", - "username": "Darrin_Champlin84", - "email": "Benton_Swift30@hotmail.com", - "address": { - "streetA": "Dickinson Forest", - "streetB": "63914 Eldora Forge", - "streetC": "095 Bella Lodge Apt. 590", - "streetD": "Apt. 980", - "city": "East Allan", - "state": "Nebraska", - "country": "Liechtenstein", - "zipcode": "08027", - "geo": { "lat": "3.4797", "lng": "-123.6115" } - }, - "phone": "(015) 568-3818 x649", - "website": "lysanne.org", - "company": { - "name": "Funk - Nicolas", - "catchPhrase": "Face to face dedicated moratorium", - "bs": "turn-key benchmark web services" - }, - "posts": [ - { - "words": "enim molestias architecto", - "sentence": "Beatae repellat deserunt eos.", - "sentences": "Vero quae laudantium. Vel autem corrupti eligendi. Reiciendis itaque delectus deserunt ea error molestiae aperiam.", - "paragraph": "Et sed nostrum placeat debitis maiores. Eos illum qui qui necessitatibus. Officiis a quisquam labore." - }, - { - "words": "qui dolor nihil", - "sentence": "Occaecati asperiores rerum magni aspernatur eius id officiis.", - "sentences": "Explicabo accusantium enim consequatur. Repellat placeat hic facere natus sint velit eligendi est distinctio.", - "paragraph": "Fugiat maiores corrupti similique laboriosam enim culpa maiores velit. Distinctio consequatur illo commodi fuga quo repellendus. Nihil sequi dolor non. Nihil et blanditiis rerum cupiditate est et facilis aliquam." - }, - { - "words": "nesciunt iusto qui", - "sentence": "Sapiente commodi facere laborum aut.", - "sentences": "Molestias nemo fugiat itaque expedita est aspernatur praesentium explicabo repellat. Ea incidunt quia sint cupiditate saepe et tempora. Autem doloribus dolor eius omnis dolor. Eos laborum nesciunt iste rem placeat ut autem. Commodi error est non sapiente a.", - "paragraph": "Eius maxime enim ut repellendus illum eum aut blanditiis. Quaerat qui omnis ab qui ipsum sint. Officiis iste neque ab qui dolor doloremque rerum quos sed." - } - ], - "accountHistory": [ - { - "amount": "251.84", - "date": "2012-02-02T08:00:00.000Z", - "business": "Breitenberg - Turcotte", - "name": "Checking Account 0226", - "type": "payment", - "account": "66727594" - }, - { - "amount": "740.75", - "date": "2012-02-02T08:00:00.000Z", - "business": "Shields - Heller", - "name": "Checking Account 3782", - "type": "invoice", - "account": "64889716" - }, - { - "amount": "378.68", - "date": "2012-02-02T08:00:00.000Z", - "business": "Dickens and Sons", - "name": "Home Loan Account 1699", - "type": "withdrawal", - "account": "69892278" - } - ] -} -``` - -## Contextual Card - -Returns an object where the name, username, and email are self-referrential. - -```js -faker.helpers.contextualCard(); -``` - -```json -{ - "name": "Joan", - "username": "Joan39", - "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/ripplemdk/128.jpg", - "email": "Joan39_Weimann93@gmail.com", - "dob": "1973-09-26T20:12:25.191Z", - "phone": "650-151-6699 x271", - "address": { - "street": "Boyle Points", - "suite": "Apt. 093", - "city": "Julioville", - "zipcode": "79041", - "geo": { "lat": "63.9355", "lng": "-150.2784" } - }, - "website": "laurianne.info", - "company": { - "name": "Hudson and Sons", - "catchPhrase": "Streamlined transitional firmware", - "bs": "value-added incentivize communities" - } -} -``` - -## User Card - -Returns an object representing a user. - -```js -faker.helpers.userCard(); -``` - -```json -{ - "name": "Adriel Dach", - "username": "Lawson.Rutherford83", - "email": "Kassandra86@gmail.com", - "address": { - "street": "Gislason View", - "suite": "Apt. 409", - "city": "Tellyside", - "zipcode": "00051", - "geo": { "lat": "69.6104", "lng": "-109.3244" } - }, - "phone": "1-685-232-7348", - "website": "dakota.org", - "company": { - "name": "DuBuque Group", - "catchPhrase": "Mandatory multi-state ability", - "bs": "real-time grow methodologies" - } -} -``` - -## Create Transaction - -Returns an object representing a transaction. - -```js -faker.helpers.createTransaction(); -``` - -```json -{ - "amount": "883.74", - "date": "2012-02-02T08:00:00.000Z", - "business": "Brakus LLC", - "name": "Credit Card Account 9671", - "type": "deposit", - "account": "54758588" -} -``` diff --git a/docs/api/image.md b/docs/api/image.md deleted file mode 100644 index 1556ab3407b..00000000000 --- a/docs/api/image.md +++ /dev/null @@ -1,318 +0,0 @@ -# Image - -[[toc]] - -## Image - -Return [lorempixel](http://lorempixel.com/) url - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| randomize | boolean | `false` | -::: - -```js -faker.image.image(); // http://lorempixel.com/640/480/nightlife -faker.image.image(200); // http://lorempixel.com/200/480/sports -faker.image.image(200, 600); // http://lorempixel.com/200/600/animals -faker.image.image(200, 600, true); // http://lorempixel.com/200/600/transport?12438 -``` - -## Avatar - -Return random avatar url - -```js -faker.image.avatar(); // https://s3.amazonaws.com/uifaces/faces/twitter/martip07/128.jpg -``` - -## Data URI - -Return random data uri - -::: tip -| Param | Type | Default | -| ------ | ------ | :-----: | -| width | number | `null` | -| height | number | `null` | -::: - -```js -faker.image.dataUri(); -// data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20baseProfile%3D%22full%22%20width%3D%22undefined%22%20height%3D%22undefined%22%3E%20%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22grey%22%2F%3E%20%20%3Ctext%20x%3D%220%22%20y%3D%2220%22%20font-size%3D%2220%22%20text-anchor%3D%22start%22%20fill%3D%22white%22%3Eundefinedxundefined%3C%2Ftext%3E%20%3C%2Fsvg%3E -``` - -## Image URL - -Return [lorempixel](http://lorempixel.com/) url - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| category | string | `480` | -| randomize | boolean | `false` | -| https | boolean | `false` | - -**Category Options:** `abstract` `animals` `business` `cats` `city` `food` `nightlife` `fashion` `people` `nature` `sports` `technics` `transport` -::: - -```js -faker.image.imageUrl(); // http://lorempixel.com/640/480 -faker.image.imageUrl(200); // http://lorempixel.com/200/480 -faker.image.imageUrl(200, 600); // http://lorempixel.com/200/600 -faker.image.imageUrl(200, 600, 'animals'); // http://lorempixel.com/200/600/animals -faker.image.imageUrl(200, 600, 'animals', true); // http://lorempixel.com/200/600/animals?3853 -faker.image.imageUrl(200, 600, 'animals', true, true); // https://lorempixel.com/200/600/animals?98461 -``` - -## Abstract Image - -Return [lorempixel](http://lorempixel.com/) url from abstract category - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| randomize | boolean | `false` | -::: - -```js -faker.image.abstract(); // http://lorempixel.com/640/480/abstract -faker.image.abstract(200); // http://lorempixel.com/200/480/abstract -faker.image.abstract(200, 600); // http://lorempixel.com/200/600/abstract -faker.image.abstract(200, 600, true); // http://lorempixel.com/200/600/abstract?89872 -``` - -## Animal Image - -Return [lorempixel](http://lorempixel.com/) url from animals category - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| randomize | boolean | `false` | -::: - -```js -faker.image.animals(); // http://lorempixel.com/640/480/animals -faker.image.animals(200); // http://lorempixel.com/200/480/animals -faker.image.animals(200, 600); // http://lorempixel.com/200/600/animals -faker.image.animals(200, 600, true); // http://lorempixel.com/200/600/animals?89872 -``` - -## Business Image - -Return [lorempixel](http://lorempixel.com/) url from business category - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| randomize | boolean | `false` | -::: - -```js -faker.image.business(); // http://lorempixel.com/640/480/business -faker.image.business(200); // http://lorempixel.com/200/480/business -faker.image.business(200, 600); // http://lorempixel.com/200/600/business -faker.image.business(200, 600, true); // http://lorempixel.com/200/600/business?89872 -``` - -## Cat Image - -Return [lorempixel](http://lorempixel.com/) url from cats category - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| randomize | boolean | `false` | -::: - -```js -faker.image.cats(); // http://lorempixel.com/640/480/cats -faker.image.cats(200); // http://lorempixel.com/200/480/cats -faker.image.cats(200, 600); // http://lorempixel.com/200/600/cats -faker.image.cats(200, 600, true); // http://lorempixel.com/200/600/cats?89872 -``` - -## City Image - -Return [lorempixel](http://lorempixel.com/) url from city category - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| randomize | boolean | `false` | -::: - -```js -faker.image.city(); // http://lorempixel.com/640/480/city -faker.image.city(200); // http://lorempixel.com/200/480/city -faker.image.city(200, 600); // http://lorempixel.com/200/600/city -faker.image.city(200, 600, true); // http://lorempixel.com/200/600/city?89872 -``` - -## Food Image - -Return [lorempixel](http://lorempixel.com/) url from food category - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| randomize | boolean | `false` | -::: - -```js -faker.image.food(); // http://lorempixel.com/640/480/food -faker.image.food(200); // http://lorempixel.com/200/480/food -faker.image.food(200, 600); // http://lorempixel.com/200/600/food -faker.image.food(200, 600, true); // http://lorempixel.com/200/600/food?89872 -``` - -## Nightlife Image - -Return [lorempixel](http://lorempixel.com/) url from nightlife category - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| randomize | boolean | `false` | -::: - -```js -faker.image.nightlife(); // http://lorempixel.com/640/480/nightlife -faker.image.nightlife(200); // http://lorempixel.com/200/480/nightlife -faker.image.nightlife(200, 600); // http://lorempixel.com/200/600/nightlife -faker.image.nightlife(200, 600, true); // http://lorempixel.com/200/600/nightlife?89872 -``` - -## Fashion Image - -Return [lorempixel](http://lorempixel.com/) url from fashion category - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| randomize | boolean | `false` | -::: - -```js -faker.image.fashion(); // http://lorempixel.com/640/480/fashion -faker.image.fashion(200); // http://lorempixel.com/200/480/fashion -faker.image.fashion(200, 600); // http://lorempixel.com/200/600/fashion -faker.image.fashion(200, 600, true); // http://lorempixel.com/200/600/fashion?89872 -``` - -## People Image - -Return [lorempixel](http://lorempixel.com/) url from people category - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| randomize | boolean | `false` | -::: - -```js -faker.image.people(); // http://lorempixel.com/640/480/people -faker.image.people(200); // http://lorempixel.com/200/480/people -faker.image.people(200, 600); // http://lorempixel.com/200/600/people -faker.image.people(200, 600, true); // http://lorempixel.com/200/600/people?89872 -``` - -## Nature Image - -Return [lorempixel](http://lorempixel.com/) url from nature category - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| randomize | boolean | `false` | -::: - -```js -faker.image.nature(); // http://lorempixel.com/640/480/nature -faker.image.nature(200); // http://lorempixel.com/200/480/nature -faker.image.nature(200, 600); // http://lorempixel.com/200/600/nature -faker.image.nature(200, 600, true); // http://lorempixel.com/200/600/nature?89872 -``` - -## Sports Image - -Return [lorempixel](http://lorempixel.com/) url from sports category - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| randomize | boolean | `false` | -::: - -```js -faker.image.sports(); // http://lorempixel.com/640/480/sports -faker.image.sports(200); // http://lorempixel.com/200/480/sports -faker.image.sports(200, 600); // http://lorempixel.com/200/600/sports -faker.image.sports(200, 600, true); // http://lorempixel.com/200/600/sports?89872 -``` - -## Technics Image - -Return [lorempixel](http://lorempixel.com/) url from technics category - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| randomize | boolean | `false` | -::: - -```js -faker.image.technics(); // http://lorempixel.com/640/480/technics -faker.image.technics(200); // http://lorempixel.com/200/480/technics -faker.image.technics(200, 600); // http://lorempixel.com/200/600/technics -faker.image.technics(200, 600, true); // http://lorempixel.com/200/600/technics?89872 -``` - -## Transport Image - -Return [lorempixel](http://lorempixel.com/) url from transport category - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| width | number | `640` | -| height | number | `480` | -| randomize | boolean | `false` | -::: - -```js -faker.image.transport(); // http://lorempixel.com/640/480/transport -faker.image.transport(200); // http://lorempixel.com/200/480/transport -faker.image.transport(200, 600); // http://lorempixel.com/200/600/transport -faker.image.transport(200, 600, true); // http://lorempixel.com/200/600/transport?89872 -``` diff --git a/docs/api/internet.md b/docs/api/internet.md deleted file mode 100644 index 3053881e270..00000000000 --- a/docs/api/internet.md +++ /dev/null @@ -1,186 +0,0 @@ -# Internet - -[[toc]] - -## Avatar - -return random avatar url - -```js -faker.internet.avatar(); -// https://s3.amazonaws.com/uifaces/faces/twitter/dnezkumar/128.jpg -``` - -## Example E-mail - -Generates random email address from [safe domains](https://en.wikipedia.org/wiki/Example.com) - -::: tip -| Param | Type | Default | -| --------- | ------ | :----------------------: | -| firstName | string | `faker.name.firstName()` | -| lastName | string | `faker.name.lastName()` | -::: - -```js -faker.internet.exampleEmail(); // Rhiannon_Von81@example.com -faker.internet.exampleEmail('bob'); // bob26@example.net -faker.internet.exampleEmail('bob', 'jon'); // bob_jon@example.com -``` - -## E-mail - -Generates random email address - -::: danger -This uses real domains so it is likely to create a "real" email address. Use `exampleEmail()` to be safe. -::: - -::: tip -| Param | Type | Default | -| --------- | ------ | :-----------------------------------: | -| firstName | string | `faker.name.firstName()` | -| lastName | string | `faker.name.lastName()` | -| provider | string | `gmail.com` `yahoo.com` `hotmail.com` | -::: - -```js -faker.internet.email(); // Ottis_Cremin16@yahoo.com -faker.internet.email('bob'); // bob_jon@example.com -faker.internet.email('bob', 'jon'); // bob_jon73@hotmail.com -faker.internet.email('bob', 'jon', 'somedomain.com'); // bob_jon@somedomain.com -``` - -## User Name - -Generates a username based on one of several patterns. - -The pattern is chosen randomly from one of the following: `firstname#` `firstname.lastname` `firstname.lastname#` `firstnamelastname` `firstnamelastname#` - -::: tip -| Param | Type | Default | -| --------- | ------ | :----------------------: | -| firstName | string | `faker.name.firstName()` | -| lastName | string | `faker.name.lastName()` | -::: - -```js -faker.internet.userName(); // Maci12 -faker.internet.userName('bob')); // bob_Considine30 -faker.internet.userName('bob', 'jon')); // bob.jon61 -``` - -## Protocol - -Randomly generates http or https - -```js -faker.internet.protocol(); // https -``` - -## URL - -Generates a random URL. The URL could be secure or insecure. - -```js -faker.internet.url(); // http://chloe.net -``` - -## Domain Name - -Generates a random domain name. - -```js -faker.internet.domainName(); // hailie.biz -``` - -## Domain Suffix - -Generates a random domain suffix. - -```js -faker.internet.domainSuffix(); // org -``` - -## Domain Word - -Generates a random domain word. - -```js -faker.internet.domainWord(); // mattie -``` - -## IP Address - -Generates a random IP. - -```js -faker.internet.ip(); // 165.20.179.86 -``` - -## IPV6 - -Generates a random IPv6 address. - -```js -faker.internet.ipv6(); // 0e1a:48d6:8da6:b933:be58:442d:71db:42d7 -``` - -## User Agent - -Generates a random user agent. - -```js -faker.internet.userAgent(); -// Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20100101 Firefox/6.0.0 -``` - -## Hexadecimal Color - -Generates a random hexadecimal color based on [this awesome response](http://stackoverflow.com/questions/43044/algorithm-to-randomly-generate-an-aesthetically-pleasing-color-palette) - -::: tip -| Param | Type | Default | -| ------------ | ------ | :-----: | -| baseRed255 | number | `0` | -| baseGreen255 | number | `0` | -| baseBlue255 | number | `0` | -::: - -```js -faker.internet.color(); // #630c7b -faker.internet.color(128); // #910145 -faker.internet.color(122, 148); // #a06a09 -faker.internet.color(42, 22, 11); // #48166d -``` - -## MAC Address - -Generates a random mac address. - -```js -faker.internet.mac(); // 00:87:14:24:31:ba -``` - -## Password - -Generates a random password. - -::: tip -| Param | Type | Default | -| --------- | ------- | :-----: | -| len | number | `15` | -| memorable | boolean | `false` | -| pattern | regex | `/\w/` | -| prefix | string | `''` | - -**Note:** `pattern` param is ignored if memorable is set to `true` -::: - -```js -faker.internet.password(); // 0ViHvR3Qp7AAsir -faker.internet.password(8); // m9Qw6dzR -faker.internet.password(8, true); // qecuquha -faker.internet.password(8, false, /^[A-Z]*$/); // PQGGVATB -faker.internet.password(8, false, /^[A-Z]*$/, 'bob'); // bobTXMPD -``` diff --git a/package.json b/package.json index 6bf7453f1b4..8914cdb7a50 100644 --- a/package.json +++ b/package.json @@ -55,9 +55,13 @@ "build:code": "esno ./scripts/bundle.ts", "build:types": "tsc --emitDeclarationOnly --outDir dist/types", "build": "run-s build:clean build:code build:types", - "docs:build": "vitepress build docs", + "generate:api-docs": "esno scripts/apidoc.ts", + "docs:build": "run-s docs:prepare docs:build:run", + "docs:build:run": "vitepress build docs", "docs:build:ci": "run-s build docs:build", - "docs:dev": "vitepress dev docs", + "docs:prepare": "run-s generate:api-docs", + "docs:dev": "run-s docs:prepare docs:dev:run", + "docs:dev:run": "vitepress dev docs", "docs:serve": "vitepress serve docs", "format": "prettier --write .", "lint": "echo 'TODO eslint'", @@ -89,6 +93,8 @@ "prettier": "2.5.1", "rimraf": "~3.0.2", "simple-git-hooks": "~2.7.0", + "typedoc": "~0.22.11", + "typedoc-plugin-missing-exports": "~0.22.6", "typescript": "~4.5.5", "vite": "~2.7.13", "vitepress": "^0.21.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c003143bf1d..3d88d331a85 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,6 +13,8 @@ specifiers: prettier: 2.5.1 rimraf: ~3.0.2 simple-git-hooks: ~2.7.0 + typedoc: ~0.22.11 + typedoc-plugin-missing-exports: ~0.22.6 typescript: ~4.5.5 vite: ~2.7.13 vitepress: ^0.21.4 @@ -31,6 +33,8 @@ devDependencies: prettier: 2.5.1 rimraf: 3.0.2 simple-git-hooks: 2.7.0 + typedoc: 0.22.11_typescript@4.5.5 + typedoc-plugin-missing-exports: 0.22.6_typedoc@0.22.11 typescript: 4.5.5 vite: 2.7.13 vitepress: 0.21.6 @@ -275,7 +279,7 @@ packages: resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} dependencies: '@types/minimatch': 3.0.5 - '@types/node': 17.0.10 + '@types/node': 17.0.12 dev: true /@types/istanbul-lib-coverage/2.0.4: @@ -290,8 +294,8 @@ packages: resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} dev: true - /@types/node/17.0.10: - resolution: {integrity: sha512-S/3xB4KzyFxYGCppyDt68yzBU9ysL88lSdIah4D6cptdcltc4NCPCAMc0+PCpg/lLIyC7IPvj2Z52OJWeIUkog==} + /@types/node/17.0.12: + resolution: {integrity: sha512-4YpbAsnJXWYK/fpTVFlMIcUIho2AYCi4wg5aNPrG1ng7fn/1/RZfCIpRCiBX+12RVa34RluilnvCqD+g3KiSiA==} dev: true /@types/normalize-package-data/2.4.1: @@ -633,14 +637,15 @@ packages: engines: {node: '>=6'} dev: true - /chai/4.3.4: - resolution: {integrity: sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==} + /chai/4.3.5: + resolution: {integrity: sha512-0gKhNDL29PUlmwz1CG42p/OaBf1v0YD3oH4//YMS1niT7rLH9tC+lqTgk+SvdbhMLd7ToTtxA61orNBmpSO/DA==} engines: {node: '>=4'} dependencies: assertion-error: 1.1.0 check-error: 1.0.2 deep-eql: 3.0.1 get-func-name: 2.0.0 + loupe: 2.3.0 pathval: 1.1.1 type-detect: 4.0.8 dev: true @@ -2289,6 +2294,10 @@ packages: resolution: {integrity: sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=} dev: true + /jsonc-parser/3.0.0: + resolution: {integrity: sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==} + dev: true + /jsonparse/1.3.1: resolution: {integrity: sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=} engines: {'0': node >= 0.2.0} @@ -2451,6 +2460,13 @@ packages: wrap-ansi: 3.0.1 dev: true + /loupe/2.3.0: + resolution: {integrity: sha512-b6TVXtF01VErh8IxN/MfdiWLQmttrenN98PPGS01kym8kGycJ9tqBXD6D+4sNEDhgE83+H0Mk1cVSl0mD1nNSg==} + dependencies: + get-func-name: 2.0.0 + type-detect: 4.0.8 + dev: true + /lru-cache/6.0.0: resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} engines: {node: '>=10'} @@ -2458,6 +2474,10 @@ packages: yallist: 4.0.0 dev: true + /lunr/2.3.9: + resolution: {integrity: sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==} + dev: true + /magic-string/0.25.7: resolution: {integrity: sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==} dependencies: @@ -2481,6 +2501,12 @@ packages: engines: {node: '>=8'} dev: true + /marked/4.0.10: + resolution: {integrity: sha512-+QvuFj0nGgO970fySghXGmuw+Fd0gD2x3+MqCWLIPf5oxdv1Ka6b2q+z9RP01P/IaKPMEramy+7cNy/Lw8c3hw==} + engines: {node: '>= 12'} + hasBin: true + dev: true + /memorystream/0.3.1: resolution: {integrity: sha1-htcJCzDORV1j+64S3aUaR93K+bI=} engines: {node: '>= 0.10.0'} @@ -3073,8 +3099,8 @@ packages: glob: 7.2.0 dev: true - /rollup/2.66.0: - resolution: {integrity: sha512-L6mKOkdyP8HK5kKJXaiWG7KZDumPJjuo1P+cfyHOJPNNTK3Moe7zCH5+fy7v8pVmHXtlxorzaBjvkBMB23s98g==} + /rollup/2.66.1: + resolution: {integrity: sha512-crSgLhSkLMnKr4s9iZ/1qJCplgAgrRY+igWv8KhG/AjKOJ0YX/WpmANyn8oxrw+zenF3BXWDLa7Xl/QZISH+7w==} engines: {node: '>=10.0.0'} hasBin: true optionalDependencies: @@ -3161,6 +3187,14 @@ packages: resolution: {integrity: sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==} dev: true + /shiki/0.10.0: + resolution: {integrity: sha512-iczxaIYeBFHTFrQPb9DVy2SKgYxC4Wo7Iucm7C17cCh2Ge/refnvHscUOxM85u57MfLoNOtjoEFUWt9gBexblA==} + dependencies: + jsonc-parser: 3.0.0 + vscode-oniguruma: 1.6.1 + vscode-textmate: 5.2.0 + dev: true + /side-channel/1.0.4: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} dependencies: @@ -3555,6 +3589,29 @@ packages: engines: {node: '>=8'} dev: true + /typedoc-plugin-missing-exports/0.22.6_typedoc@0.22.11: + resolution: {integrity: sha512-1uguGQqa+c5f33nWS3v1mm0uAx4Ii1lw4Kx2zQksmYFKNEWTmrmMXbMNBoBg4wu0p4dFCNC7JIWPoRzpNS6pFA==} + peerDependencies: + typedoc: 0.22.x + dependencies: + typedoc: 0.22.11_typescript@4.5.5 + dev: true + + /typedoc/0.22.11_typescript@4.5.5: + resolution: {integrity: sha512-pVr3hh6dkS3lPPaZz1fNpvcrqLdtEvXmXayN55czlamSgvEjh+57GUqfhAI1Xsuu/hNHUT1KNSx8LH2wBP/7SA==} + engines: {node: '>= 12.10.0'} + hasBin: true + peerDependencies: + typescript: 4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x + dependencies: + glob: 7.2.0 + lunr: 2.3.9 + marked: 4.0.10 + minimatch: 3.0.4 + shiki: 0.10.0 + typescript: 4.5.5 + dev: true + /typescript/4.5.5: resolution: {integrity: sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==} engines: {node: '>=4.2.0'} @@ -3633,7 +3690,7 @@ packages: esbuild: 0.13.15 postcss: 8.4.5 resolve: 1.22.0 - rollup: 2.66.0 + rollup: 2.66.1 optionalDependencies: fsevents: 2.3.2 dev: true @@ -3682,7 +3739,7 @@ packages: '@types/chai-subset': 1.3.3 '@vitest/ui': 0.1.27 c8: 7.11.0 - chai: 4.3.4 + chai: 4.3.5 local-pkg: 0.4.1 tinypool: 0.1.1 tinyspy: 0.2.8 @@ -3693,6 +3750,14 @@ packages: - stylus dev: true + /vscode-oniguruma/1.6.1: + resolution: {integrity: sha512-vc4WhSIaVpgJ0jJIejjYxPvURJavX6QG41vu0mGhqywMkQqulezEqEQ3cO3gc8GvcOpX6ycmKGqRoROEMBNXTQ==} + dev: true + + /vscode-textmate/5.2.0: + resolution: {integrity: sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==} + dev: true + /vue/3.2.29: resolution: {integrity: sha512-cFIwr7LkbtCRanjNvh6r7wp2yUxfxeM2yPpDQpAfaaLIGZSrUmLbNiSze9nhBJt5MrZ68Iqt0O5scwAMEVxF+Q==} dependencies: diff --git a/scripts/apidoc.ts b/scripts/apidoc.ts new file mode 100644 index 00000000000..956e53e685b --- /dev/null +++ b/scripts/apidoc.ts @@ -0,0 +1,244 @@ +import * as TypeDoc from 'typedoc'; +import { writeFileSync } from 'fs'; +import { resolve } from 'path'; +import { format } from 'prettier'; +import options from '../.prettierrc.cjs'; +import faker from '../src'; + +const pathRoot = resolve(__dirname, '..'); +const pathDocsDir = resolve(pathRoot, 'docs'); +const pathDocsApiPages = resolve(pathDocsDir, '.vitepress', 'api-pages.mjs'); +const pathOutputDir = resolve(pathDocsDir, 'api'); +const pathOutputJson = resolve(pathOutputDir, 'typedoc.json'); + +const scriptCommand = 'pnpm run generate:api-docs'; + +function toBlock(comment?: TypeDoc.Comment): string { + return ( + (comment?.shortText.trim() || 'Missing') + + (comment?.text ? '\n\n' + comment.text : '') + ); +} + +function escape(value: string): string { + return value.replace(/\|/g, '\\|').replace(//g, '\\>'); +} + +function parameterRow( + name: string, + type?: string, + def?: string, + comment?: TypeDoc.Comment +): string { + def = def ? `\`${def}\`` : ''; + return ( + '| ' + + escape(name) + + ' | ' + + escape(type) + + ' | ' + + def + + ' | ' + + escape(toBlock(comment)) + .replace(/\n{2,}/, '
') + .replace(/\n/, '') + + '|\n' + ); +} + +async function build(): Promise { + const app = new TypeDoc.Application(); + + app.options.addReader(new TypeDoc.TSConfigReader()); + // If you want TypeDoc to load typedoc.json files + //app.options.addReader(new TypeDoc.TypeDocReader()); + + app.bootstrap({ + entryPoints: ['src/index.ts'], + pretty: true, + cleanOutputDir: true, + }); + + const project = app.convert(); + + if (!project) { + // Project may not have converted correctly + return; + } + // Useful for analyzing the content + await app.generateJson(project, pathOutputJson); + + const modules = project + .getChildrenByKind(TypeDoc.ReflectionKind.Namespace)[0] + .getChildrenByKind(TypeDoc.ReflectionKind.Class); + + const modulesPages: Array<{ text: string; link: string }> = []; + modulesPages.push({ text: 'Faker', link: '/api/faker' }); + modulesPages.push({ text: 'Localization', link: '/api/localization' }); + + // Generate module file + for (const module of modules) { + const moduleName = module.name.replace('_', ''); + const lowerModuleName = + moduleName.substring(0, 1).toLowerCase() + moduleName.substring(1); + console.log(`Processing Module ${moduleName}`); + + modulesPages.push({ text: moduleName, link: '/api/' + lowerModuleName }); + + let content = ` + # ${moduleName} + + + + + [[toc]] + + ::: v-pre + + ${toBlock(module.comment)} + + `.replace(/\n +/g, '\n'); + + const methods = module.getChildrenByKind(TypeDoc.ReflectionKind.Method); + + // Generate method section + for (let method of methods) { + const methodName = method.name; + const prettyMethodName = + methodName.substring(0, 1).toUpperCase() + + methodName.substring(1).replace(/([A-Z]+)/g, ' $1'); + console.log(`- method ${prettyMethodName}`); + const signature = method.signatures[0]; + + content += ` + ## ${prettyMethodName} + + ${toBlock(signature.comment)} + + `.replace(/\n +/g, '\n'); + + // Generate parameter section + const typeParameters = signature.typeParameters || []; + const parameters = signature.parameters || []; + const signatureTypeParameters: string[] = []; + const signatureParameters: string[] = []; + let requiresArgs = false; + if (typeParameters.length !== 0 || parameters.length !== 0) { + content += `**Parameters**\n\n`; + + content += '| Name | Type | Default | Description |\n'; + content += '| ---- | ---- | ------- | ----------- |\n'; + + // typeParameters + typeParameters.forEach((parameter, index) => { + const parameterName = parameter.name; + + signatureTypeParameters.push(parameterName); + content += parameterRow( + `<${parameterName}>`, + '', + '', + parameter.comment + ); + }); + + // parameters + parameters.forEach((parameter, index) => { + const parameterDefault = parameter.defaultValue; + const parameterRequired = typeof parameterDefault === 'undefined'; + if (index == 0) { + requiresArgs = parameterRequired; + } + const parameterName = parameter.name + (parameterRequired ? '?' : ''); + const parameterType = parameter.type.toString(); + + let parameterDefaultSignatureText = ''; + if (!parameterRequired) { + parameterDefaultSignatureText = ' = ' + parameterDefault; + } + + signatureParameters.push( + parameterName + ': ' + parameterType + parameterDefaultSignatureText + ); + content += parameterRow( + parameterName, + parameterType, + parameterDefault, + parameter.comment + ); + }); + content += '\n\n'; + } + content += '**Returns:** ' + signature.type.toString() + '\n\n'; + + // Generate usage section + + content += '````ts\n'; + + let signatureTypeParametersString = signatureTypeParameters.join(', '); + if (signatureTypeParametersString.length !== 0) { + signatureTypeParametersString = `<${signatureTypeParametersString}>`; + } + const signatureParametersString = signatureParameters.join(', '); + + content += `faker.${lowerModuleName}.${methodName}${signatureTypeParametersString}(${signatureParametersString}): ${signature.type.toString()}\n`; + faker.seed(0); + if (!requiresArgs) { + try { + let example = JSON.stringify(faker[lowerModuleName][methodName]()); + if (example.length > 50) { + example = example.substring(0, 47) + '...'; + } + + content += `faker.${lowerModuleName}.${methodName}()`; + content += (example ? ` // => ${example}` : '') + '\n'; + } catch { + console.log( + `Failed to call: faker.${lowerModuleName}${methodName}()` + ); + } + } + let examples = + signature?.comment?.tags + .filter((tag) => tag.tagName === 'example') + .map((tag) => tag.text.trimEnd()) || []; + + if (examples.length !== 0) { + console.log('Example-Length: ' + examples); + content += examples.join('\n') + '\n'; + } + + content += '````\n\n'; + } + + // Format md + + content = format(content, { + ...options, + parser: 'markdown', + }); + + // Write to disk + + writeFileSync(resolve(pathOutputDir, lowerModuleName + '.md'), content); + console.log(`Done Module ${moduleName}`); + } + + // Write api-pages.mjs + modulesPages.sort((a, b) => a.text.localeCompare(b.text)); + let apiPagesContent = ` + // This file is automatically generated. + // Run '${scriptCommand}' to update + export const apiPages = ${JSON.stringify(modulesPages)}; + `.replace(/\n +/, '\n'); + + apiPagesContent = format(apiPagesContent, { + ...options, + parser: 'babel', + }); + + writeFileSync(pathDocsApiPages, apiPagesContent); + console.log('Updated api-pages.mjs'); +} + +build().catch(console.error); From 15514b5cd211a880aa5ff11c8c809168e9e1ac92 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Thu, 27 Jan 2022 21:06:43 +0100 Subject: [PATCH 02/10] fix: fake docs not accessible (#323) --- scripts/apidoc.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/apidoc.ts b/scripts/apidoc.ts index 956e53e685b..01606ec56b1 100644 --- a/scripts/apidoc.ts +++ b/scripts/apidoc.ts @@ -73,8 +73,8 @@ async function build(): Promise { .getChildrenByKind(TypeDoc.ReflectionKind.Class); const modulesPages: Array<{ text: string; link: string }> = []; - modulesPages.push({ text: 'Faker', link: '/api/faker' }); - modulesPages.push({ text: 'Localization', link: '/api/localization' }); + modulesPages.push({ text: 'Fake', link: '/api/fake.html' }); + modulesPages.push({ text: 'Localization', link: '/api/localization.html' }); // Generate module file for (const module of modules) { @@ -83,7 +83,10 @@ async function build(): Promise { moduleName.substring(0, 1).toLowerCase() + moduleName.substring(1); console.log(`Processing Module ${moduleName}`); - modulesPages.push({ text: moduleName, link: '/api/' + lowerModuleName }); + modulesPages.push({ + text: moduleName, + link: `/api/${lowerModuleName}.html`, + }); let content = ` # ${moduleName} From 31830dc5b84cdf4ac54f0aacdafba83731dd1a33 Mon Sep 17 00:00:00 2001 From: Jess Date: Thu, 27 Jan 2022 15:56:33 -0500 Subject: [PATCH 03/10] fix: docs v-pre issue (#326) --- scripts/apidoc.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/apidoc.ts b/scripts/apidoc.ts index 01606ec56b1..62fc9ed5762 100644 --- a/scripts/apidoc.ts +++ b/scripts/apidoc.ts @@ -100,6 +100,8 @@ async function build(): Promise { ${toBlock(module.comment)} + ::: + `.replace(/\n +/g, '\n'); const methods = module.getChildrenByKind(TypeDoc.ReflectionKind.Method); @@ -116,8 +118,12 @@ async function build(): Promise { content += ` ## ${prettyMethodName} + ::: v-pre + ${toBlock(signature.comment)} + ::: + `.replace(/\n +/g, '\n'); // Generate parameter section From c96bf1462bf41f80294b641701cedf0e47a7a7d6 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Fri, 28 Jan 2022 08:28:21 +0100 Subject: [PATCH 04/10] build: add clean command (#325) --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 8914cdb7a50..56c66a713ae 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "tsconfig.json" ], "scripts": { + "clean": "rimraf coverage dist docs/.vitepress/dist pnpm-lock.yaml node_modules", "build:clean": "rimraf dist", "build:code": "esno ./scripts/bundle.ts", "build:types": "tsc --emitDeclarationOnly --outDir dist/types", From 7396a571fff111bd705601963db85d15be096f12 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Fri, 28 Jan 2022 08:28:40 +0100 Subject: [PATCH 05/10] test: use run for coverage (#318) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 56c66a713ae..0c5c9301a8b 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "format": "prettier --write .", "lint": "echo 'TODO eslint'", "test": "vitest", - "coverage": "vitest --coverage" + "coverage": "vitest run --coverage" }, "simple-git-hooks": { "pre-commit": "npx lint-staged --concurrent false", From c9a540f5ce955fa66c29f43be9f334e7f6366ac7 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Fri, 28 Jan 2022 08:28:52 +0100 Subject: [PATCH 06/10] chore: replace var (#315) --- src/datatype.ts | 2 +- src/helpers.ts | 4 ++-- src/name.ts | 18 +++++++++--------- src/word.ts | 12 ++++++------ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/datatype.ts b/src/datatype.ts index e5dac1f941d..7cf280121d3 100644 --- a/src/datatype.ts +++ b/src/datatype.ts @@ -139,7 +139,7 @@ export class Datatype { let returnString = ''; - for (var i = 0; i < length; i++) { + for (let i = 0; i < length; i++) { returnString += String.fromCharCode( this.faker.datatype.number(charCodeOption) ); diff --git a/src/helpers.ts b/src/helpers.ts index 2c83a96e23e..5b95e25ff1d 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -381,8 +381,8 @@ export class Helpers { * @method faker.helpers.contextualCard */ contextualCard() { - var name = this.faker.name.firstName(), - userName = this.faker.internet.userName(name); + const name = this.faker.name.firstName(); + const userName = this.faker.internet.userName(name); return { name: name, username: userName, diff --git a/src/name.ts b/src/name.ts index bbb71c8c57e..e19dab2c169 100644 --- a/src/name.ts +++ b/src/name.ts @@ -247,15 +247,15 @@ export class Name { * @memberof faker.name */ title(): string { - var descriptor = this.faker.random.arrayElement( - this.faker.definitions.name.title.descriptor - ), - level = this.faker.random.arrayElement( - this.faker.definitions.name.title.level - ), - job = this.faker.random.arrayElement( - this.faker.definitions.name.title.job - ); + const descriptor = this.faker.random.arrayElement( + this.faker.definitions.name.title.descriptor + ); + const level = this.faker.random.arrayElement( + this.faker.definitions.name.title.level + ); + const job = this.faker.random.arrayElement( + this.faker.definitions.name.title.job + ); return descriptor + ' ' + level + ' ' + job; } diff --git a/src/word.ts b/src/word.ts index a5111dca1cd..5bd9cefa9eb 100644 --- a/src/word.ts +++ b/src/word.ts @@ -18,7 +18,7 @@ export class Word { * @param optional length of word to return */ adjective(length?: number): string { - var wordList = this.faker.definitions.word.adjective; + let wordList = this.faker.definitions.word.adjective; if (length) { wordList = this.faker.definitions.word.adjective.filter( @@ -64,7 +64,7 @@ export class Word { * @param optional length of word to return */ conjunction(length?: number): string { - var wordList = this.faker.definitions.word.conjunction; + let wordList = this.faker.definitions.word.conjunction; if (length) { wordList = this.faker.definitions.word.conjunction.filter( @@ -87,7 +87,7 @@ export class Word { * @param optional length of word to return */ interjection(length?: number): string { - var wordList = this.faker.definitions.word.interjection; + let wordList = this.faker.definitions.word.interjection; if (length) { wordList = this.faker.definitions.word.interjection.filter( @@ -110,7 +110,7 @@ export class Word { * @param optional length of word to return */ noun(length?: number): string { - var wordList = this.faker.definitions.word.noun; + let wordList = this.faker.definitions.word.noun; if (length) { wordList = this.faker.definitions.word.noun.filter( @@ -133,7 +133,7 @@ export class Word { * @param optional length of word to return */ preposition(length?: number): string { - var wordList = this.faker.definitions.word.preposition; + let wordList = this.faker.definitions.word.preposition; if (length) { wordList = this.faker.definitions.word.preposition.filter( @@ -156,7 +156,7 @@ export class Word { * @param optional length of word to return */ verb(length?: number): string { - var wordList = this.faker.definitions.word.verb; + let wordList = this.faker.definitions.word.verb; if (length) { wordList = this.faker.definitions.word.verb.filter( From e63baaa4ad88e3ed69c82096a0ffbbce38facdc8 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Fri, 28 Jan 2022 08:29:01 +0100 Subject: [PATCH 07/10] chore: configure .vscode (#311) --- .vscode/extensions.json | 6 +++++- .vscode/settings.json | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json index fbb6cfec74f..17fab0c02b3 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,3 +1,7 @@ { - "recommendations": ["editorconfig.editorconfig", "esbenp.prettier-vscode"] + "recommendations": [ + "dbaeumer.vscode-eslint", + "editorconfig.editorconfig", + "esbenp.prettier-vscode" + ] } diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000000..014dbf07a16 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + // Enable eslint validation for js and ts files + "eslint.validate": ["javascript", "typescript"], + + // Always use the `package.json`'s `typescript` + "typescript.tsdk": "node_modules/typescript/lib" +} From 90d48da0bef125fd84fc758cebaeae4fab6c06bc Mon Sep 17 00:00:00 2001 From: Shinigami Date: Fri, 28 Jan 2022 08:29:10 +0100 Subject: [PATCH 08/10] ci: check formatting (#317) --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5dc89fa1512..2ae48deec26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,3 +70,6 @@ jobs: - name: Lint run: pnpm run lint + + - name: Check formatting + run: pnpm prettier --check . From 4ca61ca5b73c3cd4a0ba4094aabd492e2b7f74bf Mon Sep 17 00:00:00 2001 From: Eric Cheng Date: Fri, 28 Jan 2022 02:29:41 -0500 Subject: [PATCH 09/10] fix: some return types (#307) --- src/database.ts | 8 ++++---- src/finance.ts | 6 +++--- src/hacker.ts | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/database.ts b/src/database.ts index c0513bbc5ec..abfaea85315 100644 --- a/src/database.ts +++ b/src/database.ts @@ -38,7 +38,7 @@ export class Database { * * @method faker.database.column */ - column() { + column(): string { return this.faker.random.arrayElement( this.faker.definitions.database.column ); @@ -49,7 +49,7 @@ export class Database { * * @method faker.database.type */ - type() { + type(): string { return this.faker.random.arrayElement(this.faker.definitions.database.type); } @@ -58,7 +58,7 @@ export class Database { * * @method faker.database.collation */ - collation() { + collation(): string { return this.faker.random.arrayElement( this.faker.definitions.database.collation ); @@ -69,7 +69,7 @@ export class Database { * * @method faker.database.engine */ - engine() { + engine(): string { return this.faker.random.arrayElement( this.faker.definitions.database.engine ); diff --git a/src/finance.ts b/src/finance.ts index 4ccc06bdd7b..34786faae90 100644 --- a/src/finance.ts +++ b/src/finance.ts @@ -153,7 +153,7 @@ export class Finance { * * @method faker.finance.currencyCode */ - currencyCode() { + currencyCode(): string { // TODO @Shinigami92 2022-01-14: missing second parameter // @ts-expect-error return this.faker.random.objectElement( @@ -166,7 +166,7 @@ export class Finance { * * @method faker.finance.currencyName */ - currencyName() { + currencyName(): string { return this.faker.random.objectElement( this.faker.definitions.finance.currency, 'key' @@ -178,7 +178,7 @@ export class Finance { * * @method faker.finance.currencySymbol */ - currencySymbol() { + currencySymbol(): string { let symbol; while (!symbol) { diff --git a/src/hacker.ts b/src/hacker.ts index ee36d814d43..dac9b4f6d9e 100644 --- a/src/hacker.ts +++ b/src/hacker.ts @@ -16,7 +16,7 @@ export class Hacker { * * @method faker.hacker.abbreviation */ - abbreviation() { + abbreviation(): string { return this.faker.random.arrayElement( this.faker.definitions.hacker.abbreviation ); @@ -27,7 +27,7 @@ export class Hacker { * * @method faker.hacker.adjective */ - adjective() { + adjective(): string { return this.faker.random.arrayElement( this.faker.definitions.hacker.adjective ); @@ -38,7 +38,7 @@ export class Hacker { * * @method faker.hacker.noun */ - noun() { + noun(): string { return this.faker.random.arrayElement(this.faker.definitions.hacker.noun); } @@ -47,7 +47,7 @@ export class Hacker { * * @method faker.hacker.verb */ - verb() { + verb(): string { return this.faker.random.arrayElement(this.faker.definitions.hacker.verb); } @@ -56,7 +56,7 @@ export class Hacker { * * @method faker.hacker.ingverb */ - ingverb() { + ingverb(): string { return this.faker.random.arrayElement( this.faker.definitions.hacker.ingverb ); @@ -67,7 +67,7 @@ export class Hacker { * * @method faker.hacker.phrase */ - phrase() { + phrase(): string { const data = { abbreviation: this.abbreviation, adjective: this.adjective, From 32b483920450a5c1a084e83723f1c433db8ff34f Mon Sep 17 00:00:00 2001 From: Eric Cheng Date: Fri, 28 Jan 2022 02:30:20 -0500 Subject: [PATCH 10/10] feat: add chat.fakerjs.dev subdomain redirection to discord (#306) Co-authored-by: ST-DDT --- .github/ISSUE_TEMPLATE/config.yml | 2 +- CODE_OF_CONDUCT.md | 2 +- README.md | 2 +- docs/guide/index.md | 2 +- docs/update.md | 2 +- netlify.toml | 5 +++++ 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 313e09953ef..6af839564f0 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,7 +1,7 @@ blank_issues_enabled: false contact_links: - name: Discord Chat - url: discord.gg/4qDjAmDj4P + url: https://chat.fakerjs.dev about: Ask questions and discuss with other users in real time. - name: Questions & Discussions url: https://github.com/faker-js/faker.js/discussions diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 0c25086badf..4634d41e93c 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -35,7 +35,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe ## Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by [contacting a Moderator or Maintainer via Discord](https://discord.com/invite/4qDjAmDj4P). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by [contacting a Moderator or Maintainer via Discord](https://chat.fakerjs.dev). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. diff --git a/README.md b/README.md index ff15636b802..18dfb366f71 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

Faker

Generate massive amounts of fake (but realistic) data for testing and development.

- [![Chat on Discord](https://img.shields.io/discord/929487054990110771)](https://discord.com/invite/4qDjAmDj4P) + [![Chat on Discord](https://img.shields.io/discord/929487054990110771)](https://chat.fakerjs.dev) [![Continuous Integration](https://github.com/faker-js/faker/actions/workflows/ci.yml/badge.svg)](https://github.com/faker-js/faker/actions/workflows/ci.yml) [![npm version](https://badgen.net/npm/v/@faker-js/faker)](https://www.npmjs.com/package/@faker-js/faker) [![npm downloads](https://badgen.net/npm/dm/@faker-js/faker)](https://www.npmjs.com/package/@faker-js/faker) diff --git a/docs/guide/index.md b/docs/guide/index.md index d377b20dd0c..def785f2e41 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -87,4 +87,4 @@ It is highly recommended to use version tags when importing libraries in Deno, e ## Community -If you have questions or need help, reach out to the community via [Discord](https://discord.com/invite/4qDjAmDj4P) and [GitHub Discussions](https://github.com/faker-js/faker/discussions). +If you have questions or need help, reach out to the community via [Discord](https://chat.fakerjs.dev) and [GitHub Discussions](https://github.com/faker-js/faker/discussions). diff --git a/docs/update.md b/docs/update.md index 2f11caa39b2..603879c0f7a 100644 --- a/docs/update.md +++ b/docs/update.md @@ -30,7 +30,7 @@ We're referring to it as the official library in the immediate term in order to ## (someone) is also working on a Faker library -Please send them to our [Discord](https://discord.gg/k4bPM5dzqC) and we can share ideas and collaborate. +Please send them to our [Discord](https://chat.fakerjs.dev) and we can share ideas and collaborate. ## Who are the current maintainers? diff --git a/netlify.toml b/netlify.toml index 5bc3b32d5dc..2fa705182e9 100644 --- a/netlify.toml +++ b/netlify.toml @@ -4,3 +4,8 @@ [build] publish = "docs/.vitepress/dist" command = "npx pnpm i --store=node_modules/.pnpm-store && npm run docs:build:ci" +[[redirects]] + from = "https://chat.fakerjs.dev" + to = "https://discord.com/invite/4qDjAmDj4P" + status = 301 + force = true