Skip to content

Commit 35d1306

Browse files
committed
Merge branch 'next' into locale/introduce-metadata
2 parents df2df9f + 3562e87 commit 35d1306

130 files changed

Lines changed: 557 additions & 118 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ trim_trailing_whitespace = true
99
insert_final_newline = true
1010

1111
[*.md]
12-
max_line_length = off
1312
trim_trailing_whitespace = false

docs/api/ApiIndex.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ onUnmounted(() => window.removeEventListener('keydown', apiSearchFocusHandler));
9696
<h2 :id="slugify(section.text)">{{ section.text }}</h2>
9797
<div class="api-groups">
9898
<div v-for="item of section.items" :key="item.text" class="api-group">
99-
<h3>{{ item.text }}</h3>
99+
<h3>
100+
<a :href="item.link + '.html'">{{ item.text }}</a>
101+
</h3>
100102
<ul>
101103
<li v-for="h of item.headers" :key="h.anchor">
102104
<a :href="item.link + '.html#' + slugify(h.anchor)">{{
@@ -158,19 +160,19 @@ h3 {
158160
margin-bottom: 64px;
159161
}
160162
161-
.api-groups a {
163+
.api-groups ul a {
162164
font-size: 15px;
163165
font-weight: 500;
164166
line-height: 2;
165167
color: var(--vp-c-text-code);
166168
transition: color 0.5s;
167169
}
168170
169-
.dark .api-groups a {
171+
.dark .api-groups ul a {
170172
font-weight: 400;
171173
}
172174
173-
.api-groups a:hover {
175+
.api-groups ul a:hover {
174176
color: var(--vp-c-green);
175177
transition: none;
176178
}
@@ -233,7 +235,7 @@ h3 {
233235
padding-top: 32px;
234236
}
235237
236-
.api-groups a {
238+
.api-groups ul a {
237239
font-size: 14px;
238240
}
239241

docs/guide/localization.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ If our built-in faker instances don't satisfy your needs, you can build your own
4444

4545
```ts
4646
import type { LocaleDefinition } from '@faker-js/faker';
47-
import { Faker, de_CH, de, en } from '@faker-js/faker';
47+
import { Faker, de_CH, de, en, base } from '@faker-js/faker';
4848

4949
const customLocale: LocaleDefinition = {
5050
title: 'My custom locale',
@@ -54,10 +54,18 @@ const customLocale: LocaleDefinition = {
5454
};
5555

5656
export const customFaker = new Faker({
57-
locale: [customLocale, de_CH, de, en, global],
57+
locale: [customLocale, de_CH, de, en, base],
5858
});
5959
```
6060

61+
In this example there are 5 locales. Each of these is checked in order, and the first locale which contains the requested data will be used:
62+
63+
- `customLocale` is your custom locale definition which will override all other fallback definitions.
64+
- `de_CH` is a specific locale definition that overrides some German definitions with `CH` (Switzerland) data.
65+
- `de` is a generic `de` (German) locale definition.
66+
- `en` is a generic `en` (English) locale definition. This is our most complete locale, so we add it to fill some gaps. Depending on your needs, you might want or not want to have it as a fallback.
67+
- `base` is the base locale definition which contains definitions that can be used in every language (e.g. emojis).
68+
6169
## Available locales
6270

6371
<!-- LOCALES-AUTO-GENERATED-START -->
@@ -69,6 +77,7 @@ export const customFaker = new Faker({
6977
| `af_ZA` | Afrikaans | `fakerAF_ZA` |
7078
| `ar` | Arabic | `fakerAR` |
7179
| `az` | Azerbaijani | `fakerAZ` |
80+
| `base` | Base | `fakerBASE` |
7281
| `cz` | Czech | `fakerCZ` |
7382
| `de` | German | `fakerDE` |
7483
| `de_AT` | German (Austria) | `fakerDE_AT` |

docs/guide/upgrading.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ const b = customFaker.internet.emoji();
6060
**New**
6161

6262
```ts
63-
import { Faker, de_CH, de, en, global } from '@faker-js/faker';
63+
import { Faker, de_CH, de, en, base } from '@faker-js/faker';
6464

6565
// same as fakerDE_CH
6666
export const customFaker = new Faker({
6767
// Now multiple fallbacks are supported
68-
locale: [de_CH, de, en, global],
68+
locale: [de_CH, de, en, base],
6969
});
7070
const a = customFaker.internet.email();
7171
const b = customFaker.internet.emoji();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"glob": "~9.3.2",
113113
"npm-run-all": "~4.1.5",
114114
"picocolors": "~1.0.0",
115-
"prettier": "2.8.4",
115+
"prettier": "2.8.7",
116116
"prettier-plugin-organize-imports": "~3.2.2",
117117
"react": "~18.2.0",
118118
"react-dom": "~18.2.0",

pnpm-lock.yaml

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/apidoc/moduleMethods.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { DeclarationReflection, ProjectReflection } from 'typedoc';
22
import type { Method } from '../../docs/.vitepress/components/api-docs/method';
33
import { writeApiDocsData, writeApiDocsModulePage } from './apiDocsWriter';
4-
import { analyzeSignature, toBlock } from './signature';
4+
import { analyzeSignature, stripAbsoluteFakerUrls, toBlock } from './signature';
55
import {
66
extractModuleFieldName,
77
extractModuleName,
@@ -40,7 +40,7 @@ function processModuleMethod(module: DeclarationReflection): PageAndDiffIndex {
4040
const moduleName = extractModuleName(module);
4141
const moduleFieldName = extractModuleFieldName(module);
4242
console.log(`Processing Module ${moduleName}`);
43-
const comment = toBlock(module.comment);
43+
const comment = stripAbsoluteFakerUrls(toBlock(module.comment));
4444

4545
const methods: Method[] = [];
4646

scripts/apidoc/signature.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ export function toBlock(comment?: Comment): string {
4444
return joinTagParts(comment?.summary) || 'Missing';
4545
}
4646

47+
export function stripAbsoluteFakerUrls(markdown: string): string {
48+
return markdown.replace(/https:\/\/(next.)?fakerjs.dev\//g, '/');
49+
}
50+
4751
let markdown: MarkdownRenderer;
4852

4953
export async function initMarkdownRenderer(): Promise<void> {

scripts/generateLocales.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,15 @@ function generateLocaleFile(locale: string): void {
126126
}
127127
}
128128

129-
if (locales[locales.length - 1] !== 'en') {
129+
// TODO christopher 2023-03-07: Remove 'en' fallback in a separate PR
130+
if (locales[locales.length - 1] !== 'en' && locale !== 'base') {
130131
locales.push('en');
131132
}
132133

134+
if (locales[locales.length - 1] !== 'base') {
135+
locales.push('base');
136+
}
137+
133138
let content = `
134139
${autoGeneratedCommentHeader}
135140

src/definitions/location.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ export type LocationDefinitions = LocaleEntry<{
4545
country_code: Array<{ alpha2: string; alpha3: string }>;
4646

4747
/**
48-
* The names of this country's states.
48+
* The names of this country's states, or other first-level administrative areas.
4949
*/
5050
state: string[];
5151

5252
/**
53-
* The abbreviated names of this country's states.
53+
* The abbreviated names of this country's states, or other first-level administrative areas.
5454
*/
5555
state_abbr: string[];
5656

5757
/**
58-
* The names of counties inside the country or state.
58+
* The names of counties, or other second-level administrative areas, inside the country's states.
5959
*/
6060
county: string[];
6161

0 commit comments

Comments
 (0)