Skip to content

Commit b5dcf6a

Browse files
authored
Merge pull request #638 from projectfluent/typedoc-update
Update to typedoc 0.28 and use entryPointStrategy: packages
2 parents ca021ac + afbd420 commit b5dcf6a

Some content is hidden

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

49 files changed

+415
-240
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
- run: npm run build --workspaces
2222
- run: npm test
2323
- run: npm run lint
24-
- run: npm run docs --workspaces
24+
- run: npm run docs

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Build and test all packages at once:
8181
$ npm run build --workspaces
8282
$ npm run lint
8383
$ npm run test
84-
$ npm run docs --workspaces
84+
$ npm run docs
8585

8686
Each package may also be built separately by running `npm run build` in
8787
its directory.

fluent-bundle/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"scripts": {
4242
"build": "tsc",
4343
"postbuild": "rollup -c ../rollup.config.mjs",
44-
"docs": "typedoc --options ../typedoc.config.cjs",
4544
"test": "mocha 'test/*_test.js'"
4645
},
4746
"engines": {

fluent-bundle/src/builtins.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ const NUMBER_ALLOWED = [
5050
*
5151
* pi = The value of π is {NUMBER($pi, maximumFractionDigits: 2)}.
5252
*
53-
* The implementation expects an array of `FluentValues` representing the
54-
* positional arguments, and an object of named `FluentValues` representing the
53+
* The implementation expects an array of {@link FluentValue | FluentValues} representing the
54+
* positional arguments, and an object of named {@link FluentValue | FluentValues} representing the
5555
* named parameters.
5656
*
5757
* The following options are recognized:
@@ -121,8 +121,8 @@ const DATETIME_ALLOWED = [
121121
*
122122
* now = It's {DATETIME($today, month: "long")}.
123123
*
124-
* The implementation expects an array of `FluentValues` representing the
125-
* positional arguments, and an object of named `FluentValues` representing the
124+
* The implementation expects an array of {@link FluentValue | FluentValues} representing the
125+
* positional arguments, and an object of named {@link FluentValue | FluentValues} representing the
126126
* named parameters.
127127
*
128128
* The following options are recognized:

fluent-bundle/src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/**
2-
* @module fluent
3-
* @overview
4-
*
5-
* `fluent` is a JavaScript implementation of Project Fluent, a localization
2+
* A JavaScript implementation of Project Fluent, a localization
63
* framework designed to unleash the expressive power of the natural language.
74
*
5+
* @module
86
*/
97

108
export type { Message } from "./ast.js";

fluent-bundle/src/resolver.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
/* global Intl */
2-
31
/**
4-
* @overview
5-
*
62
* The role of the Fluent resolver is to format a `Pattern` to an instance of
73
* `FluentValue`. For performance reasons, primitive strings are considered
84
* such instances, too.

fluent-bundle/src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export abstract class FluentType<T> {
6363
}
6464

6565
/**
66-
* A `FluentType` representing no correct value.
66+
* A {@link FluentType} representing no correct value.
6767
*/
6868
export class FluentNone extends FluentType<string> {
6969
/**
@@ -83,7 +83,7 @@ export class FluentNone extends FluentType<string> {
8383
}
8484

8585
/**
86-
* A `FluentType` representing a number.
86+
* A {@link FluentType} representing a number.
8787
*
8888
* A `FluentNumber` instance stores the number value of the number it
8989
* represents. It may also store an option bag of options which will be passed
@@ -120,7 +120,7 @@ export class FluentNumber extends FluentType<number> {
120120
}
121121

122122
/**
123-
* A `FluentType` representing a date and time.
123+
* A {@link FluentType} representing a date and time.
124124
*
125125
* A `FluentDateTime` instance stores a Date object, Temporal object, or a number
126126
* as a numerical timestamp in milliseconds. It may also store an

fluent-bundle/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../tsconfig.json",
2+
"extends": "../tsconfig.base.json",
33
"compilerOptions": {
44
"outDir": "./esm",
55
"rootDir": "./src"

fluent-bundle/typedoc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"intentionallyNotExported": ["Pattern", "TemporalObject"]
3+
}

fluent-dedent/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"scripts": {
2727
"build": "tsc",
2828
"postbuild": "rollup -c ../rollup.config.mjs",
29-
"docs": "typedoc --options ../typedoc.config.cjs",
3029
"test": "mocha 'test/*_test.js'"
3130
},
3231
"engines": {

fluent-dedent/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../tsconfig.json",
2+
"extends": "../tsconfig.base.json",
33
"compilerOptions": {
44
"outDir": "./esm"
55
},

fluent-dom/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"scripts": {
3737
"build": "tsc",
3838
"postbuild": "rollup -c ../rollup.config.mjs --globals cached-iterable:CachedIterable",
39-
"docs": "typedoc --options ../typedoc.config.cjs src/index.js",
4039
"test": "c8 mocha -ui tdd --require ./test/index.js 'test/*_test.js'"
4140
},
4241
"engines": {

fluent-dom/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../tsconfig.json",
2+
"extends": "../tsconfig.base.json",
33
"compilerOptions": {
44
"allowJs": true,
55
"outDir": "./esm"

fluent-dom/typedoc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"entryPoints": ["src/index.js"]
3+
}

fluent-langneg/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"scripts": {
3535
"build": "tsc",
3636
"postbuild": "rollup -c ../rollup.config.mjs",
37-
"docs": "typedoc --options ../typedoc.config.cjs",
3837
"test": "mocha 'test/*_test.js'"
3938
},
4039
"engines": {

fluent-langneg/src/index.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
/*
2-
* @module fluent-langneg
3-
* @overview
4-
*
5-
* `fluent-langneg` provides language negotiation API that fits into
1+
/**
2+
* A language negotiation API that fits into the
63
* Project Fluent localization composition and fallbacking strategy.
74
*
5+
* @module
86
*/
97

10-
export {
11-
negotiateLanguages,
12-
NegotiateLanguagesOptions,
13-
} from "./negotiate_languages.js";
8+
export { negotiateLanguages } from "./negotiate_languages.js";
149
export { acceptedLanguages } from "./accepted_languages.js";
1510
export { filterMatches } from "./matches.js";

fluent-langneg/src/locale.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint no-magic-numbers: 0 */
2-
31
const languageCodeRe = "([a-z]{2,3}|\\*)";
42
const scriptCodeRe = "(?:-([a-z]{4}|\\*))";
53
const regionCodeRe = "(?:-([a-z]{2}|\\*))";

fluent-langneg/src/matches.ts

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint no-magic-numbers: 0 */
2-
31
import { Locale } from "./locale.js";
42

53
/**
@@ -9,68 +7,68 @@ import { Locale } from "./locale.js";
97
* The algorithm is based on the BCP4647 3.3.2 Extended Filtering algorithm,
108
* with several modifications:
119
*
12-
* 1) available locales are treated as ranges
10+
* ### 1. Available locales are treated as ranges
1311
*
14-
* This change allows us to match a more specific request against
15-
* more generic available locale.
12+
* This change allows us to match a more specific request against
13+
* more generic available locale.
1614
*
17-
* For example, if the available locale list provides locale `en`,
18-
* and the requested locale is `en-US`, we treat the available locale as
19-
* a locale that matches all possible english requests.
15+
* For example, if the available locale list provides locale `en`,
16+
* and the requested locale is `en-US`, we treat the available locale as
17+
* a locale that matches all possible english requests.
2018
*
21-
* This means that we expect available locale ID to be as precize as
22-
* the matches they want to cover.
19+
* This means that we expect available locale ID to be as precize as
20+
* the matches they want to cover.
2321
*
24-
* For example, if there is only `sr` available, it's ok to list
25-
* it in available locales. But once the available locales has both,
26-
* Cyrl and Latn variants, the locale IDs should be `sr-Cyrl` and `sr-Latn`
27-
* to avoid any `sr-*` request to match against whole `sr` range.
22+
* For example, if there is only `sr` available, it's ok to list
23+
* it in available locales. But once the available locales has both,
24+
* Cyrl and Latn variants, the locale IDs should be `sr-Cyrl` and `sr-Latn`
25+
* to avoid any `sr-*` request to match against whole `sr` range.
2826
*
29-
* What it does ([requested] * [available] = [supported]):
27+
* What it does ([requested] * [available] = [supported]):
3028
*
31-
* ['en-US'] * ['en'] = ['en']
29+
* ['en-US'] * ['en'] = ['en']
3230
*
33-
* 2) likely subtags from LDML 4.3 Likely Subtags has been added
31+
* ### 2. Likely subtags from LDML 4.3 Likely Subtags has been added
3432
*
35-
* The most obvious likely subtag that can be computed is a duplication
36-
* of the language field onto region field (`fr` => `fr-FR`).
33+
* The most obvious likely subtag that can be computed is a duplication
34+
* of the language field onto region field (`fr` => `fr-FR`).
3735
*
38-
* On top of that, likely subtags may use a list of mappings, that
39-
* allow the algorithm to handle non-obvious matches.
40-
* For example, making sure that we match `en` to `en-US` or `sr` to
41-
* `sr-Cyrl`, while `sr-RU` to `sr-Latn-RU`.
36+
* On top of that, likely subtags may use a list of mappings, that
37+
* allow the algorithm to handle non-obvious matches.
38+
* For example, making sure that we match `en` to `en-US` or `sr` to
39+
* `sr-Cyrl`, while `sr-RU` to `sr-Latn-RU`.
4240
*
43-
* This list can be taken directly from CLDR Supplemental Data.
41+
* This list can be taken directly from CLDR Supplemental Data.
4442
*
45-
* What it does ([requested] * [available] = [supported]):
43+
* What it does ([requested] * [available] = [supported]):
4644
*
47-
* ['fr'] * ['fr-FR'] = ['fr-FR']
48-
* ['en'] * ['en-US'] = ['en-US']
49-
* ['sr'] * ['sr-Latn', 'sr-Cyrl'] = ['sr-Cyrl']
45+
* ['fr'] * ['fr-FR'] = ['fr-FR']
46+
* ['en'] * ['en-US'] = ['en-US']
47+
* ['sr'] * ['sr-Latn', 'sr-Cyrl'] = ['sr-Cyrl']
5048
*
51-
* 3) variant/region range check has been added
49+
* ### 3. Variant/region range check has been added
5250
*
53-
* Lastly, the last form of check is against the requested locale ID
54-
* but with the variant/region field replaced with a `*` range.
51+
* Lastly, the last form of check is against the requested locale ID
52+
* but with the variant/region field replaced with a `*` range.
5553
*
56-
* The rationale here laid out in LDML 4.4 Language Matching:
57-
* "(...) normally the fall-off between the user's languages is
58-
* substantially greated than regional variants."
54+
* The rationale here laid out in LDML 4.4 Language Matching:
55+
* "(...) normally the fall-off between the user's languages is
56+
* substantially greated than regional variants."
5957
*
60-
* In other words, if we can't match for the given region, maybe
61-
* we can match for the same language/script but other region, and
62-
* it will in most cases be preferred over falling back on the next
63-
* language.
58+
* In other words, if we can't match for the given region, maybe
59+
* we can match for the same language/script but other region, and
60+
* it will in most cases be preferred over falling back on the next
61+
* language.
6462
*
65-
* What it does ([requested] * [available] = [supported]):
63+
* What it does ([requested] * [available] = [supported]):
6664
*
67-
* ['en-AU'] * ['en-US'] = ['en-US']
68-
* ['sr-RU'] * ['sr-Latn-RO'] = ['sr-Latn-RO'] // sr-RU -> sr-Latn-RU
65+
* ['en-AU'] * ['en-US'] = ['en-US']
66+
* ['sr-RU'] * ['sr-Latn-RO'] = ['sr-Latn-RO'] // sr-RU -> sr-Latn-RU
6967
*
70-
* It works similarly to getParentLocales algo, except that we stop
71-
* after matching against variant/region ranges and don't try to match
72-
* ignoring script ranges. That means that `sr-Cyrl` will never match
73-
* against `sr-Latn`.
68+
* It works similarly to getParentLocales algo, except that we stop
69+
* after matching against variant/region ranges and don't try to match
70+
* ignoring script ranges. That means that `sr-Cyrl` will never match
71+
* against `sr-Latn`.
7472
*/
7573
export function filterMatches(
7674
requestedLocales: Array<string>,

fluent-langneg/src/negotiate_languages.ts

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,57 @@
11
import { filterMatches } from "./matches.js";
22

3-
export interface NegotiateLanguagesOptions {
4-
strategy?: "filtering" | "matching" | "lookup";
5-
defaultLocale?: string;
6-
}
7-
83
/**
94
* Negotiates the languages between the list of requested locales against
105
* a list of available locales.
116
*
127
* It accepts three arguments:
138
*
14-
* requestedLocales:
15-
* an Array of strings with BCP47 locale IDs sorted
16-
* according to user preferences.
9+
* - `requestedLocales`:
10+
* an Array of strings with BCP47 locale IDs sorted
11+
* according to user preferences.
1712
*
18-
* availableLocales:
19-
* an Array of strings with BCP47 locale IDs of locale for which
20-
* resources are available. Unsorted.
13+
* - `availableLocales`:
14+
* an Array of strings with BCP47 locale IDs of locale for which
15+
* resources are available. Unsorted.
2116
*
22-
* options:
23-
* An object with the following, optional keys:
17+
* - `options`:
18+
* An object with the following, optional keys:
2419
*
25-
* strategy: 'filtering' (default) | 'matching' | 'lookup'
20+
* - `strategy`: `'filtering'` (default) | `'matching'` | `'lookup'`
2621
*
27-
* defaultLocale:
28-
* a string with BCP47 locale ID to be used
29-
* as a last resort locale.
22+
* - `defaultLocale`:
23+
* a string with BCP47 locale ID to be used
24+
* as a last resort locale.
3025
*
3126
*
3227
* It returns an Array of strings with BCP47 locale IDs sorted according to the
3328
* user preferences.
3429
*
3530
* The exact list will be selected differently depending on the strategy:
3631
*
37-
* 'filtering': (default)
38-
* In the filtering strategy, the algorithm will attempt to match
39-
* as many keys in the available locales in order of the requested locales.
32+
* - `'filtering'`: (default)<br>
33+
* In the filtering strategy, the algorithm will attempt to match
34+
* as many keys in the available locales in order of the requested locales.
4035
*
41-
* 'matching':
42-
* In the matching strategy, the algorithm will attempt to find the
43-
* best possible match for each element of the requestedLocales list.
36+
* - `'matching'`:<br>
37+
* In the matching strategy, the algorithm will attempt to find the
38+
* best possible match for each element of the requestedLocales list.
4439
*
45-
* 'lookup':
46-
* In the lookup strategy, the algorithm will attempt to find a single
47-
* best available locale based on the requested locales list.
40+
* - `'lookup'`:<br>
41+
* In the lookup strategy, the algorithm will attempt to find a single
42+
* best available locale based on the requested locales list.
4843
*
49-
* This strategy requires defaultLocale option to be set.
44+
* This strategy requires defaultLocale option to be set.
5045
*/
5146
export function negotiateLanguages(
5247
requestedLocales: Readonly<Array<string>>,
5348
availableLocales: Readonly<Array<string>>,
54-
{ strategy = "filtering", defaultLocale }: NegotiateLanguagesOptions = {}
49+
options?: {
50+
strategy?: "filtering" | "matching" | "lookup";
51+
defaultLocale?: string;
52+
}
5553
): Array<string> {
54+
const { strategy = "filtering", defaultLocale } = options ?? {};
5655
const supportedLocales = filterMatches(
5756
Array.from(requestedLocales ?? []).map(String),
5857
Array.from(availableLocales ?? []).map(String),

fluent-langneg/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../tsconfig.json",
2+
"extends": "../tsconfig.base.json",
33
"compilerOptions": {
44
"outDir": "./esm"
55
},

fluent-react/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"scripts": {
4444
"build": "tsc -p ./tsconfig.build.json",
4545
"postbuild": "rollup -c ../rollup.config.mjs --globals @fluent/sequence:FluentSequence,cached-iterable:CachedIterable,react:React",
46-
"docs": "typedoc --options ../typedoc.config.cjs --tsconfig ./tsconfig.build.json",
4746
"test": "jest --collect-coverage"
4847
},
4948
"engines": {

0 commit comments

Comments
 (0)