aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2022-01-27 18:13:29 +0100
committerGitHub <[email protected]>2022-01-27 12:13:29 -0500
commit35de92ffaff2261eae29422474afd4ca674ab473 (patch)
treedbc38e3abe4b7ea812292165f62e96b1814a437a
parent3242dfc4b2f566931c3687173f6361a6384b6247 (diff)
downloadfaker-35de92ffaff2261eae29422474afd4ca674ab473.tar.xz
faker-35de92ffaff2261eae29422474afd4ca674ab473.zip
docs: automatically generate api docs from source (#289)
Co-authored-by: Shinigami <[email protected]>
-rw-r--r--.gitignore1
-rw-r--r--docs/.vitepress/.gitignore1
-rw-r--r--docs/.vitepress/config.mjs57
-rw-r--r--docs/api/.gitignore3
-rw-r--r--docs/api/address.md181
-rw-r--r--docs/api/commerce.md62
-rw-r--r--docs/api/company.md106
-rw-r--r--docs/api/database.md35
-rw-r--r--docs/api/datatype.md125
-rw-r--r--docs/api/date.md129
-rw-r--r--docs/api/finance.md167
-rw-r--r--docs/api/hacker.md51
-rw-r--r--docs/api/helpers.md262
-rw-r--r--docs/api/image.md318
-rw-r--r--docs/api/internet.md186
-rw-r--r--package.json10
-rw-r--r--pnpm-lock.yaml83
-rw-r--r--scripts/apidoc.ts244
18 files changed, 333 insertions, 1688 deletions
diff --git a/.gitignore b/.gitignore
index a7b1de8c..8acf826f 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 00000000..1af560a8
--- /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 fe5370c3..d35171bb 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 00000000..73d5e086
--- /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 421aad7e..00000000
--- 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 <Badge text="5.0.0+" type="tip" vertical="middle"/>
-| 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 <Badge text="5.0.0+" type="tip" vertical="middle"/>
-| 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 <Badge text="5.0.0+" type="tip" vertical="middle"/>
-
-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 a7809709..00000000
--- 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 c2919d6f..00000000
--- 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 c9be1533..00000000
--- 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 35a25716..00000000
--- a/docs/api/datatype.md
+++ /dev/null
@@ -1,125 +0,0 @@
-# Data Type <Badge text="5.5.0+" type="tip" vertical="middle"/>
-
-[[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 359a7744..00000000
--- 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 | <Badge text="N/A" type="error" vertical="middle"/> |
-| to | Date | <Badge text="N/A" type="error" vertical="middle"/> |
-:::
-
-```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 <Badge text="5.0.0+" type="tip" vertical="middle"/>
-
-Returns some date recent date
-
-::: tip
-| Param | Type | Default |
-| ------- | ------- | :----------: |
-| days | number | `1` |
-| refDate | Date | `new Date()` |
-:::
-
-```js
-faker.date.recent();
-```
-
-## Soon <Badge text="5.0.0+" type="tip" vertical="middle"/>
-
-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 6035dbcc..00000000
--- 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 <Badge text="5.0.0+" type="tip" vertical="middle"/>
-
-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 <Badge text="5.0.0+" type="tip" vertical="middle"/>
-
-Return random credit card number
-
-::: tip
-| Param | Type | Default |
-| -------- | ------ | :-----: |
-| provider | string | `''` |
-:::
-
-```js
-faker.finance.creditCardNumber();
-```
-
-## Credit Card CVV <Badge text="5.0.0+" type="tip" vertical="middle"/>
-
-Return random credit card CVV
-
-```js
-faker.finance.creditCardCVV();
-```
-
-## Bitcoin Address
-
-Return random bitcoin address
-
-```js
-faker.finance.bitcoinAddress(); // 3FINQD7C6JW7XPF4NMNHOJYAXLKLP
-```
-
-## Ethereum Address <Badge text="5.0.0+" type="tip" vertical="middle"/>
-
-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 d692d4ae..00000000
--- 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 7a2db0d2..00000000
--- 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'); // [email protected]
-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": "[email protected]",
- "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": "[email protected]",
- "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": "[email protected]",
- "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 1556ab34..00000000
--- 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 3053881e..00000000
--- 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 <Badge type="tip" vertical="middle" text="Recommended" />
-
-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(); // [email protected]
-faker.internet.exampleEmail('bob'); // [email protected]
-faker.internet.exampleEmail('bob', 'jon'); // [email protected]
-```
-
-## E-mail <Badge type="danger" vertical="middle" text="Not recommended" />
-
-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(); // [email protected]
-faker.internet.email('bob'); // [email protected]
-faker.internet.email('bob', 'jon'); // [email protected]
-faker.internet.email('bob', 'jon', 'somedomain.com'); // [email protected]
-```
-
-## 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 6bf7453f..8914cdb7 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 c003143b..3d88d331 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-plugin-missing-exports: [email protected]
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/[email protected]:
+ resolution: {integrity: sha512-1uguGQqa+c5f33nWS3v1mm0uAx4Ii1lw4Kx2zQksmYFKNEWTmrmMXbMNBoBg4wu0p4dFCNC7JIWPoRzpNS6pFA==}
+ peerDependencies:
+ typedoc: 0.22.x
+ dependencies:
+ dev: true
+
+ /typedoc/[email protected]:
+ 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 00000000..956e53e6
--- /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, '\\<').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,}/, '<br />')
+ .replace(/\n/, '') +
+ '|\n'
+ );
+}
+
+async function build(): Promise<void> {
+ 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}
+
+ <!-- This file is automatically generated. -->
+ <!-- Run '${scriptCommand}' to update -->
+
+ [[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);