diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ae0667c5..22ed61cb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,4 +21,4 @@ jobs: - run: npm run build --workspaces - run: npm test - run: npm run lint - - run: npm run docs --workspaces + - run: npm run docs diff --git a/README.md b/README.md index 7da366ed..bdcee419 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Build and test all packages at once: $ npm run build --workspaces $ npm run lint $ npm run test - $ npm run docs --workspaces + $ npm run docs Each package may also be built separately by running `npm run build` in its directory. diff --git a/fluent-bundle/package.json b/fluent-bundle/package.json index 6fcdf02d..69592527 100644 --- a/fluent-bundle/package.json +++ b/fluent-bundle/package.json @@ -41,7 +41,6 @@ "scripts": { "build": "tsc", "postbuild": "rollup -c ../rollup.config.mjs", - "docs": "typedoc --options ../typedoc.config.cjs", "test": "mocha 'test/*_test.js'" }, "engines": { diff --git a/fluent-bundle/src/builtins.ts b/fluent-bundle/src/builtins.ts index 10de6588..2862616c 100644 --- a/fluent-bundle/src/builtins.ts +++ b/fluent-bundle/src/builtins.ts @@ -50,8 +50,8 @@ const NUMBER_ALLOWED = [ * * pi = The value of π is {NUMBER($pi, maximumFractionDigits: 2)}. * - * The implementation expects an array of `FluentValues` representing the - * positional arguments, and an object of named `FluentValues` representing the + * The implementation expects an array of {@link FluentValue | FluentValues} representing the + * positional arguments, and an object of named {@link FluentValue | FluentValues} representing the * named parameters. * * The following options are recognized: @@ -121,8 +121,8 @@ const DATETIME_ALLOWED = [ * * now = It's {DATETIME($today, month: "long")}. * - * The implementation expects an array of `FluentValues` representing the - * positional arguments, and an object of named `FluentValues` representing the + * The implementation expects an array of {@link FluentValue | FluentValues} representing the + * positional arguments, and an object of named {@link FluentValue | FluentValues} representing the * named parameters. * * The following options are recognized: diff --git a/fluent-bundle/src/index.ts b/fluent-bundle/src/index.ts index 369c4c96..0470f9e5 100644 --- a/fluent-bundle/src/index.ts +++ b/fluent-bundle/src/index.ts @@ -1,10 +1,8 @@ /** - * @module fluent - * @overview - * - * `fluent` is a JavaScript implementation of Project Fluent, a localization + * A JavaScript implementation of Project Fluent, a localization * framework designed to unleash the expressive power of the natural language. * + * @module */ export type { Message } from "./ast.js"; diff --git a/fluent-bundle/src/resolver.ts b/fluent-bundle/src/resolver.ts index 0779f7f2..5d13ef95 100644 --- a/fluent-bundle/src/resolver.ts +++ b/fluent-bundle/src/resolver.ts @@ -1,8 +1,4 @@ -/* global Intl */ - /** - * @overview - * * The role of the Fluent resolver is to format a `Pattern` to an instance of * `FluentValue`. For performance reasons, primitive strings are considered * such instances, too. diff --git a/fluent-bundle/src/types.ts b/fluent-bundle/src/types.ts index 1d27f186..a78fa9c1 100644 --- a/fluent-bundle/src/types.ts +++ b/fluent-bundle/src/types.ts @@ -63,7 +63,7 @@ export abstract class FluentType { } /** - * A `FluentType` representing no correct value. + * A {@link FluentType} representing no correct value. */ export class FluentNone extends FluentType { /** @@ -83,7 +83,7 @@ export class FluentNone extends FluentType { } /** - * A `FluentType` representing a number. + * A {@link FluentType} representing a number. * * A `FluentNumber` instance stores the number value of the number it * represents. It may also store an option bag of options which will be passed @@ -120,7 +120,7 @@ export class FluentNumber extends FluentType { } /** - * A `FluentType` representing a date and time. + * A {@link FluentType} representing a date and time. * * A `FluentDateTime` instance stores a Date object, Temporal object, or a number * as a numerical timestamp in milliseconds. It may also store an diff --git a/fluent-bundle/tsconfig.json b/fluent-bundle/tsconfig.json index 9ea82c48..1a76d9a4 100644 --- a/fluent-bundle/tsconfig.json +++ b/fluent-bundle/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig.json", + "extends": "../tsconfig.base.json", "compilerOptions": { "outDir": "./esm", "rootDir": "./src" diff --git a/fluent-bundle/typedoc.json b/fluent-bundle/typedoc.json new file mode 100644 index 00000000..01e584fb --- /dev/null +++ b/fluent-bundle/typedoc.json @@ -0,0 +1,3 @@ +{ + "intentionallyNotExported": ["Pattern", "TemporalObject"] +} diff --git a/fluent-dedent/package.json b/fluent-dedent/package.json index ebf8151b..978c9c01 100644 --- a/fluent-dedent/package.json +++ b/fluent-dedent/package.json @@ -26,7 +26,6 @@ "scripts": { "build": "tsc", "postbuild": "rollup -c ../rollup.config.mjs", - "docs": "typedoc --options ../typedoc.config.cjs", "test": "mocha 'test/*_test.js'" }, "engines": { diff --git a/fluent-dedent/tsconfig.json b/fluent-dedent/tsconfig.json index 5a446b00..1c550163 100644 --- a/fluent-dedent/tsconfig.json +++ b/fluent-dedent/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig.json", + "extends": "../tsconfig.base.json", "compilerOptions": { "outDir": "./esm" }, diff --git a/fluent-dom/package.json b/fluent-dom/package.json index b8709228..f0e35ada 100644 --- a/fluent-dom/package.json +++ b/fluent-dom/package.json @@ -36,7 +36,6 @@ "scripts": { "build": "tsc", "postbuild": "rollup -c ../rollup.config.mjs --globals cached-iterable:CachedIterable", - "docs": "typedoc --options ../typedoc.config.cjs src/index.js", "test": "c8 mocha -ui tdd --require ./test/index.js 'test/*_test.js'" }, "engines": { diff --git a/fluent-dom/tsconfig.json b/fluent-dom/tsconfig.json index 99e6e8ad..0225d671 100644 --- a/fluent-dom/tsconfig.json +++ b/fluent-dom/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig.json", + "extends": "../tsconfig.base.json", "compilerOptions": { "allowJs": true, "outDir": "./esm" diff --git a/fluent-dom/typedoc.json b/fluent-dom/typedoc.json new file mode 100644 index 00000000..75dac08a --- /dev/null +++ b/fluent-dom/typedoc.json @@ -0,0 +1,3 @@ +{ + "entryPoints": ["src/index.js"] +} diff --git a/fluent-langneg/package.json b/fluent-langneg/package.json index d46d9322..6d2c01dc 100644 --- a/fluent-langneg/package.json +++ b/fluent-langneg/package.json @@ -34,7 +34,6 @@ "scripts": { "build": "tsc", "postbuild": "rollup -c ../rollup.config.mjs", - "docs": "typedoc --options ../typedoc.config.cjs", "test": "mocha 'test/*_test.js'" }, "engines": { diff --git a/fluent-langneg/src/index.ts b/fluent-langneg/src/index.ts index 294c4aa8..d586d02d 100644 --- a/fluent-langneg/src/index.ts +++ b/fluent-langneg/src/index.ts @@ -1,15 +1,10 @@ -/* - * @module fluent-langneg - * @overview - * - * `fluent-langneg` provides language negotiation API that fits into +/** + * A language negotiation API that fits into the * Project Fluent localization composition and fallbacking strategy. * + * @module */ -export { - negotiateLanguages, - NegotiateLanguagesOptions, -} from "./negotiate_languages.js"; +export { negotiateLanguages } from "./negotiate_languages.js"; export { acceptedLanguages } from "./accepted_languages.js"; export { filterMatches } from "./matches.js"; diff --git a/fluent-langneg/src/locale.ts b/fluent-langneg/src/locale.ts index 6b8fef80..d4a96822 100644 --- a/fluent-langneg/src/locale.ts +++ b/fluent-langneg/src/locale.ts @@ -1,5 +1,3 @@ -/* eslint no-magic-numbers: 0 */ - const languageCodeRe = "([a-z]{2,3}|\\*)"; const scriptCodeRe = "(?:-([a-z]{4}|\\*))"; const regionCodeRe = "(?:-([a-z]{2}|\\*))"; diff --git a/fluent-langneg/src/matches.ts b/fluent-langneg/src/matches.ts index 7cfbfceb..213001de 100644 --- a/fluent-langneg/src/matches.ts +++ b/fluent-langneg/src/matches.ts @@ -1,5 +1,3 @@ -/* eslint no-magic-numbers: 0 */ - import { Locale } from "./locale.js"; /** @@ -9,68 +7,68 @@ import { Locale } from "./locale.js"; * The algorithm is based on the BCP4647 3.3.2 Extended Filtering algorithm, * with several modifications: * - * 1) available locales are treated as ranges + * ### 1. Available locales are treated as ranges * - * This change allows us to match a more specific request against - * more generic available locale. + * This change allows us to match a more specific request against + * more generic available locale. * - * For example, if the available locale list provides locale `en`, - * and the requested locale is `en-US`, we treat the available locale as - * a locale that matches all possible english requests. + * For example, if the available locale list provides locale `en`, + * and the requested locale is `en-US`, we treat the available locale as + * a locale that matches all possible english requests. * - * This means that we expect available locale ID to be as precize as - * the matches they want to cover. + * This means that we expect available locale ID to be as precize as + * the matches they want to cover. * - * For example, if there is only `sr` available, it's ok to list - * it in available locales. But once the available locales has both, - * Cyrl and Latn variants, the locale IDs should be `sr-Cyrl` and `sr-Latn` - * to avoid any `sr-*` request to match against whole `sr` range. + * For example, if there is only `sr` available, it's ok to list + * it in available locales. But once the available locales has both, + * Cyrl and Latn variants, the locale IDs should be `sr-Cyrl` and `sr-Latn` + * to avoid any `sr-*` request to match against whole `sr` range. * - * What it does ([requested] * [available] = [supported]): + * What it does ([requested] * [available] = [supported]): * - * ['en-US'] * ['en'] = ['en'] + * ['en-US'] * ['en'] = ['en'] * - * 2) likely subtags from LDML 4.3 Likely Subtags has been added + * ### 2. Likely subtags from LDML 4.3 Likely Subtags has been added * - * The most obvious likely subtag that can be computed is a duplication - * of the language field onto region field (`fr` => `fr-FR`). + * The most obvious likely subtag that can be computed is a duplication + * of the language field onto region field (`fr` => `fr-FR`). * - * On top of that, likely subtags may use a list of mappings, that - * allow the algorithm to handle non-obvious matches. - * For example, making sure that we match `en` to `en-US` or `sr` to - * `sr-Cyrl`, while `sr-RU` to `sr-Latn-RU`. + * On top of that, likely subtags may use a list of mappings, that + * allow the algorithm to handle non-obvious matches. + * For example, making sure that we match `en` to `en-US` or `sr` to + * `sr-Cyrl`, while `sr-RU` to `sr-Latn-RU`. * - * This list can be taken directly from CLDR Supplemental Data. + * This list can be taken directly from CLDR Supplemental Data. * - * What it does ([requested] * [available] = [supported]): + * What it does ([requested] * [available] = [supported]): * - * ['fr'] * ['fr-FR'] = ['fr-FR'] - * ['en'] * ['en-US'] = ['en-US'] - * ['sr'] * ['sr-Latn', 'sr-Cyrl'] = ['sr-Cyrl'] + * ['fr'] * ['fr-FR'] = ['fr-FR'] + * ['en'] * ['en-US'] = ['en-US'] + * ['sr'] * ['sr-Latn', 'sr-Cyrl'] = ['sr-Cyrl'] * - * 3) variant/region range check has been added + * ### 3. Variant/region range check has been added * - * Lastly, the last form of check is against the requested locale ID - * but with the variant/region field replaced with a `*` range. + * Lastly, the last form of check is against the requested locale ID + * but with the variant/region field replaced with a `*` range. * - * The rationale here laid out in LDML 4.4 Language Matching: - * "(...) normally the fall-off between the user's languages is - * substantially greated than regional variants." + * The rationale here laid out in LDML 4.4 Language Matching: + * "(...) normally the fall-off between the user's languages is + * substantially greated than regional variants." * - * In other words, if we can't match for the given region, maybe - * we can match for the same language/script but other region, and - * it will in most cases be preferred over falling back on the next - * language. + * In other words, if we can't match for the given region, maybe + * we can match for the same language/script but other region, and + * it will in most cases be preferred over falling back on the next + * language. * - * What it does ([requested] * [available] = [supported]): + * What it does ([requested] * [available] = [supported]): * - * ['en-AU'] * ['en-US'] = ['en-US'] - * ['sr-RU'] * ['sr-Latn-RO'] = ['sr-Latn-RO'] // sr-RU -> sr-Latn-RU + * ['en-AU'] * ['en-US'] = ['en-US'] + * ['sr-RU'] * ['sr-Latn-RO'] = ['sr-Latn-RO'] // sr-RU -> sr-Latn-RU * - * It works similarly to getParentLocales algo, except that we stop - * after matching against variant/region ranges and don't try to match - * ignoring script ranges. That means that `sr-Cyrl` will never match - * against `sr-Latn`. + * It works similarly to getParentLocales algo, except that we stop + * after matching against variant/region ranges and don't try to match + * ignoring script ranges. That means that `sr-Cyrl` will never match + * against `sr-Latn`. */ export function filterMatches( requestedLocales: Array, diff --git a/fluent-langneg/src/negotiate_languages.ts b/fluent-langneg/src/negotiate_languages.ts index dcba7401..5405be43 100644 --- a/fluent-langneg/src/negotiate_languages.ts +++ b/fluent-langneg/src/negotiate_languages.ts @@ -1,32 +1,27 @@ import { filterMatches } from "./matches.js"; -export interface NegotiateLanguagesOptions { - strategy?: "filtering" | "matching" | "lookup"; - defaultLocale?: string; -} - /** * Negotiates the languages between the list of requested locales against * a list of available locales. * * It accepts three arguments: * - * requestedLocales: - * an Array of strings with BCP47 locale IDs sorted - * according to user preferences. + * - `requestedLocales`: + * an Array of strings with BCP47 locale IDs sorted + * according to user preferences. * - * availableLocales: - * an Array of strings with BCP47 locale IDs of locale for which - * resources are available. Unsorted. + * - `availableLocales`: + * an Array of strings with BCP47 locale IDs of locale for which + * resources are available. Unsorted. * - * options: - * An object with the following, optional keys: + * - `options`: + * An object with the following, optional keys: * - * strategy: 'filtering' (default) | 'matching' | 'lookup' + * - `strategy`: `'filtering'` (default) | `'matching'` | `'lookup'` * - * defaultLocale: - * a string with BCP47 locale ID to be used - * as a last resort locale. + * - `defaultLocale`: + * a string with BCP47 locale ID to be used + * as a last resort locale. * * * It returns an Array of strings with BCP47 locale IDs sorted according to the @@ -34,25 +29,29 @@ export interface NegotiateLanguagesOptions { * * The exact list will be selected differently depending on the strategy: * - * 'filtering': (default) - * In the filtering strategy, the algorithm will attempt to match - * as many keys in the available locales in order of the requested locales. + * - `'filtering'`: (default)
+ * In the filtering strategy, the algorithm will attempt to match + * as many keys in the available locales in order of the requested locales. * - * 'matching': - * In the matching strategy, the algorithm will attempt to find the - * best possible match for each element of the requestedLocales list. + * - `'matching'`:
+ * In the matching strategy, the algorithm will attempt to find the + * best possible match for each element of the requestedLocales list. * - * 'lookup': - * In the lookup strategy, the algorithm will attempt to find a single - * best available locale based on the requested locales list. + * - `'lookup'`:
+ * In the lookup strategy, the algorithm will attempt to find a single + * best available locale based on the requested locales list. * - * This strategy requires defaultLocale option to be set. + * This strategy requires defaultLocale option to be set. */ export function negotiateLanguages( requestedLocales: Readonly>, availableLocales: Readonly>, - { strategy = "filtering", defaultLocale }: NegotiateLanguagesOptions = {} + options?: { + strategy?: "filtering" | "matching" | "lookup"; + defaultLocale?: string; + } ): Array { + const { strategy = "filtering", defaultLocale } = options ?? {}; const supportedLocales = filterMatches( Array.from(requestedLocales ?? []).map(String), Array.from(availableLocales ?? []).map(String), diff --git a/fluent-langneg/tsconfig.json b/fluent-langneg/tsconfig.json index 5a446b00..1c550163 100644 --- a/fluent-langneg/tsconfig.json +++ b/fluent-langneg/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig.json", + "extends": "../tsconfig.base.json", "compilerOptions": { "outDir": "./esm" }, diff --git a/fluent-react/package.json b/fluent-react/package.json index 9bbdf7c9..6cade35f 100644 --- a/fluent-react/package.json +++ b/fluent-react/package.json @@ -43,7 +43,6 @@ "scripts": { "build": "tsc -p ./tsconfig.build.json", "postbuild": "rollup -c ../rollup.config.mjs --globals @fluent/sequence:FluentSequence,cached-iterable:CachedIterable,react:React", - "docs": "typedoc --options ../typedoc.config.cjs --tsconfig ./tsconfig.build.json", "test": "jest --collect-coverage" }, "engines": { diff --git a/fluent-react/src/index.ts b/fluent-react/src/index.ts index 242a6241..ccf11f45 100644 --- a/fluent-react/src/index.ts +++ b/fluent-react/src/index.ts @@ -1,13 +1,9 @@ /** - * @module fluent-react - * @overview + * React bindings for Fluent. + * Takes advantage of React's Components system and the virtual DOM. + * Translations are exposed to components via the provider pattern. * - - * `fluent-react` provides React bindings for Fluent. It takes advantage of - * React's Components system and the virtual DOM. Translations are exposed to - * components via the provider pattern. - * - * Consult the documentation of the `LocalizationProvider` and the `Localized` + * Consult the documentation of the {@link LocalizationProvider} and the {@link Localized} * components for more information. * * @example @@ -18,6 +14,8 @@ * * * ``` + * + * @module */ export { ReactLocalization } from "./localization.js"; diff --git a/fluent-react/src/localization.ts b/fluent-react/src/localization.ts index 4f444271..ce1d3d28 100644 --- a/fluent-react/src/localization.ts +++ b/fluent-react/src/localization.ts @@ -25,12 +25,12 @@ const defaultReportError = (error: Error): void => { * `ReactLocalization` handles translation formatting and fallback. * * The current negotiated fallback chain of languages is stored in the - * `ReactLocalization` instance in form of an iterable of `FluentBundle` + * `ReactLocalization` instance in form of an iterable of {@link FluentBundle} * instances. This iterable is used to find the best existing translation for * a given identifier. * - * The `ReactLocalization` class instances are exposed to `Localized` elements - * via the `LocalizationProvider` component. + * The `ReactLocalization` class instances are exposed to {@link Localized} elements + * via the {@link LocalizationProvider} component. */ export class ReactLocalization { public bundles: Iterable; diff --git a/fluent-react/src/provider.ts b/fluent-react/src/provider.ts index f725d467..5339cc32 100644 --- a/fluent-react/src/provider.ts +++ b/fluent-react/src/provider.ts @@ -3,15 +3,15 @@ import { FluentContext } from "./context.js"; import { ReactLocalization } from "./localization.js"; /** - * The Provider component for the `ReactLocalization` class. + * The Provider component for the {@link ReactLocalization} class. * - * Exposes a `ReactLocalization` instance to all descendants via React's + * Exposes a {@link ReactLocalization} instance to all descendants via React's * context feature. It makes translations available to all localizable * elements in the descendant's render tree without the need to pass them * explicitly. * - * `LocalizationProvider` takes an instance of `ReactLocalization` in the - * `l10n` prop. This instance will be made available to `Localized` components + * `LocalizationProvider` takes an instance of {@link ReactLocalization} in the + * `l10n` prop. This instance will be made available to {@link Localized} components * under the provider. * * @example diff --git a/fluent-react/src/use_localization.ts b/fluent-react/src/use_localization.ts index b02e305d..6eba87be 100644 --- a/fluent-react/src/use_localization.ts +++ b/fluent-react/src/use_localization.ts @@ -2,11 +2,7 @@ import { useContext } from "react"; import { FluentContext } from "./context.js"; import { ReactLocalization } from "./localization.js"; -/** - * The `useLocalization` hook returns the FluentContext - */ -type useLocalization = () => { l10n: ReactLocalization }; -export const useLocalization: useLocalization = () => { +export function useLocalization(): { l10n: ReactLocalization } { const l10n = useContext(FluentContext); if (!l10n) { @@ -17,4 +13,4 @@ export const useLocalization: useLocalization = () => { } return { l10n }; -}; +} diff --git a/fluent-react/src/with_localization.ts b/fluent-react/src/with_localization.ts index 4e8abba8..e8aabd69 100644 --- a/fluent-react/src/with_localization.ts +++ b/fluent-react/src/with_localization.ts @@ -10,13 +10,14 @@ export interface WithLocalizationProps { ): string; } -type WithoutLocalizationProps

= Omit & - Partial; - export function withLocalization

( Inner: ComponentType

-): ComponentType> { - function WithLocalization(props: WithoutLocalizationProps

): ReactElement { +): ComponentType< + Omit & Partial +> { + function WithLocalization( + props: Omit & Partial + ): ReactElement { const l10n = useContext(FluentContext); if (!l10n) { throw new Error( diff --git a/fluent-react/tsconfig.build.json b/fluent-react/tsconfig.build.json index 5a446b00..1c550163 100644 --- a/fluent-react/tsconfig.build.json +++ b/fluent-react/tsconfig.build.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig.json", + "extends": "../tsconfig.base.json", "compilerOptions": { "outDir": "./esm" }, diff --git a/fluent-react/tsconfig.json b/fluent-react/tsconfig.json index 7fcf1668..b6256cb0 100644 --- a/fluent-react/tsconfig.json +++ b/fluent-react/tsconfig.json @@ -1,10 +1,6 @@ { - "extends": "./tsconfig.build.json", + "extends": "../tsconfig.json", "compilerOptions": { - "baseUrl": ".", - "paths": { - "@fluent/bundle": ["../fluent-bundle/src/index.ts"], - "@fluent/sequence": ["../fluent-sequence/src/index.ts"] - } + "jsx": "react" } } diff --git a/fluent-react/typedoc.json b/fluent-react/typedoc.json new file mode 100644 index 00000000..bbb5972d --- /dev/null +++ b/fluent-react/typedoc.json @@ -0,0 +1,3 @@ +{ + "tsconfig": "./tsconfig.build.json" +} diff --git a/fluent-sequence/package.json b/fluent-sequence/package.json index 480c90c2..0323f85d 100644 --- a/fluent-sequence/package.json +++ b/fluent-sequence/package.json @@ -29,7 +29,6 @@ "scripts": { "build": "tsc -p ./tsconfig.build.json", "postbuild": "rollup -c ../rollup.config.mjs", - "docs": "typedoc --options ../typedoc.config.cjs --tsconfig ./tsconfig.build.json", "test": "mocha 'test/*_test.js'" }, "engines": { diff --git a/fluent-sequence/src/index.ts b/fluent-sequence/src/index.ts index ec700689..f8f82e92 100644 --- a/fluent-sequence/src/index.ts +++ b/fluent-sequence/src/index.ts @@ -1,6 +1,7 @@ /** - * @module fluent-sequence - * @overview Manage ordered sequences of FluentBundles. + * Manage ordered sequences of {@link @fluent/bundle!FluentBundle | FluentBundles}. + * + * @module */ export { mapBundleSync } from "./map_sync.js"; diff --git a/fluent-sequence/src/map_async.ts b/fluent-sequence/src/map_async.ts index a3185b68..f1d64ca7 100644 --- a/fluent-sequence/src/map_async.ts +++ b/fluent-sequence/src/map_async.ts @@ -12,7 +12,7 @@ export function mapBundleAsync( /** * Asynchronously map an identifier or an array of identifiers to the best - * `FluentBundle` instance(s). + * {@link FluentBundle} instance(s). * * @param bundles - An iterable of bundles to sift through. * @param ids - An id or ids to map. diff --git a/fluent-sequence/src/map_sync.ts b/fluent-sequence/src/map_sync.ts index e1baf313..7e9901bb 100644 --- a/fluent-sequence/src/map_sync.ts +++ b/fluent-sequence/src/map_sync.ts @@ -12,7 +12,7 @@ export function mapBundleSync( /** * Synchronously map an identifier or an array of identifiers to the best - * `FluentBundle` instance(s). + * {@link FluentBundle} instance(s). * * @param bundles - An iterable of bundles to sift through. * @param ids - An id or ids to map. diff --git a/fluent-sequence/tsconfig.build.json b/fluent-sequence/tsconfig.build.json index 9ea82c48..1a76d9a4 100644 --- a/fluent-sequence/tsconfig.build.json +++ b/fluent-sequence/tsconfig.build.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig.json", + "extends": "../tsconfig.base.json", "compilerOptions": { "outDir": "./esm", "rootDir": "./src" diff --git a/fluent-sequence/tsconfig.json b/fluent-sequence/tsconfig.json index 1897eccf..3c43903c 100644 --- a/fluent-sequence/tsconfig.json +++ b/fluent-sequence/tsconfig.json @@ -1,9 +1,3 @@ { - "extends": "./tsconfig.build.json", - "compilerOptions": { - "baseUrl": ".", - "paths": { - "@fluent/bundle": ["../fluent-bundle/src/index.ts"] - } - } + "extends": "../tsconfig.json" } diff --git a/fluent-syntax/package.json b/fluent-syntax/package.json index 0bd7c336..cc43908b 100644 --- a/fluent-syntax/package.json +++ b/fluent-syntax/package.json @@ -43,7 +43,6 @@ "scripts": { "build": "tsc", "postbuild": "rollup -c ../rollup.config.mjs", - "docs": "typedoc --options ../typedoc.config.cjs", "test": "mocha 'test/*_test.js'" }, "engines": { diff --git a/fluent-syntax/src/ast.ts b/fluent-syntax/src/ast.ts index f8e81673..0167bb42 100644 --- a/fluent-syntax/src/ast.ts +++ b/fluent-syntax/src/ast.ts @@ -4,6 +4,7 @@ * All productions described in the ASDL subclass BaseNode, including Span and * Annotation. * + * @category Data Model */ export abstract class BaseNode { abstract type: string; @@ -79,6 +80,8 @@ function scalarsEqual( /** * Base class for AST nodes which can have Spans. + * + * @category Data Model */ export abstract class SyntaxNode extends BaseNode { public span?: Span; @@ -89,6 +92,7 @@ export abstract class SyntaxNode extends BaseNode { } } +/** @category Data Model */ export class Resource extends SyntaxNode { public type = "Resource" as const; public body: Array; @@ -98,8 +102,10 @@ export class Resource extends SyntaxNode { } } +/** @category Data Model */ export declare type Entry = Message | Term | Comments | Junk; +/** @category Data Model */ export class Message extends SyntaxNode { public type = "Message" as const; public id: Identifier; @@ -121,6 +127,7 @@ export class Message extends SyntaxNode { } } +/** @category Data Model */ export class Term extends SyntaxNode { public type = "Term" as const; public id: Identifier; @@ -142,6 +149,7 @@ export class Term extends SyntaxNode { } } +/** @category Data Model */ export class Pattern extends SyntaxNode { public type = "Pattern" as const; public elements: Array; @@ -152,8 +160,10 @@ export class Pattern extends SyntaxNode { } } +/** @category Data Model */ export declare type PatternElement = TextElement | Placeable; +/** @category Data Model */ export class TextElement extends SyntaxNode { public type = "TextElement" as const; public value: string; @@ -164,6 +174,7 @@ export class TextElement extends SyntaxNode { } } +/** @category Data Model */ export class Placeable extends SyntaxNode { public type = "Placeable" as const; public expression: Expression; @@ -176,6 +187,8 @@ export class Placeable extends SyntaxNode { /** * A subset of expressions which can be used as outside of Placeables. + * + * @category Data Model */ export type InlineExpression = | StringLiteral @@ -185,9 +198,15 @@ export type InlineExpression = | TermReference | VariableReference | Placeable; + +/** @category Data Model */ export declare type Expression = InlineExpression | SelectExpression; -// An abstract base class for Literals. +/** + * An abstract base class for Literals. + * + * @category Data Model + */ export abstract class BaseLiteral extends SyntaxNode { public value: string; @@ -201,6 +220,7 @@ export abstract class BaseLiteral extends SyntaxNode { abstract parse(): { value: unknown }; } +/** @category Data Model */ export class StringLiteral extends BaseLiteral { public type = "StringLiteral" as const; @@ -238,6 +258,7 @@ export class StringLiteral extends BaseLiteral { } } +/** @category Data Model */ export class NumberLiteral extends BaseLiteral { public type = "NumberLiteral" as const; @@ -249,8 +270,10 @@ export class NumberLiteral extends BaseLiteral { } } +/** @category Data Model */ export declare type Literal = StringLiteral | NumberLiteral; +/** @category Data Model */ export class MessageReference extends SyntaxNode { public type = "MessageReference" as const; public id: Identifier; @@ -263,6 +286,7 @@ export class MessageReference extends SyntaxNode { } } +/** @category Data Model */ export class TermReference extends SyntaxNode { public type = "TermReference" as const; public id: Identifier; @@ -281,6 +305,7 @@ export class TermReference extends SyntaxNode { } } +/** @category Data Model */ export class VariableReference extends SyntaxNode { public type = "VariableReference" as const; public id: Identifier; @@ -291,6 +316,7 @@ export class VariableReference extends SyntaxNode { } } +/** @category Data Model */ export class FunctionReference extends SyntaxNode { public type = "FunctionReference" as const; public id: Identifier; @@ -303,6 +329,7 @@ export class FunctionReference extends SyntaxNode { } } +/** @category Data Model */ export class SelectExpression extends SyntaxNode { public type = "SelectExpression" as const; public selector: InlineExpression; @@ -315,6 +342,7 @@ export class SelectExpression extends SyntaxNode { } } +/** @category Data Model */ export class CallArguments extends SyntaxNode { public type = "CallArguments" as const; public positional: Array; @@ -330,6 +358,7 @@ export class CallArguments extends SyntaxNode { } } +/** @category Data Model */ export class Attribute extends SyntaxNode { public type = "Attribute" as const; public id: Identifier; @@ -342,6 +371,7 @@ export class Attribute extends SyntaxNode { } } +/** @category Data Model */ export class Variant extends SyntaxNode { public type = "Variant" as const; public key: Identifier | NumberLiteral; @@ -356,6 +386,7 @@ export class Variant extends SyntaxNode { } } +/** @category Data Model */ export class NamedArgument extends SyntaxNode { public type = "NamedArgument" as const; public name: Identifier; @@ -368,6 +399,7 @@ export class NamedArgument extends SyntaxNode { } } +/** @category Data Model */ export class Identifier extends SyntaxNode { public type = "Identifier" as const; public name: string; @@ -378,6 +410,7 @@ export class Identifier extends SyntaxNode { } } +/** @category Data Model */ export abstract class BaseComment extends SyntaxNode { public content: string; constructor(content: string) { @@ -386,19 +419,25 @@ export abstract class BaseComment extends SyntaxNode { } } +/** @category Data Model */ export class Comment extends BaseComment { public type = "Comment" as const; } +/** @category Data Model */ export class GroupComment extends BaseComment { public type = "GroupComment" as const; } + +/** @category Data Model */ export class ResourceComment extends BaseComment { public type = "ResourceComment" as const; } +/** @category Data Model */ export declare type Comments = Comment | GroupComment | ResourceComment; +/** @category Data Model */ export class Junk extends SyntaxNode { public type = "Junk" as const; public annotations: Array; @@ -415,6 +454,7 @@ export class Junk extends SyntaxNode { } } +/** @category Data Model */ export class Span extends BaseNode { public type = "Span" as const; public start: number; @@ -427,6 +467,7 @@ export class Span extends BaseNode { } } +/** @category Data Model */ export class Annotation extends SyntaxNode { public type = "Annotation" as const; public code: string; diff --git a/fluent-syntax/src/errors.ts b/fluent-syntax/src/errors.ts index e92f8835..9150e835 100644 --- a/fluent-syntax/src/errors.ts +++ b/fluent-syntax/src/errors.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ +/** @category Parse */ export class ParseError extends Error { public code: string; public args: Array; diff --git a/fluent-syntax/src/index.ts b/fluent-syntax/src/index.ts index e0df5eef..ebeb2ff1 100644 --- a/fluent-syntax/src/index.ts +++ b/fluent-syntax/src/index.ts @@ -15,11 +15,13 @@ export { FluentSerializerOptions, }; +/** @category Parse */ export function parse(source: string, opts: FluentParserOptions): Resource { const parser = new FluentParser(opts); return parser.parse(source); } +/** @category Serialize */ export function serialize( resource: Resource, opts: FluentSerializerOptions diff --git a/fluent-syntax/src/parser.ts b/fluent-syntax/src/parser.ts index a301396a..92afb20c 100644 --- a/fluent-syntax/src/parser.ts +++ b/fluent-syntax/src/parser.ts @@ -36,10 +36,12 @@ function withSpan(fn: ParseFn): ParseFn { }; } +/** @category Parse */ export interface FluentParserOptions { withSpans?: boolean; } +/** @category Parse */ export class FluentParser { public withSpans: boolean; @@ -145,6 +147,7 @@ export class FluentParser { return this.getEntryOrJunk(ps); } + /** @internal */ getEntryOrJunk(ps: FluentParserStream): AST.Entry { const entryStartPos = ps.index; @@ -178,6 +181,7 @@ export class FluentParser { } } + /** @internal */ getEntry(ps: FluentParserStream): AST.Entry { if (ps.currentChar() === "#") { return this.getComment(ps); @@ -194,6 +198,7 @@ export class FluentParser { throw new ParseError("E0002"); } + /** @internal */ getComment(ps: FluentParserStream): AST.Comments { // 0 - comment // 1 - group comment @@ -242,6 +247,7 @@ export class FluentParser { return new Comment(content); } + /** @internal */ getMessage(ps: FluentParserStream): AST.Message { const id = this.getIdentifier(ps); @@ -258,6 +264,7 @@ export class FluentParser { return new AST.Message(id, value, attrs); } + /** @internal */ getTerm(ps: FluentParserStream): AST.Term { ps.expectChar("-"); const id = this.getIdentifier(ps); @@ -274,6 +281,7 @@ export class FluentParser { return new AST.Term(id, value, attrs); } + /** @internal */ getAttribute(ps: FluentParserStream): AST.Attribute { ps.expectChar("."); @@ -290,6 +298,7 @@ export class FluentParser { return new AST.Attribute(key, value); } + /** @internal */ getAttributes(ps: FluentParserStream): Array { const attrs = []; ps.peekBlank(); @@ -302,6 +311,7 @@ export class FluentParser { return attrs; } + /** @internal */ getIdentifier(ps: FluentParserStream): AST.Identifier { let name = ps.takeIDStart(); @@ -313,6 +323,7 @@ export class FluentParser { return new AST.Identifier(name); } + /** @internal */ getVariantKey(ps: FluentParserStream): AST.Identifier | AST.NumberLiteral { const ch = ps.currentChar(); @@ -330,6 +341,7 @@ export class FluentParser { return this.getIdentifier(ps); } + /** @internal */ getVariant(ps: FluentParserStream, hasDefault: boolean = false): AST.Variant { let defaultIndex = false; @@ -358,6 +370,7 @@ export class FluentParser { return new AST.Variant(key, value, defaultIndex); } + /** @internal */ getVariants(ps: FluentParserStream): Array { const variants: Array = []; let hasDefault = false; @@ -386,6 +399,7 @@ export class FluentParser { return variants; } + /** @internal */ getDigits(ps: FluentParserStream): string { let num = ""; @@ -401,6 +415,7 @@ export class FluentParser { return num; } + /** @internal */ getNumber(ps: FluentParserStream): AST.NumberLiteral { let value = ""; @@ -426,6 +441,8 @@ export class FluentParser { * patterns). The distinction is important for the dedentation logic: the * indent of the first line of a block pattern must be taken into account when * calculating the maximum common indent. + * + * @internal */ maybeGetPattern(ps: FluentParserStream): AST.Pattern | null { ps.peekBlankInline(); @@ -443,6 +460,7 @@ export class FluentParser { return null; } + /** @internal */ getPattern(ps: FluentParserStream, isBlock: boolean): AST.Pattern { const elements: Array = []; let commonIndentLength; @@ -494,6 +512,8 @@ export class FluentParser { * Create a token representing an indent. It's not part of the AST and it will * be trimmed and merged into adjacent TextElements, or turned into a new * TextElement, if it's surrounded by two Placeables. + * + * @internal */ getIndent(ps: FluentParserStream, value: string, start: number): Indent { return new Indent(value, start, ps.index); @@ -502,6 +522,8 @@ export class FluentParser { /** * Dedent a list of elements by removing the maximum common indent from the * beginning of text lines. The common indent is calculated in getPattern. + * + * @internal */ dedent( elements: Array, @@ -562,6 +584,7 @@ export class FluentParser { return trimmed; } + /** @internal */ getTextElement(ps: FluentParserStream): AST.TextElement { let buffer = ""; @@ -582,6 +605,7 @@ export class FluentParser { return new AST.TextElement(buffer); } + /** @internal */ getEscapeSequence(ps: FluentParserStream): string { const next = ps.currentChar(); @@ -599,6 +623,7 @@ export class FluentParser { } } + /** @internal */ getUnicodeEscapeSequence( ps: FluentParserStream, u: string, @@ -620,6 +645,7 @@ export class FluentParser { return `\\${u}${sequence}`; } + /** @internal */ getPlaceable(ps: FluentParserStream): AST.Placeable { ps.expectChar("{"); ps.skipBlank(); @@ -628,6 +654,7 @@ export class FluentParser { return new AST.Placeable(expression); } + /** @internal */ getExpression(ps: FluentParserStream): AST.Expression | AST.Placeable { const selector = this.getInlineExpression(ps); ps.skipBlank(); @@ -672,6 +699,7 @@ export class FluentParser { return selector; } + /** @internal */ getInlineExpression( ps: FluentParserStream ): AST.InlineExpression | AST.Placeable { @@ -740,6 +768,7 @@ export class FluentParser { throw new ParseError("E0028"); } + /** @internal */ getCallArgument( ps: FluentParserStream ): AST.InlineExpression | AST.NamedArgument { @@ -762,6 +791,7 @@ export class FluentParser { throw new ParseError("E0009"); } + /** @internal */ getCallArguments(ps: FluentParserStream): AST.CallArguments { const positional: Array = []; const named: Array = []; @@ -803,6 +833,7 @@ export class FluentParser { return new AST.CallArguments(positional, named); } + /** @internal */ getString(ps: FluentParserStream): AST.StringLiteral { ps.expectChar('"'); let value = ""; @@ -825,6 +856,7 @@ export class FluentParser { return new AST.StringLiteral(value); } + /** @internal */ getLiteral(ps: FluentParserStream): AST.Literal { if (ps.isNumberStart()) { return this.getNumber(ps); @@ -838,6 +870,7 @@ export class FluentParser { } } +/** @internal */ export class Indent { public type = "Indent"; public span: AST.Span; diff --git a/fluent-syntax/src/serializer.ts b/fluent-syntax/src/serializer.ts index 1cf06623..467c7888 100644 --- a/fluent-syntax/src/serializer.ts +++ b/fluent-syntax/src/serializer.ts @@ -43,10 +43,12 @@ function shouldStartOnNewLine(pattern: AST.Pattern): boolean { /** Bit masks representing the state of the serializer. */ const HAS_ENTRIES = 1; +/** @category Serialize */ export interface FluentSerializerOptions { withJunk?: boolean; } +/** @category Serialize */ export class FluentSerializer { public withJunk: boolean; @@ -198,6 +200,7 @@ function serializePlaceable(placeable: AST.Placeable): string { return `{ ${serializeExpression(expr)} }`; } +/** @category Serialize */ export function serializeExpression(expr: Expression | Placeable): string { if (expr instanceof AST.StringLiteral) { return `"${expr.value}"`; @@ -266,6 +269,7 @@ function serializeNamedArgument(arg: AST.NamedArgument): string { return `${arg.name.name}: ${value}`; } +/** @category Serialize */ export function serializeVariantKey( key: AST.Identifier | AST.NumberLiteral ): string { diff --git a/fluent-syntax/tsconfig.json b/fluent-syntax/tsconfig.json index 5a446b00..1c550163 100644 --- a/fluent-syntax/tsconfig.json +++ b/fluent-syntax/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig.json", + "extends": "../tsconfig.base.json", "compilerOptions": { "outDir": "./esm" }, diff --git a/fluent-syntax/typedoc.json b/fluent-syntax/typedoc.json new file mode 100644 index 00000000..0d407573 --- /dev/null +++ b/fluent-syntax/typedoc.json @@ -0,0 +1,4 @@ +{ + "categoryOrder": ["Parse", "Serialize", "Data Model"], + "excludeInternal": true +} diff --git a/package-lock.json b/package-lock.json index b3680dcb..faced3a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,8 @@ "prettyjson": "^1.2.1", "rollup": "^4.12.0", "sinon": "^17.0.1", - "typedoc": "^0.25.9", + "typedoc": "^0.28.1", + "typedoc-plugin-redirect": "^1.2.0", "typescript": "^5.3.3", "typescript-eslint": "^8.27.0" }, @@ -2351,6 +2352,18 @@ "resolved": "fluent-syntax", "link": true }, + "node_modules/@gerrit0/mini-shiki": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/@gerrit0/mini-shiki/-/mini-shiki-3.2.1.tgz", + "integrity": "sha512-HbzRC6MKB6U8kQhczz0APKPIzFHTrcqhaC7es2EXInq1SpjPVnpVSIsBe6hNoLWqqCx1n5VKiPXq6PfXnHZKOQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/engine-oniguruma": "^3.2.1", + "@shikijs/types": "^3.2.1", + "@shikijs/vscode-textmate": "^10.0.2" + } + }, "node_modules/@humanfs/core": { "version": "0.19.1", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", @@ -3364,6 +3377,35 @@ "win32" ] }, + "node_modules/@shikijs/engine-oniguruma": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-3.2.1.tgz", + "integrity": "sha512-wZZAkayEn6qu2+YjenEoFqj0OyQI64EWsNR6/71d1EkG4sxEOFooowKivsWPpaWNBu3sxAG+zPz5kzBL/SsreQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "3.2.1", + "@shikijs/vscode-textmate": "^10.0.2" + } + }, + "node_modules/@shikijs/types": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-3.2.1.tgz", + "integrity": "sha512-/NTWAk4KE2M8uac0RhOsIhYQf4pdU0OywQuYDGIGAJ6Mjunxl2cGiuLkvu4HLCMn+OTTLRWkjZITp+aYJv60yA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4" + } + }, + "node_modules/@shikijs/vscode-textmate": { + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz", + "integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==", + "dev": true, + "license": "MIT" + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -3492,6 +3534,16 @@ "@types/node": "*" } }, + "node_modules/@types/hast": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", + "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", @@ -3587,6 +3639,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/yargs": { "version": "17.0.33", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz", @@ -3954,13 +4013,6 @@ "node": ">=8" } }, - "node_modules/ansi-sequence-parser": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.3.tgz", - "integrity": "sha512-+fksAx9eG3Ab6LDnLs3ZqZa8KVJ/jYnX+D4Qe1azX+LFGFAXqynCQLOdLpNYN/l9e7l6hMWwZbrnctqr6eSQSw==", - "dev": true, - "license": "MIT" - }, "node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -7964,13 +8016,6 @@ "node": ">=6" } }, - "node_modules/jsonc-parser": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", - "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", - "dev": true, - "license": "MIT" - }, "node_modules/jsonfile": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", @@ -8042,6 +8087,16 @@ "dev": true, "license": "MIT" }, + "node_modules/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "uc.micro": "^2.0.0" + } + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -8153,17 +8208,22 @@ "tmpl": "1.0.5" } }, - "node_modules/marked": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", - "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", + "node_modules/markdown-it": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", "dev": true, "license": "MIT", - "bin": { - "marked": "bin/marked.js" + "dependencies": { + "argparse": "^2.0.1", + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" }, - "engines": { - "node": ">= 12" + "bin": { + "markdown-it": "bin/markdown-it.mjs" } }, "node_modules/math-intrinsics": { @@ -8176,6 +8236,13 @@ "node": ">= 0.4" } }, + "node_modules/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true, + "license": "MIT" + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -8922,6 +8989,16 @@ "node": ">=6" } }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/pure-rand": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.1.0.tgz", @@ -9567,19 +9644,6 @@ "node": ">=8" } }, - "node_modules/shiki": { - "version": "0.14.7", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.7.tgz", - "integrity": "sha512-dNPAPrxSc87ua2sKJ3H5dQ/6ZaY8RNnaAqK+t0eG7p0Soi2ydiqbGOTaZCqaYvA/uZYfS1LJnemt3Q+mSfcPCg==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-sequence-parser": "^1.1.0", - "jsonc-parser": "^3.2.0", - "vscode-oniguruma": "^1.7.0", - "vscode-textmate": "^8.0.0" - } - }, "node_modules/side-channel": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", @@ -10251,25 +10315,37 @@ } }, "node_modules/typedoc": { - "version": "0.25.13", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.13.tgz", - "integrity": "sha512-pQqiwiJ+Z4pigfOnnysObszLiU3mVLWAExSPf+Mu06G/qsc3wzbuM56SZQvONhHLncLUhYzOVkjFFpFfL5AzhQ==", + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.28.1.tgz", + "integrity": "sha512-Mn2VPNMaxoe/hlBiLriG4U55oyAa3Xo+8HbtEwV7F5WEOPXqtxzGuMZhJYHaqFJpajeQ6ZDUC2c990NAtTbdgw==", "dev": true, "license": "Apache-2.0", "dependencies": { + "@gerrit0/mini-shiki": "^3.2.1", "lunr": "^2.3.9", - "marked": "^4.3.0", - "minimatch": "^9.0.3", - "shiki": "^0.14.7" + "markdown-it": "^14.1.0", + "minimatch": "^9.0.5", + "yaml": "^2.7.0 " }, "bin": { "typedoc": "bin/typedoc" }, "engines": { - "node": ">= 16" + "node": ">= 18", + "pnpm": ">= 10" }, "peerDependencies": { - "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x" + "typescript": "5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x" + } + }, + "node_modules/typedoc-plugin-redirect": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/typedoc-plugin-redirect/-/typedoc-plugin-redirect-1.2.0.tgz", + "integrity": "sha512-BfS8FVWCaAHbbz0/Yx6TeKhKrfo+XIYTw2L17HklvR70GQ3iDbbWu0MDDVwecfbPW9oxlHPitFxTVBZVA9Iojg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "typedoc": "0.26.x || 0.27.x || 0.28.x" } }, "node_modules/typedoc/node_modules/brace-expansion": { @@ -10299,9 +10375,9 @@ } }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "version": "5.8.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz", + "integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==", "dev": true, "license": "Apache-2.0", "bin": { @@ -10335,6 +10411,13 @@ "typescript": ">=4.8.4 <5.9.0" } }, + "node_modules/uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "dev": true, + "license": "MIT" + }, "node_modules/unbox-primitive": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.1.0.tgz", @@ -10482,20 +10565,6 @@ "node": ">=10.12.0" } }, - "node_modules/vscode-oniguruma": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz", - "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==", - "dev": true, - "license": "MIT" - }, - "node_modules/vscode-textmate": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz", - "integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==", - "dev": true, - "license": "MIT" - }, "node_modules/w3c-xmlserializer": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", @@ -10799,6 +10868,19 @@ "dev": true, "license": "ISC" }, + "node_modules/yaml": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.0.tgz", + "integrity": "sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/yargs": { "version": "17.7.2", "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", diff --git a/package.json b/package.json index da9a4a9a..36904409 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,10 @@ "scripts": { "predist": "npm run clean", "dist": "npm run build --workspaces", - "postdist": "npm run lint && npm run test && npm run docs --workspaces", + "postdist": "npm run lint && npm run test && npm run docs", "clean": "git clean -fdxe node_modules fluent-*/{coverage,dist,esm,index.js} html", "deploy-html": "gh-pages -d html", + "docs": "typedoc", "lint": "eslint --max-warnings 0", "prettier": "prettier --write .", "test:common": "c8 mocha 'fluent-*/test/*_test.js'", @@ -45,7 +46,8 @@ "prettyjson": "^1.2.1", "rollup": "^4.12.0", "sinon": "^17.0.1", - "typedoc": "^0.25.9", + "typedoc": "^0.28.1", + "typedoc-plugin-redirect": "^1.2.0", "typescript": "^5.3.3", "typescript-eslint": "^8.27.0" } diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 00000000..58c339e8 --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "es2019", + "module": "es2015", + "strict": true, + "allowJs": false, + "esModuleInterop": true, + "moduleResolution": "node", + "noEmitHelpers": true, + "declaration": true + } +} diff --git a/tsconfig.json b/tsconfig.json index 58c339e8..0908de60 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,10 @@ { + "extends": "./tsconfig.base.json", "compilerOptions": { - "target": "es2019", - "module": "es2015", - "strict": true, - "allowJs": false, - "esModuleInterop": true, - "moduleResolution": "node", - "noEmitHelpers": true, - "declaration": true + "baseUrl": ".", + "paths": { + "@fluent/bundle": ["./fluent-bundle/src/index.ts"], + "@fluent/sequence": ["./fluent-sequence/src/index.ts"] + } } } diff --git a/typedoc.config.cjs b/typedoc.config.cjs deleted file mode 100644 index 660fe8c8..00000000 --- a/typedoc.config.cjs +++ /dev/null @@ -1,10 +0,0 @@ -const { resolve } = require("path"); - -const { name } = require(resolve("package.json")); - -module.exports = { - entryPoints: [resolve("src/index.ts")], - hideGenerator: true, - includeVersion: true, - out: resolve(name.replace("@fluent", "../html")), -}; diff --git a/typedoc.json b/typedoc.json new file mode 100644 index 00000000..69031319 --- /dev/null +++ b/typedoc.json @@ -0,0 +1,34 @@ +{ + "name": "fluent.js", + "entryPointStrategy": "packages", + "entryPoints": [ + "./fluent-bundle", + "./fluent-dedent", + "./fluent-dom", + "./fluent-langneg", + "./fluent-react", + "./fluent-sequence", + "./fluent-syntax" + ], + "navigation": { + "includeCategories": true, + "includeFolders": false + }, + "out": "./html", + "packageOptions": { + "entryPoints": ["src/index.ts"], + "includeVersion": true + }, + "plugin": ["typedoc-plugin-redirect"], + "hideGenerator": true, + "highlightLanguages": ["html", "javascript", "jsx", "typescript"], + "redirects": { + "bundle": "modules/_fluent_bundle.html", + "dedent": "modules/_fluent_dedent.html", + "dom": "modules/_fluent_dom.html", + "langneg": "modules/_fluent_langneg.html", + "react": "modules/_fluent_react.html", + "sequence": "modules/_fluent_sequence.html", + "syntax": "modules/_fluent_syntax.html" + } +}