Comparing version 0.25.13 to 0.26.0-beta.0
@@ -21,9 +21,10 @@ export { Application } from "./lib/application"; | ||
export { Converter, Context, type CommentParserConfig, type DeclarationReference, type SymbolReference, type ComponentPath, type Meaning, type MeaningKeyword, type ExternalResolveResult, type ExternalSymbolResolver, } from "./lib/converter"; | ||
export { Renderer, DefaultTheme, DefaultThemeRenderContext, UrlMapping, Theme, PageEvent, RendererEvent, MarkdownEvent, IndexEvent, } from "./lib/output"; | ||
export { Renderer, DefaultTheme, DefaultThemeRenderContext, Slugger, UrlMapping, Theme, PageEvent, RendererEvent, MarkdownEvent, IndexEvent, } from "./lib/output"; | ||
export type { RenderTemplate, RendererHooks, NavigationElement, } from "./lib/output"; | ||
export { ArgumentsReader, Option, BindOption, CommentStyle, JSX, LogLevel, Logger, Options, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, MinimalSourceFile, normalizePath, } from "./lib/utils"; | ||
export { ArgumentsReader, Option, CommentStyle, JSX, LogLevel, Logger, Options, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, MinimalSourceFile, normalizePath, } from "./lib/utils"; | ||
export type { OptionsReader, TypeDocOptions, TypeDocOptionMap, ValidationOptions, TypeDocOptionValues, KeyToDeclaration, DeclarationOption, DeclarationOptionBase, StringDeclarationOption, NumberDeclarationOption, BooleanDeclarationOption, ArrayDeclarationOption, MixedDeclarationOption, ObjectDeclarationOption, MapDeclarationOption, FlagsDeclarationOption, DeclarationOptionToOptionType, SortStrategy, ParameterTypeToOptionTypeMap, DocumentationEntryPoint, ManuallyValidatedOption, EnumKeys, JsDocCompatibility, } from "./lib/utils"; | ||
export type { EventMap, EventCallback } from "./lib/utils/events"; | ||
export { JSONOutput, Serializer, Deserializer, type Deserializable, type DeserializerComponent, type SerializerComponent, SerializeEvent, } from "./lib/serialization"; | ||
export * as Internationalization from "./lib/internationalization/index"; | ||
import TypeScript from "typescript"; | ||
export { TypeScript }; |
@@ -32,3 +32,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TypeScript = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.normalizePath = exports.MinimalSourceFile = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.BindOption = exports.Option = exports.ArgumentsReader = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.Configuration = exports.Models = exports.resetReflectionID = exports.Event = exports.EventDispatcher = exports.Application = void 0; | ||
exports.TypeScript = exports.Internationalization = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.normalizePath = exports.MinimalSourceFile = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.Option = exports.ArgumentsReader = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.Slugger = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.Configuration = exports.Models = exports.resetReflectionID = exports.Event = exports.EventDispatcher = exports.Application = void 0; | ||
var application_1 = require("./lib/application"); | ||
@@ -64,2 +64,3 @@ Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } }); | ||
Object.defineProperty(exports, "DefaultThemeRenderContext", { enumerable: true, get: function () { return output_1.DefaultThemeRenderContext; } }); | ||
Object.defineProperty(exports, "Slugger", { enumerable: true, get: function () { return output_1.Slugger; } }); | ||
Object.defineProperty(exports, "UrlMapping", { enumerable: true, get: function () { return output_1.UrlMapping; } }); | ||
@@ -74,3 +75,2 @@ Object.defineProperty(exports, "Theme", { enumerable: true, get: function () { return output_1.Theme; } }); | ||
Object.defineProperty(exports, "Option", { enumerable: true, get: function () { return utils_1.Option; } }); | ||
Object.defineProperty(exports, "BindOption", { enumerable: true, get: function () { return utils_1.BindOption; } }); | ||
Object.defineProperty(exports, "CommentStyle", { enumerable: true, get: function () { return utils_1.CommentStyle; } }); | ||
@@ -95,3 +95,4 @@ Object.defineProperty(exports, "JSX", { enumerable: true, get: function () { return utils_1.JSX; } }); | ||
Object.defineProperty(exports, "SerializeEvent", { enumerable: true, get: function () { return serialization_1.SerializeEvent; } }); | ||
exports.Internationalization = __importStar(require("./lib/internationalization/index")); | ||
const typescript_1 = __importDefault(require("typescript")); | ||
exports.TypeScript = typescript_1.default; |
@@ -5,7 +5,8 @@ import { Converter } from "./converter/index"; | ||
import type { ProjectReflection } from "./models/index"; | ||
import { Logger, OptionsReader } from "./utils/index"; | ||
import { AbstractComponent, ChildableComponent } from "./utils/component"; | ||
import { Logger, type OptionsReader } from "./utils/index"; | ||
import { type AbstractComponent, ChildableComponent } from "./utils/component"; | ||
import { Options } from "./utils"; | ||
import type { TypeDocOptions } from "./utils/options/declaration"; | ||
import { DocumentationEntryPoint, EntryPointStrategy } from "./utils/entry-point"; | ||
import { type DocumentationEntryPoint, EntryPointStrategy } from "./utils/entry-point"; | ||
import { Internationalization } from "./internationalization/internationalization"; | ||
export declare function createAppForTesting(): Application; | ||
@@ -46,4 +47,15 @@ /** | ||
logger: Logger; | ||
/** | ||
* Internationalization module which supports translating according to | ||
* the `lang` option. | ||
*/ | ||
internationalization: Internationalization; | ||
/** | ||
* Proxy based shortcuts for internationalization keys. | ||
*/ | ||
i18n: import("./internationalization/internationalization").TranslationProxy; | ||
options: Options; | ||
/** @internal */ | ||
accessor lang: string; | ||
/** @internal */ | ||
accessor skipErrorChecking: boolean; | ||
@@ -50,0 +62,0 @@ /** @internal */ |
@@ -78,3 +78,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Application = exports.createAppForTesting = void 0; | ||
exports.Application = void 0; | ||
exports.createAppForTesting = createAppForTesting; | ||
const Path = __importStar(require("path")); | ||
@@ -101,2 +102,4 @@ const typescript_1 = __importDefault(require("typescript")); | ||
const ReflectionSymbolId_1 = require("./models/reflections/ReflectionSymbolId"); | ||
const internationalization_1 = require("./internationalization/internationalization"); | ||
const highlighter_1 = require("./utils/highlighter"); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
@@ -112,3 +115,2 @@ const packageInfo = require("../../package.json"); | ||
} | ||
exports.createAppForTesting = createAppForTesting; | ||
const DEFAULT_READERS = [ | ||
@@ -133,3 +135,3 @@ new index_2.TypeDocReader(), | ||
let Application = (() => { | ||
var _Application_skipErrorChecking_accessor_storage, _Application_entryPointStrategy_accessor_storage, _Application_entryPoints_accessor_storage; | ||
var _Application_lang_accessor_storage, _Application_skipErrorChecking_accessor_storage, _Application_entryPointStrategy_accessor_storage, _Application_entryPoints_accessor_storage; | ||
let _classDecorators = [(0, component_1.Component)({ name: "application", internal: true })]; | ||
@@ -140,2 +142,5 @@ let _classDescriptor; | ||
let _classSuper = component_1.ChildableComponent; | ||
let _lang_decorators; | ||
let _lang_initializers = []; | ||
let _lang_extraInitializers = []; | ||
let _skipErrorChecking_decorators; | ||
@@ -152,2 +157,5 @@ let _skipErrorChecking_initializers = []; | ||
/** @internal */ | ||
get lang() { return __classPrivateFieldGet(this, _Application_lang_accessor_storage, "f"); } | ||
set lang(value) { __classPrivateFieldSet(this, _Application_lang_accessor_storage, value, "f"); } | ||
/** @internal */ | ||
get skipErrorChecking() { return __classPrivateFieldGet(this, _Application_skipErrorChecking_accessor_storage, "f"); } | ||
@@ -181,4 +189,14 @@ set skipErrorChecking(value) { __classPrivateFieldSet(this, _Application_skipErrorChecking_accessor_storage, value, "f"); } | ||
this.logger = new index_2.ConsoleLogger(); | ||
this.options = new utils_1.Options(); | ||
_Application_skipErrorChecking_accessor_storage.set(this, __runInitializers(this, _skipErrorChecking_initializers, void 0)); | ||
/** | ||
* Internationalization module which supports translating according to | ||
* the `lang` option. | ||
*/ | ||
this.internationalization = new internationalization_1.Internationalization(this); | ||
/** | ||
* Proxy based shortcuts for internationalization keys. | ||
*/ | ||
this.i18n = this.internationalization.proxy; | ||
this.options = new utils_1.Options(this.i18n); | ||
_Application_lang_accessor_storage.set(this, __runInitializers(this, _lang_initializers, void 0)); | ||
_Application_skipErrorChecking_accessor_storage.set(this, (__runInitializers(this, _lang_extraInitializers), __runInitializers(this, _skipErrorChecking_initializers, void 0))); | ||
_Application_entryPointStrategy_accessor_storage.set(this, (__runInitializers(this, _skipErrorChecking_extraInitializers), __runInitializers(this, _entryPointStrategy_initializers, void 0))); | ||
@@ -189,2 +207,3 @@ _Application_entryPoints_accessor_storage.set(this, (__runInitializers(this, _entryPointStrategy_extraInitializers), __runInitializers(this, _entryPoints_initializers, void 0))); | ||
this.renderer = this.addComponent("renderer", renderer_1.Renderer); | ||
this.logger.i18n = this.i18n; | ||
} | ||
@@ -195,2 +214,3 @@ /** | ||
static async bootstrapWithPlugins(options = {}, readers = DEFAULT_READERS) { | ||
await (0, highlighter_1.loadShikiMetadata)(); | ||
const app = new Application(DETECTOR); | ||
@@ -219,2 +239,3 @@ readers.forEach((r) => app.options.addReader(r)); | ||
static async bootstrap(options = {}, readers = DEFAULT_READERS) { | ||
await (0, highlighter_1.loadShikiMetadata)(); | ||
const app = new Application(DETECTOR); | ||
@@ -231,6 +252,18 @@ readers.forEach((r) => app.options.addReader(r)); | ||
this.logger.level = this.options.getValue("logLevel"); | ||
for (const [lang, locales] of Object.entries(this.options.getValue("locales"))) { | ||
this.internationalization.addTranslations(lang, locales); | ||
} | ||
if ((0, general_1.hasBeenLoadedMultipleTimes)()) { | ||
this.logger.warn(`TypeDoc has been loaded multiple times. This is commonly caused by plugins which have their own installation of TypeDoc. The loaded paths are:\n\t${(0, general_1.getLoadedPaths)().join("\n\t")}`); | ||
this.logger.warn(this.i18n.loaded_multiple_times_0((0, general_1.getLoadedPaths)().join("\n\t"))); | ||
} | ||
this.trigger(application_events_1.ApplicationEvents.BOOTSTRAP_END, this); | ||
if (!this.internationalization.hasTranslations(this.lang)) { | ||
// Not internationalized as by definition we don't know what to include here. | ||
this.logger.warn(`Options specified "${this.lang}" as the language to use, but TypeDoc does not support it.`); | ||
this.logger.info(("The supported languages are:\n\t" + | ||
this.internationalization | ||
.getSupportedLanguages() | ||
.join("\n\t"))); | ||
this.logger.info("You can define/override local locales with the `locales` option, or contribute them to TypeDoc!"); | ||
} | ||
} | ||
@@ -284,3 +317,3 @@ setOptions(options, reportErrors = true) { | ||
if (!supportedVersionMajorMinor.some((version) => version == typescript_1.default.versionMajorMinor)) { | ||
this.logger.warn(`You are running with an unsupported TypeScript version! If TypeDoc crashes, this is why. TypeDoc supports ${supportedVersionMajorMinor.join(", ")}`); | ||
this.logger.warn(this.i18n.unsupported_ts_version_0(supportedVersionMajorMinor.join(", "))); | ||
} | ||
@@ -320,6 +353,6 @@ const entryPoints = this.getEntryPoints(); | ||
if (!supportedVersionMajorMinor.some((version) => version == typescript_1.default.versionMajorMinor)) { | ||
this.logger.warn(`You are running with an unsupported TypeScript version! TypeDoc supports ${supportedVersionMajorMinor.join(", ")}`); | ||
this.logger.warn(this.i18n.unsupported_ts_version_0(supportedVersionMajorMinor.join(", "))); | ||
} | ||
if (Object.keys(this.options.getCompilerOptions()).length === 0) { | ||
this.logger.warn(`No compiler options set. This likely means that TypeDoc did not find your tsconfig.json. Generated documentation will probably be empty.`); | ||
this.logger.warn(this.i18n.no_compiler_options_set()); | ||
} | ||
@@ -329,3 +362,3 @@ // Doing this is considerably more complicated, we'd need to manage an array of programs, not convert until all programs | ||
if (this.options.getFileNames().length === 0) { | ||
this.logger.error("The provided tsconfig file looks like a solution style tsconfig, which is not supported in watch mode."); | ||
this.logger.error(this.i18n.solution_not_supported_in_watch_mode()); | ||
return; | ||
@@ -336,3 +369,3 @@ } | ||
this.entryPointStrategy !== entry_point_1.EntryPointStrategy.Expand) { | ||
this.logger.error("entryPointStrategy must be set to either resolve or expand for watch mode."); | ||
this.logger.error(this.i18n.strategy_not_supported_in_watch_mode()); | ||
return; | ||
@@ -424,6 +457,6 @@ } | ||
if (this.logger.hasErrors()) { | ||
this.logger.error("Documentation could not be generated due to the errors above."); | ||
this.logger.error(this.i18n.docs_could_not_be_generated()); | ||
} | ||
else { | ||
this.logger.info(`Documentation generated at ${(0, paths_1.nicePath)(out)}`); | ||
this.logger.info(this.i18n.docs_generated_at_0((0, paths_1.nicePath)(out))); | ||
this.logger.verbose(`HTML rendering took ${Date.now() - start}ms`); | ||
@@ -444,3 +477,3 @@ } | ||
await (0, index_2.writeFile)(out, JSON.stringify(ser, null, space)); | ||
this.logger.info(`JSON written to ${(0, paths_1.nicePath)(out)}`); | ||
this.logger.info(this.i18n.json_written_to_0((0, paths_1.nicePath)(out))); | ||
this.logger.verbose(`JSON rendering took ${Date.now() - start}ms`); | ||
@@ -461,3 +494,3 @@ } | ||
if (!this.options.isSet("entryPoints")) { | ||
this.logger.error("No entry points provided to packages mode, documentation cannot be generated."); | ||
this.logger.error(this.i18n.no_entry_points_for_packages()); | ||
return; | ||
@@ -467,3 +500,3 @@ } | ||
if (packageDirs.length === 0) { | ||
this.logger.error("Failed to find any packages, ensure you have provided at least one directory as an entry point containing package.json"); | ||
this.logger.error(this.i18n.failed_to_find_packages()); | ||
return; | ||
@@ -483,3 +516,3 @@ } | ||
entry_point_1.EntryPointStrategy.Packages) { | ||
this.logger.error(`Project at ${(0, paths_1.nicePath)(dir)} has entryPointStrategy set to packages, but nested packages are not supported.`); | ||
this.logger.error(this.i18n.nested_packages_unsupported_0((0, paths_1.nicePath)(dir))); | ||
continue; | ||
@@ -491,3 +524,3 @@ } | ||
for (const { dir, options } of projectsToConvert) { | ||
this.logger.info(`Converting project at ${(0, paths_1.nicePath)(dir)}`); | ||
this.logger.info(this.i18n.converting_project_at_0((0, paths_1.nicePath)(dir))); | ||
this.options = options; | ||
@@ -502,7 +535,7 @@ const project = await this.convert(); | ||
this.options = origOptions; | ||
this.logger.info(`Merging converted projects`); | ||
if (projects.length !== packageDirs.length) { | ||
this.logger.error("Failed to convert one or more packages, result will not be merged together."); | ||
this.logger.error(this.i18n.failed_to_convert_packages()); | ||
return; | ||
} | ||
this.logger.info(this.i18n.merging_converted_projects()); | ||
const result = this.deserializer.reviveProjects(this.options.getValue("name") || "Documentation", projects); | ||
@@ -515,3 +548,3 @@ this.trigger(application_events_1.ApplicationEvents.REVIVE, result); | ||
if (!this.options.isSet("entryPoints")) { | ||
this.logger.error("No entry points provided to merge."); | ||
this.logger.error(this.i18n.no_entry_points_to_merge()); | ||
return; | ||
@@ -523,3 +556,3 @@ } | ||
if (result.length === 0) { | ||
this.logger.warn(`The entrypoint glob ${(0, paths_1.nicePath)(entry)} did not match any files.`); | ||
this.logger.warn(this.i18n.entrypoint_did_not_match_files_0((0, paths_1.nicePath)(entry))); | ||
} | ||
@@ -538,3 +571,3 @@ else { | ||
catch { | ||
this.logger.error(`Failed to parse file at ${(0, paths_1.nicePath)(path)} as json.`); | ||
this.logger.error(this.i18n.failed_to_parse_json_0((0, paths_1.nicePath)(path))); | ||
return null; | ||
@@ -547,2 +580,8 @@ } | ||
this.logger.verbose(`Reviving projects took ${Date.now() - start}ms`); | ||
// If we only revived one project, the project documents were set for | ||
// it when it was created. If we revived more than one project then | ||
// it's convenient to be able to add more documents now. | ||
if (jsonProjects.length > 1) { | ||
this.converter.addProjectDocuments(result); | ||
} | ||
this.trigger(application_events_1.ApplicationEvents.REVIVE, result); | ||
@@ -552,2 +591,3 @@ return result; | ||
}; | ||
_Application_lang_accessor_storage = new WeakMap(); | ||
_Application_skipErrorChecking_accessor_storage = new WeakMap(); | ||
@@ -559,5 +599,7 @@ _Application_entryPointStrategy_accessor_storage = new WeakMap(); | ||
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; | ||
_lang_decorators = [(0, utils_1.Option)("lang")]; | ||
_skipErrorChecking_decorators = [(0, utils_1.Option)("skipErrorChecking")]; | ||
_entryPointStrategy_decorators = [(0, utils_1.Option)("entryPointStrategy")]; | ||
_entryPoints_decorators = [(0, utils_1.Option)("entryPoints")]; | ||
__esDecorate(_classThis, null, _lang_decorators, { kind: "accessor", name: "lang", static: false, private: false, access: { has: obj => "lang" in obj, get: obj => obj.lang, set: (obj, value) => { obj.lang = value; } }, metadata: _metadata }, _lang_initializers, _lang_extraInitializers); | ||
__esDecorate(_classThis, null, _skipErrorChecking_decorators, { kind: "accessor", name: "skipErrorChecking", static: false, private: false, access: { has: obj => "skipErrorChecking" in obj, get: obj => obj.skipErrorChecking, set: (obj, value) => { obj.skipErrorChecking = value; } }, metadata: _metadata }, _skipErrorChecking_initializers, _skipErrorChecking_extraInitializers); | ||
@@ -564,0 +606,0 @@ __esDecorate(_classThis, null, _entryPointStrategy_decorators, { kind: "accessor", name: "entryPointStrategy", static: false, private: false, access: { has: obj => "entryPointStrategy" in obj, get: obj => obj.entryPointStrategy, set: (obj, value) => { obj.entryPointStrategy = value; } }, metadata: _metadata }, _entryPointStrategy_initializers, _entryPointStrategy_extraInitializers); |
@@ -70,3 +70,3 @@ "use strict"; | ||
if (app.options.getValue("help")) { | ||
console.log(app.options.getHelp()); | ||
console.log(app.options.getHelp(app.i18n)); | ||
return ExitCodes.Ok; | ||
@@ -73,0 +73,0 @@ } |
import ts from "typescript"; | ||
import { Token } from "./lexer"; | ||
import { type Token } from "./lexer"; | ||
export declare function lexBlockComment(file: string, pos?: number, end?: number, jsDoc?: ts.JSDoc | undefined, checker?: ts.TypeChecker | undefined): Generator<Token, undefined, undefined>; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lexBlockComment = void 0; | ||
exports.lexBlockComment = lexBlockComment; | ||
const typescript_1 = __importDefault(require("typescript")); | ||
@@ -37,3 +37,2 @@ const lexer_1 = require("./lexer"); | ||
} | ||
exports.lexBlockComment = lexBlockComment; | ||
function getLinkTags(jsDoc) { | ||
@@ -40,0 +39,0 @@ const result = []; |
@@ -10,3 +10,10 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseDeclarationReference = exports.parseMeaning = exports.parseComponentPath = exports.parseComponent = exports.parseSymbolReference = exports.parseModuleSource = exports.parseString = exports.MeaningKeywords = void 0; | ||
exports.MeaningKeywords = void 0; | ||
exports.parseString = parseString; | ||
exports.parseModuleSource = parseModuleSource; | ||
exports.parseSymbolReference = parseSymbolReference; | ||
exports.parseComponent = parseComponent; | ||
exports.parseComponentPath = parseComponentPath; | ||
exports.parseMeaning = parseMeaning; | ||
exports.parseDeclarationReference = parseDeclarationReference; | ||
exports.MeaningKeywords = [ | ||
@@ -148,3 +155,2 @@ "class", // SymbolFlags.Class | ||
} | ||
exports.parseString = parseString; | ||
// ModuleSource:: String | ModuleSourceCharacters | ||
@@ -166,3 +172,2 @@ function parseModuleSource(source, pos, end) { | ||
} | ||
exports.parseModuleSource = parseModuleSource; | ||
// SymbolReference: | ||
@@ -180,3 +185,2 @@ // ComponentPath Meaning? | ||
} | ||
exports.parseSymbolReference = parseSymbolReference; | ||
// Component:: | ||
@@ -203,3 +207,2 @@ // String | ||
} | ||
exports.parseComponent = parseComponent; | ||
// ComponentPath: | ||
@@ -229,3 +232,2 @@ // Component | ||
} | ||
exports.parseComponentPath = parseComponentPath; | ||
// The TSDoc specification permits the first four branches of Meaning. TypeDoc adds the UserLabel | ||
@@ -290,3 +292,2 @@ // branch so that the @label tag can be used with this form of declaration references. | ||
} | ||
exports.parseMeaning = parseMeaning; | ||
// // NOTE: The following grammar is incorrect as |SymbolReference| and |ModuleSource| have an | ||
@@ -336,2 +337,1 @@ // // ambiguous parse. The correct solution is to use a cover grammar to parse | ||
} | ||
exports.parseDeclarationReference = parseDeclarationReference; |
@@ -1,3 +0,3 @@ | ||
import { Reflection } from "../../models"; | ||
import { type Reflection } from "../../models"; | ||
import type { DeclarationReference } from "./declarationReference"; | ||
export declare function resolveDeclarationReference(reflection: Reflection, ref: DeclarationReference): Reflection | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveDeclarationReference = void 0; | ||
exports.resolveDeclarationReference = resolveDeclarationReference; | ||
const assert_1 = require("assert"); | ||
@@ -51,3 +51,3 @@ const models_1 = require("../../models"); | ||
if (reflection.parent instanceof models_1.ContainerReflection) { | ||
high.push(...(reflection.parent.children?.filter((c) => c.name === reflection.name) || [])); | ||
high.push(...(reflection.parent.childrenIncludingDocuments?.filter((c) => c.name === reflection.name) || [])); | ||
} | ||
@@ -83,3 +83,2 @@ else { | ||
} | ||
exports.resolveDeclarationReference = resolveDeclarationReference; | ||
function filterMapByMeaning(reflections, meaning) { | ||
@@ -149,4 +148,4 @@ return (0, utils_1.filterMap)(reflections, (refl) => { | ||
case "index": | ||
if (refl.indexSignature) { | ||
return [refl.indexSignature]; | ||
if (refl.indexSignatures) { | ||
return refl.indexSignatures; | ||
} | ||
@@ -175,3 +174,4 @@ break; | ||
let low = []; | ||
if (!(refl instanceof models_1.ContainerReflection) || !refl.children) { | ||
if (!(refl instanceof models_1.ContainerReflection) || | ||
!refl.childrenIncludingDocuments) { | ||
return { high, low }; | ||
@@ -185,5 +185,5 @@ } | ||
case ".": | ||
high = refl.children.filter((r) => r.name === path.path && | ||
high = refl.childrenIncludingDocuments.filter((r) => r.name === path.path && | ||
(r.kindOf(models_1.ReflectionKind.SomeExport) || r.flags.isStatic)); | ||
low = refl.children.filter((r) => r.name === path.path && | ||
low = refl.childrenIncludingDocuments.filter((r) => r.name === path.path && | ||
(!r.kindOf(models_1.ReflectionKind.SomeExport) || !r.flags.isStatic)); | ||
@@ -194,7 +194,8 @@ break; | ||
case "#": | ||
high = refl.children.filter((r) => { | ||
return (r.name === path.path && | ||
r.kindOf(models_1.ReflectionKind.SomeMember) && | ||
!r.flags.isStatic); | ||
}); | ||
high = | ||
refl.children?.filter((r) => { | ||
return (r.name === path.path && | ||
r.kindOf(models_1.ReflectionKind.SomeMember) && | ||
!r.flags.isStatic); | ||
}) || []; | ||
break; | ||
@@ -205,3 +206,3 @@ // Resolve via "locals"... treat this as a stricter `.` which only supports traversing | ||
if (refl.kindOf(models_1.ReflectionKind.SomeModule | models_1.ReflectionKind.Project)) { | ||
high = refl.children.filter((r) => r.name === path.path); | ||
high = refl.children?.filter((r) => r.name === path.path) || []; | ||
} | ||
@@ -208,0 +209,0 @@ break; |
import ts from "typescript"; | ||
import { ReflectionKind } from "../../models"; | ||
import { Logger } from "../../utils"; | ||
import { type Logger } from "../../utils"; | ||
import { CommentStyle } from "../../utils/options/declaration"; | ||
@@ -10,9 +10,9 @@ export interface DiscoveredComment { | ||
} | ||
export declare function discoverFileComment(node: ts.SourceFile, commentStyle: CommentStyle): { | ||
export declare function discoverFileComments(node: ts.SourceFile, commentStyle: CommentStyle): { | ||
file: ts.SourceFile; | ||
ranges: ts.CommentRange[]; | ||
jsDoc: ts.JSDoc | undefined; | ||
} | undefined; | ||
}[]; | ||
export declare function discoverNodeComment(node: ts.Node, commentStyle: CommentStyle): DiscoveredComment | undefined; | ||
export declare function discoverComment(symbol: ts.Symbol, kind: ReflectionKind, logger: Logger, commentStyle: CommentStyle): DiscoveredComment | undefined; | ||
export declare function discoverSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature, commentStyle: CommentStyle): DiscoveredComment | undefined; |
@@ -6,3 +6,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.discoverSignatureComment = exports.discoverComment = exports.discoverNodeComment = exports.discoverFileComment = void 0; | ||
exports.discoverFileComments = discoverFileComments; | ||
exports.discoverNodeComment = discoverNodeComment; | ||
exports.discoverComment = discoverComment; | ||
exports.discoverSignatureComment = discoverSignatureComment; | ||
const typescript_1 = __importDefault(require("typescript")); | ||
@@ -110,16 +113,17 @@ const models_1 = require("../../models"); | ||
], | ||
// Non-TS kind, will never have comments. | ||
[models_1.ReflectionKind.Document]: [], | ||
}; | ||
function discoverFileComment(node, commentStyle) { | ||
function discoverFileComments(node, commentStyle) { | ||
const text = node.text; | ||
const comments = collectCommentRanges(typescript_1.default.getLeadingCommentRanges(text, node.pos)); | ||
const selectedDocComment = comments.find((ranges) => permittedRange(text, ranges, commentStyle)); | ||
if (selectedDocComment) { | ||
const selectedDocComments = comments.filter((ranges) => permittedRange(text, ranges, commentStyle)); | ||
return selectedDocComments.map((ranges) => { | ||
return { | ||
file: node, | ||
ranges: selectedDocComment, | ||
jsDoc: findJsDocForComment(node, selectedDocComment), | ||
ranges, | ||
jsDoc: findJsDocForComment(node, ranges), | ||
}; | ||
} | ||
}); | ||
} | ||
exports.discoverFileComment = discoverFileComment; | ||
function discoverNodeComment(node, commentStyle) { | ||
@@ -138,3 +142,2 @@ const text = node.getSourceFile().text; | ||
} | ||
exports.discoverNodeComment = discoverNodeComment; | ||
function discoverComment(symbol, kind, logger, commentStyle) { | ||
@@ -154,7 +157,7 @@ // For a module comment, we want the first one defined in the file, | ||
seen.add(node); | ||
// Special behavior here! We temporarily put the implementation comment | ||
// on the reflection which contains all the signatures. This lets us pull | ||
// the comment on the implementation if some signature does not have a comment. | ||
// However, we don't want to skip the node if it is a reference to something. | ||
// See the gh1770 test for an example. | ||
// Special behavior here! | ||
// Signatures and symbols have two distinct discovery methods as of TypeDoc 0.26. | ||
// This method discovers comments for symbols, and function-likes will only have | ||
// a symbol comment if there is more than one signature (== more than one declaration) | ||
// and there is a comment on the implementation signature. | ||
if (kind & models_1.ReflectionKind.ContainsCallSignatures && | ||
@@ -166,3 +169,4 @@ [ | ||
].includes(node.kind) && | ||
!node.body) { | ||
(symbol.declarations.filter((d) => wantedKinds[kind].includes(d.kind)).length === 1 || | ||
!node.body)) { | ||
continue; | ||
@@ -190,3 +194,3 @@ } | ||
default: { | ||
logger.warn(`${symbol.name} has multiple declarations with a comment. An arbitrary comment will be used.`); | ||
logger.warn(logger.i18n.symbol_0_has_multiple_declarations_with_comment(symbol.name)); | ||
const locations = discovered.map(({ file, ranges: [{ pos }] }) => { | ||
@@ -197,3 +201,3 @@ const path = (0, paths_1.nicePath)(file.fileName); | ||
}); | ||
logger.info(`The comments for ${symbol.name} are declared at:\n\t${locations.join("\n\t")}`); | ||
logger.info(logger.i18n.comments_for_0_are_declared_at_1(symbol.name, locations.join("\n\t"))); | ||
return discovered[0]; | ||
@@ -203,3 +207,2 @@ } | ||
} | ||
exports.discoverComment = discoverComment; | ||
function discoverSignatureComment(declaration, commentStyle) { | ||
@@ -237,3 +240,2 @@ const node = declarationToCommentNode(declaration); | ||
} | ||
exports.discoverSignatureComment = discoverSignatureComment; | ||
function findJsDocForComment(node, ranges) { | ||
@@ -240,0 +242,0 @@ if (ranges[0].kind === typescript_1.default.SyntaxKind.MultiLineCommentTrivia) { |
import ts from "typescript"; | ||
import { Comment, ReflectionKind } from "../../models"; | ||
import { Logger } from "../../utils"; | ||
import { type Logger } from "../../utils"; | ||
import type { CommentStyle, JsDocCompatibility } from "../../utils/options/declaration"; | ||
@@ -5,0 +5,0 @@ export interface CommentParserConfig { |
@@ -6,3 +6,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getJsDocComment = exports.getSignatureComment = exports.getFileComment = exports.getNodeComment = exports.getComment = exports.clearCommentCache = void 0; | ||
exports.clearCommentCache = clearCommentCache; | ||
exports.getComment = getComment; | ||
exports.getNodeComment = getNodeComment; | ||
exports.getFileComment = getFileComment; | ||
exports.getSignatureComment = getSignatureComment; | ||
exports.getJsDocComment = getJsDocComment; | ||
const typescript_1 = __importDefault(require("typescript")); | ||
@@ -22,2 +27,3 @@ const models_1 = require("../../models"); | ||
]; | ||
let commentDiscoveryId = 0; | ||
let commentCache = new WeakMap(); | ||
@@ -29,4 +35,4 @@ // We need to do this for tests so that changing the tsLinkResolution option | ||
commentCache = new WeakMap(); | ||
commentDiscoveryId = 0; | ||
} | ||
exports.clearCommentCache = clearCommentCache; | ||
function getCommentWithCache(discovered, config, logger, checker) { | ||
@@ -51,2 +57,3 @@ if (!discovered) | ||
} | ||
comment.discoveryId = ++commentDiscoveryId; | ||
cache.set(ranges[0].pos, comment); | ||
@@ -81,5 +88,7 @@ commentCache.set(file, cache); | ||
} | ||
const sf = declarations.find(typescript_1.default.isSourceFile); | ||
if (sf) { | ||
return getFileComment(sf, config, logger, commentStyle, checker); | ||
} | ||
const isModule = declarations.some((decl) => { | ||
if (typescript_1.default.isSourceFile(decl)) | ||
return true; | ||
if (typescript_1.default.isModuleDeclaration(decl) && typescript_1.default.isStringLiteral(decl.name)) { | ||
@@ -96,12 +105,18 @@ return true; | ||
} | ||
exports.getComment = getComment; | ||
function getNodeComment(node, kind, config, logger, commentStyle, checker) { | ||
return getCommentImpl((0, discovery_1.discoverNodeComment)(node, commentStyle), config, logger, kind === models_1.ReflectionKind.Module, checker); | ||
} | ||
exports.getNodeComment = getNodeComment; | ||
function getFileComment(file, config, logger, commentStyle, checker) { | ||
return getCommentImpl((0, discovery_1.discoverFileComment)(file, commentStyle), config, logger, | ||
/* moduleComment */ true, checker); | ||
for (const commentSource of (0, discovery_1.discoverFileComments)(file, commentStyle)) { | ||
const comment = getCommentWithCache(commentSource, config, logger, checker); | ||
if (comment?.getTag("@license") || comment?.getTag("@import")) { | ||
continue; | ||
} | ||
if (comment?.getTag("@module") || | ||
comment?.hasModifier("@packageDocumentation")) { | ||
return comment; | ||
} | ||
return; | ||
} | ||
} | ||
exports.getFileComment = getFileComment; | ||
function getConstructorParamPropertyComment(symbol, config, logger, commentStyle, checker) { | ||
@@ -115,3 +130,5 @@ const decl = symbol.declarations?.find(typescript_1.default.isParameter); | ||
if (paramTag) { | ||
return new models_1.Comment(paramTag.content); | ||
const result = new models_1.Comment(paramTag.content); | ||
result.sourcePath = comment.sourcePath; | ||
return result; | ||
} | ||
@@ -122,3 +139,2 @@ } | ||
} | ||
exports.getSignatureComment = getSignatureComment; | ||
function getJsDocComment(declaration, config, logger, checker) { | ||
@@ -145,3 +161,5 @@ const file = declaration.getSourceFile(); | ||
if (typescript_1.default.isJSDocEnumTag(declaration)) { | ||
return new models_1.Comment(comment.getTag("@enum")?.content); | ||
const result = new models_1.Comment(comment.getTag("@enum")?.content); | ||
result.sourcePath = comment.sourcePath; | ||
return result; | ||
} | ||
@@ -154,3 +172,3 @@ if (typescript_1.default.isJSDocTemplateTag(declaration) && | ||
// which feels horribly hacky. | ||
logger.warn(`TypeDoc does not support multiple type parameters defined in a single @template tag with a comment.`, declaration); | ||
logger.warn(logger.i18n.multiple_type_parameters_on_template_tag_unsupported(), declaration); | ||
return; | ||
@@ -171,8 +189,9 @@ } | ||
if (!tag) { | ||
logger.error(`Failed to find JSDoc tag for ${name} after parsing comment, please file a bug report.`, declaration); | ||
logger.error(logger.i18n.failed_to_find_jsdoc_tag_for_name_0(name), declaration); | ||
} | ||
else { | ||
return new models_1.Comment(models_1.Comment.cloneDisplayParts(tag.content)); | ||
const result = new models_1.Comment(models_1.Comment.cloneDisplayParts(tag.content)); | ||
result.sourcePath = comment.sourcePath; | ||
return result; | ||
} | ||
} | ||
exports.getJsDocComment = getJsDocComment; |
import type * as ts from "typescript"; | ||
import { Token } from "./lexer"; | ||
import { type Token } from "./lexer"; | ||
export declare function lexLineComments(file: string, ranges: ts.CommentRange[]): Generator<Token, undefined, undefined>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lexLineComments = void 0; | ||
exports.lexLineComments = lexLineComments; | ||
const lexer_1 = require("./lexer"); | ||
@@ -30,3 +30,2 @@ function* lexLineComments(file, ranges) { | ||
} | ||
exports.lexLineComments = lexLineComments; | ||
function* lexLineComments2(file, pos, end) { | ||
@@ -33,0 +32,0 @@ // Trailing whitespace |
@@ -1,3 +0,3 @@ | ||
import { Comment, CommentDisplayPart, Reflection, ReflectionSymbolId } from "../../models"; | ||
import { DeclarationReference } from "./declarationReference"; | ||
import { type Comment, type CommentDisplayPart, type Reflection, ReflectionSymbolId } from "../../models"; | ||
import { type DeclarationReference } from "./declarationReference"; | ||
export type ExternalResolveResult = { | ||
@@ -4,0 +4,0 @@ target: string; |
@@ -6,3 +6,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolvePartLinks = exports.resolveLinks = void 0; | ||
exports.resolveLinks = resolveLinks; | ||
exports.resolvePartLinks = resolvePartLinks; | ||
const typescript_1 = __importDefault(require("typescript")); | ||
@@ -21,8 +22,9 @@ const models_1 = require("../../models"); | ||
} | ||
if (reflection.isDocument()) { | ||
reflection.content = resolvePartLinks(reflection, reflection.content, externalResolver, options); | ||
} | ||
} | ||
exports.resolveLinks = resolveLinks; | ||
function resolvePartLinks(reflection, parts, externalResolver, options) { | ||
return parts.flatMap((part) => processPart(reflection, part, externalResolver, options)); | ||
} | ||
exports.resolvePartLinks = resolvePartLinks; | ||
function processPart(reflection, part, externalResolver, options) { | ||
@@ -29,0 +31,0 @@ if (part.kind === "inline-tag") { |
import type { CommentParserConfig } from "."; | ||
import { Comment } from "../../models"; | ||
import { Logger } from "../../utils"; | ||
import { Comment, type CommentDisplayPart } from "../../models"; | ||
import { type Logger } from "../../utils"; | ||
import type { MinimalSourceFile } from "../../utils/minimalSourceFile"; | ||
import { Token } from "./lexer"; | ||
import { type Token } from "./lexer"; | ||
export declare function parseComment(tokens: Generator<Token, undefined, undefined>, config: CommentParserConfig, file: MinimalSourceFile, logger: Logger): Comment; | ||
/** | ||
* Intended for parsing markdown documents. This only parses code blocks and | ||
* inline tags outside of code blocks, everything else is text. | ||
* | ||
* If you change this, also look at blockContent, as it likely needs similar | ||
* modifications to ensure parsing is consistent. | ||
*/ | ||
export declare function parseCommentString(tokens: Generator<Token, undefined, undefined>, config: CommentParserConfig, file: MinimalSourceFile, logger: Logger): { | ||
content: CommentDisplayPart[]; | ||
frontmatter: Record<string, unknown>; | ||
}; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseComment = void 0; | ||
const assert_1 = require("assert"); | ||
exports.parseComment = parseComment; | ||
exports.parseCommentString = parseCommentString; | ||
const assert_1 = __importStar(require("assert")); | ||
const yaml_1 = require("yaml"); | ||
const models_1 = require("../../models"); | ||
@@ -46,10 +71,9 @@ const utils_1 = require("../../utils"); | ||
const comment = new models_1.Comment(); | ||
comment.summary = blockContent(comment, lexer, config, warningImpl); | ||
comment.sourcePath = file.fileName; | ||
comment.summary = blockContent(comment, lexer, config, logger.i18n, warningImpl); | ||
while (!lexer.done()) { | ||
comment.blockTags.push(blockTag(comment, lexer, config, warningImpl)); | ||
comment.blockTags.push(blockTag(comment, lexer, config, logger.i18n, warningImpl)); | ||
} | ||
postProcessComment(comment, (message) => { | ||
(0, assert_1.ok)(typeof tok === "object"); | ||
logger.warn(`${message} in comment at ${(0, paths_1.nicePath)(file.fileName)}:${file.getLineAndCharacterOfPosition(tok.pos).line + 1}`); | ||
}); | ||
const tok2 = tok; | ||
postProcessComment(comment, logger.i18n, () => `${(0, paths_1.nicePath)(file.fileName)}:${file.getLineAndCharacterOfPosition(tok2.pos).line + 1}`, (message) => logger.warn(message)); | ||
return comment; | ||
@@ -60,3 +84,81 @@ function warningImpl(message, token) { | ||
} | ||
exports.parseComment = parseComment; | ||
/** | ||
* Intended for parsing markdown documents. This only parses code blocks and | ||
* inline tags outside of code blocks, everything else is text. | ||
* | ||
* If you change this, also look at blockContent, as it likely needs similar | ||
* modifications to ensure parsing is consistent. | ||
*/ | ||
function parseCommentString(tokens, config, file, logger) { | ||
const suppressWarningsConfig = { | ||
...config, | ||
jsDocCompatibility: { | ||
defaultTag: true, | ||
exampleTag: true, | ||
ignoreUnescapedBraces: true, | ||
inheritDocTag: true, | ||
}, | ||
}; | ||
const content = []; | ||
const lexer = makeLookaheadGenerator(tokens); | ||
while (!lexer.done()) { | ||
let consume = true; | ||
const next = lexer.peek(); | ||
switch (next.kind) { | ||
case lexer_1.TokenSyntaxKind.TypeAnnotation: | ||
// Shouldn't have been produced by our lexer | ||
(0, assert_1.default)(false, "Should be unreachable"); | ||
break; | ||
case lexer_1.TokenSyntaxKind.NewLine: | ||
case lexer_1.TokenSyntaxKind.Text: | ||
case lexer_1.TokenSyntaxKind.Tag: | ||
case lexer_1.TokenSyntaxKind.CloseBrace: | ||
content.push({ kind: "text", text: next.text }); | ||
break; | ||
case lexer_1.TokenSyntaxKind.Code: | ||
content.push({ kind: "code", text: next.text }); | ||
break; | ||
case lexer_1.TokenSyntaxKind.OpenBrace: | ||
inlineTag(lexer, content, suppressWarningsConfig, logger.i18n, (message, token) => logger.warn(message, token.pos, file)); | ||
consume = false; | ||
break; | ||
default: | ||
(0, utils_1.assertNever)(next.kind); | ||
} | ||
if (consume) { | ||
lexer.take(); | ||
} | ||
} | ||
// Check for frontmatter | ||
let frontmatterData = {}; | ||
const firstBlock = content[0]; | ||
if (firstBlock.text.startsWith("---\n")) { | ||
const end = firstBlock.text.indexOf("\n---\n"); | ||
if (end !== -1) { | ||
const yamlText = firstBlock.text.slice("---\n".length, end); | ||
firstBlock.text = firstBlock.text | ||
.slice(end + "\n---\n".length) | ||
.trimStart(); | ||
const frontmatter = (0, yaml_1.parseDocument)(yamlText, { prettyErrors: false }); | ||
for (const warning of frontmatter.warnings) { | ||
// Can't translate issues coming from external library... | ||
logger.warn(warning.message, warning.pos[0] + "---\n".length, file); | ||
} | ||
for (const error of frontmatter.errors) { | ||
// Can't translate issues coming from external library... | ||
logger.error(error.message, error.pos[0] + "---\n".length, file); | ||
} | ||
if (frontmatter.errors.length === 0) { | ||
const data = frontmatter.toJS(); | ||
if (typeof data === "object") { | ||
frontmatterData = data; | ||
} | ||
else { | ||
logger.error(logger.i18n.yaml_frontmatter_not_an_object(), 5, file); | ||
} | ||
} | ||
} | ||
} | ||
return { content, frontmatter: frontmatterData }; | ||
} | ||
const HAS_USER_IDENTIFIER = [ | ||
@@ -79,3 +181,3 @@ "@callback", | ||
*/ | ||
function postProcessComment(comment, warning) { | ||
function postProcessComment(comment, i18n, getPosition, warning) { | ||
for (const tag of comment.blockTags) { | ||
@@ -97,3 +199,3 @@ if (HAS_USER_IDENTIFIER.includes(tag.tag) && tag.content.length) { | ||
if (tag.content.some((part) => part.kind === "inline-tag" && part.tag === "@inheritDoc")) { | ||
warning("An inline @inheritDoc tag should not appear within a block tag as it will not be processed"); | ||
warning(i18n.inline_inheritdoc_should_not_appear_in_block_tag_in_comment_at_0(getPosition())); | ||
} | ||
@@ -103,3 +205,3 @@ } | ||
if (remarks.length > 1) { | ||
warning("At most one @remarks tag is expected in a comment, ignoring all but the first"); | ||
warning(i18n.at_most_one_remarks_tag_expected_in_comment_at_0(getPosition())); | ||
(0, utils_1.removeIf)(comment.blockTags, (tag) => remarks.indexOf(tag) > 0); | ||
@@ -109,3 +211,3 @@ } | ||
if (remarks.length > 1) { | ||
warning("At most one @returns tag is expected in a comment, ignoring all but the first"); | ||
warning(i18n.at_most_one_returns_tag_expected_in_comment_at_0(getPosition())); | ||
(0, utils_1.removeIf)(comment.blockTags, (tag) => returns.indexOf(tag) > 0); | ||
@@ -116,3 +218,3 @@ } | ||
if (inlineInheritDoc.length + inheritDoc.length > 1) { | ||
warning("At most one @inheritDoc tag is expected in a comment, ignoring all but the first"); | ||
warning(i18n.at_most_one_inheritdoc_tag_expected_in_comment_at_0(getPosition())); | ||
const allInheritTags = [...inlineInheritDoc, ...inheritDoc]; | ||
@@ -124,10 +226,10 @@ (0, utils_1.removeIf)(comment.summary, (part) => allInheritTags.indexOf(part) > 0); | ||
comment.summary.some((part) => part.kind !== "inline-tag" && /\S/.test(part.text))) { | ||
warning("Content in the summary section will be overwritten by the @inheritDoc tag"); | ||
warning(i18n.content_in_summary_overwritten_by_inheritdoc_in_comment_at_0(getPosition())); | ||
} | ||
if ((inlineInheritDoc.length || inheritDoc.length) && remarks.length) { | ||
warning("Content in the @remarks block will be overwritten by the @inheritDoc tag"); | ||
warning(i18n.content_in_remarks_block_overwritten_by_inheritdoc_in_comment_at_0(getPosition())); | ||
} | ||
} | ||
const aliasedTags = new Map([["@return", "@returns"]]); | ||
function blockTag(comment, lexer, config, warning) { | ||
function blockTag(comment, lexer, config, i18n, warning) { | ||
const blockTag = lexer.take(); | ||
@@ -138,10 +240,10 @@ (0, assert_1.ok)(blockTag.kind === lexer_1.TokenSyntaxKind.Tag, "blockTag called not at the start of a block tag."); // blockContent is broken if this fails. | ||
if (tagName === "@example") { | ||
return exampleBlock(comment, lexer, config, warning); | ||
return exampleBlock(comment, lexer, config, i18n, warning); | ||
} | ||
else if (["@default", "@defaultValue"].includes(tagName) && | ||
config.jsDocCompatibility.defaultTag) { | ||
content = defaultBlockContent(comment, lexer, config, warning); | ||
content = defaultBlockContent(comment, lexer, config, i18n, warning); | ||
} | ||
else { | ||
content = blockContent(comment, lexer, config, warning); | ||
content = blockContent(comment, lexer, config, i18n, warning); | ||
} | ||
@@ -154,9 +256,9 @@ return new models_1.CommentTag(tagName, content); | ||
*/ | ||
function defaultBlockContent(comment, lexer, config, warning) { | ||
function defaultBlockContent(comment, lexer, config, i18n, warning) { | ||
lexer.mark(); | ||
const content = blockContent(comment, lexer, config, () => { }); | ||
const content = blockContent(comment, lexer, config, i18n, () => { }); | ||
const end = lexer.done() || lexer.peek(); | ||
lexer.release(); | ||
if (content.some((part) => part.kind === "code")) { | ||
return blockContent(comment, lexer, config, warning); | ||
return blockContent(comment, lexer, config, i18n, warning); | ||
} | ||
@@ -184,5 +286,5 @@ const tokens = []; | ||
*/ | ||
function exampleBlock(comment, lexer, config, warning) { | ||
function exampleBlock(comment, lexer, config, i18n, warning) { | ||
lexer.mark(); | ||
const content = blockContent(comment, lexer, config, () => { }); | ||
const content = blockContent(comment, lexer, config, i18n, () => { }); | ||
const end = lexer.done() || lexer.peek(); | ||
@@ -219,4 +321,3 @@ lexer.release(); | ||
if (!warnedAboutRichNameContent) { | ||
warning("The first line of an example tag will be taken literally as" + | ||
" the example name, and should only contain text.", lexer.peek()); | ||
warning(i18n.example_tag_literal_name(), lexer.peek()); | ||
warnedAboutRichNameContent = true; | ||
@@ -230,3 +331,3 @@ } | ||
} | ||
const content = blockContent(comment, lexer, config, warning); | ||
const content = blockContent(comment, lexer, config, i18n, warning); | ||
const tag = new models_1.CommentTag("@example", content); | ||
@@ -266,3 +367,7 @@ if (exampleName.trim()) { | ||
} | ||
function blockContent(comment, lexer, config, warning) { | ||
/** | ||
* If you change this, also look at parseCommentString as it | ||
* likely needs similar modifications to ensure parsing is consistent. | ||
*/ | ||
function blockContent(comment, lexer, config, i18n, warning) { | ||
const content = []; | ||
@@ -284,3 +389,3 @@ let atNewLine = true; | ||
if (!config.jsDocCompatibility.inheritDocTag) { | ||
warning("The @inheritDoc tag should be properly capitalized", next); | ||
warning(i18n.inheritdoc_tag_properly_capitalized(), next); | ||
} | ||
@@ -296,3 +401,3 @@ next.text = "@inheritDoc"; | ||
comment.modifierTags.add(next.text); | ||
warning(`Treating unrecognized tag "${next.text}" as a modifier tag`, next); | ||
warning(i18n.treating_unrecognized_tag_0_as_modifier(next.text), next); | ||
break; | ||
@@ -311,3 +416,3 @@ } | ||
if (!config.jsDocCompatibility.ignoreUnescapedBraces) { | ||
warning(`Unmatched closing brace`, next); | ||
warning(i18n.unmatched_closing_brace(), next); | ||
} | ||
@@ -317,3 +422,3 @@ content.push({ kind: "text", text: next.text }); | ||
case lexer_1.TokenSyntaxKind.OpenBrace: | ||
inlineTag(lexer, content, config, warning); | ||
inlineTag(lexer, content, config, i18n, warning); | ||
consume = false; | ||
@@ -355,3 +460,3 @@ break; | ||
} | ||
function inlineTag(lexer, block, config, warning) { | ||
function inlineTag(lexer, block, config, i18n, warning) { | ||
const openBrace = lexer.take(); | ||
@@ -364,3 +469,3 @@ // Now skip whitespace to grab the tag name. | ||
if (!config.jsDocCompatibility.ignoreUnescapedBraces) { | ||
warning("Encountered an unescaped open brace without an inline tag", openBrace); | ||
warning(i18n.unescaped_open_brace_without_inline_tag(), openBrace); | ||
} | ||
@@ -376,3 +481,3 @@ block.push({ kind: "text", text: openBrace.text }); | ||
if (!config.jsDocCompatibility.ignoreUnescapedBraces) { | ||
warning("Encountered an unescaped open brace without an inline tag", openBrace); | ||
warning(i18n.unescaped_open_brace_without_inline_tag(), openBrace); | ||
} | ||
@@ -386,3 +491,3 @@ block.push({ kind: "text", text: openBrace.text + tagName.text }); | ||
if (!config.inlineTags.has(tagName.text)) { | ||
warning(`Encountered an unknown inline tag "${tagName.text}"`, tagName); | ||
warning(i18n.unknown_inline_tag_0(tagName.text), tagName); | ||
} | ||
@@ -395,3 +500,3 @@ const content = []; | ||
if (token.kind === lexer_1.TokenSyntaxKind.OpenBrace) { | ||
warning("Encountered an open brace within an inline tag, this is likely a mistake", token); | ||
warning(i18n.open_brace_within_inline_tag(), token); | ||
} | ||
@@ -401,3 +506,3 @@ content.push(token.kind === lexer_1.TokenSyntaxKind.NewLine ? " " : token.text); | ||
if (lexer.done()) { | ||
warning("Inline tag is not closed", openBrace); | ||
warning(i18n.inline_tag_not_closed(), openBrace); | ||
} | ||
@@ -404,0 +509,0 @@ else { |
@@ -1,2 +0,8 @@ | ||
import { Token } from "./lexer"; | ||
import { type Token } from "./lexer"; | ||
/** | ||
* Note: This lexer intentionally *only* recognizes inline tags and code blocks. | ||
* This is because it is intended for use on markdown documents, and we shouldn't | ||
* take some stray `@user` mention within a "Thanks" section of someone's changelog | ||
* as starting a block! | ||
*/ | ||
export declare function lexCommentString(file: string): Generator<Token, undefined, undefined>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lexCommentString = void 0; | ||
exports.lexCommentString = lexCommentString; | ||
const lexer_1 = require("./lexer"); | ||
/** | ||
* Note: This lexer intentionally *only* recognizes inline tags and code blocks. | ||
* This is because it is intended for use on markdown documents, and we shouldn't | ||
* take some stray `@user` mention within a "Thanks" section of someone's changelog | ||
* as starting a block! | ||
*/ | ||
function* lexCommentString(file) { | ||
@@ -9,3 +15,4 @@ // Wrapper around our real lex function to collapse adjacent text tokens. | ||
for (const token of lexCommentString2(file)) { | ||
if (token.kind === lexer_1.TokenSyntaxKind.Text) { | ||
if (token.kind === lexer_1.TokenSyntaxKind.Text || | ||
token.kind === lexer_1.TokenSyntaxKind.NewLine) { | ||
if (textToken) { | ||
@@ -15,2 +22,3 @@ textToken.text += token.text; | ||
else { | ||
token.kind = lexer_1.TokenSyntaxKind.Text; | ||
textToken = token; | ||
@@ -32,3 +40,2 @@ } | ||
} | ||
exports.lexCommentString = lexCommentString; | ||
function* lexCommentString2(file) { | ||
@@ -46,3 +53,3 @@ let pos = 0; | ||
let lineStart = true; | ||
let braceStartsType = false; | ||
let expectingTag = false; | ||
for (;;) { | ||
@@ -59,15 +66,11 @@ if (pos >= end) { | ||
lineStart = true; | ||
expectingTag = false; | ||
break; | ||
case "{": | ||
if (braceStartsType && nextNonWs(pos + 1) !== "@") { | ||
yield makeToken(lexer_1.TokenSyntaxKind.TypeAnnotation, findEndOfType(pos) - pos); | ||
braceStartsType = false; | ||
} | ||
else { | ||
yield makeToken(lexer_1.TokenSyntaxKind.OpenBrace, 1); | ||
} | ||
yield makeToken(lexer_1.TokenSyntaxKind.OpenBrace, 1); | ||
expectingTag = true; | ||
break; | ||
case "}": | ||
yield makeToken(lexer_1.TokenSyntaxKind.CloseBrace, 1); | ||
braceStartsType = false; | ||
expectingTag = false; | ||
break; | ||
@@ -80,3 +83,2 @@ case "`": { | ||
// We don't quite handle #2 correctly yet. PR welcome! | ||
braceStartsType = false; | ||
let tickCount = 1; | ||
@@ -100,2 +102,3 @@ let lookahead = pos; | ||
}; | ||
expectingTag = false; | ||
pos = lookahead; | ||
@@ -132,2 +135,3 @@ break; | ||
}; | ||
expectingTag = false; | ||
pos = lookahead; | ||
@@ -137,2 +141,3 @@ } | ||
yield makeToken(lexer_1.TokenSyntaxKind.Text, tickCount); | ||
expectingTag = false; | ||
} | ||
@@ -153,5 +158,5 @@ } | ||
} | ||
if (lookahead !== pos + 1 && | ||
if (expectingTag && | ||
lookahead !== pos + 1 && | ||
(lookahead === end || /[\s}]/.test(file[lookahead]))) { | ||
braceStartsType = true; | ||
yield makeToken(lexer_1.TokenSyntaxKind.Tag, lookahead - pos); | ||
@@ -186,3 +191,3 @@ break; | ||
if (textParts.some((part) => /\S/.test(part))) { | ||
braceStartsType = false; | ||
expectingTag = false; | ||
} | ||
@@ -215,56 +220,2 @@ // This piece of text had line continuations or escaped text | ||
} | ||
function findEndOfType(pos) { | ||
let openBraces = 0; | ||
while (pos < end) { | ||
if (file[pos] === "{") { | ||
openBraces++; | ||
} | ||
else if (file[pos] === "}") { | ||
if (--openBraces === 0) { | ||
break; | ||
} | ||
} | ||
else if ("`'\"".includes(file[pos])) { | ||
pos = findEndOfString(pos); | ||
} | ||
pos++; | ||
} | ||
if (pos < end && file[pos] === "}") { | ||
pos++; | ||
} | ||
return pos; | ||
} | ||
function findEndOfString(pos) { | ||
const endOfString = file[pos]; | ||
pos++; | ||
while (pos < end) { | ||
if (file[pos] === endOfString) { | ||
break; | ||
} | ||
else if (file[pos] === "\\") { | ||
pos++; // Skip escaped character | ||
} | ||
else if (endOfString === "`" && | ||
file[pos] === "$" && | ||
file[pos + 1] === "{") { | ||
// Template literal with data inside a ${} | ||
while (pos < end && file[pos] !== "}") { | ||
if ("`'\"".includes(file[pos])) { | ||
pos = findEndOfString(pos) + 1; | ||
} | ||
else { | ||
pos++; | ||
} | ||
} | ||
} | ||
pos++; | ||
} | ||
return pos; | ||
} | ||
function nextNonWs(pos) { | ||
while (pos < end && /\s/.test(file[pos])) { | ||
pos++; | ||
} | ||
return file[pos]; | ||
} | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extractTagName = void 0; | ||
exports.extractTagName = extractTagName; | ||
/** | ||
@@ -53,3 +53,2 @@ * Determines the name of the parameter/template/property from the tag content | ||
} | ||
exports.extractTagName = extractTagName; | ||
function skipWs(text, pos) { | ||
@@ -56,0 +55,0 @@ return skipWith(text, pos, /\s/); |
import ts from "typescript"; | ||
import { Reflection, ProjectReflection, DeclarationReflection, ReflectionKind } from "../models/index"; | ||
import { type Reflection, type ProjectReflection, DeclarationReflection, ReflectionKind, type DocumentReflection } from "../models/index"; | ||
import type { Converter } from "./converter"; | ||
import type { TranslationProxy } from "../internationalization/internationalization"; | ||
/** | ||
@@ -17,2 +18,6 @@ * The context describes the current state the converter is in. | ||
/** | ||
* Translation interface for log messages. | ||
*/ | ||
get i18n(): TranslationProxy; | ||
/** | ||
* The program currently being converted. | ||
@@ -60,3 +65,3 @@ * Accessing this property will throw if a source file is not currently being converted. | ||
finalizeDeclarationReflection(reflection: DeclarationReflection): void; | ||
addChild(reflection: DeclarationReflection): void; | ||
addChild(reflection: DeclarationReflection | DocumentReflection): void; | ||
shouldIgnore(symbol: ts.Symbol): boolean; | ||
@@ -63,0 +68,0 @@ /** |
@@ -26,2 +26,8 @@ "use strict"; | ||
/** | ||
* Translation interface for log messages. | ||
*/ | ||
get i18n() { | ||
return this.converter.application.i18n; | ||
} | ||
/** | ||
* The program currently being converted. | ||
@@ -143,4 +149,3 @@ * Accessing this property will throw if a source file is not currently being converted. | ||
if (this.scope instanceof index_1.ContainerReflection) { | ||
this.scope.children ??= []; | ||
this.scope.children.push(reflection); | ||
this.scope.addChild(reflection); | ||
} | ||
@@ -147,0 +152,0 @@ } |
@@ -6,3 +6,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.convertExpression = exports.convertDefaultValue = void 0; | ||
exports.convertDefaultValue = convertDefaultValue; | ||
exports.convertExpression = convertExpression; | ||
const typescript_1 = __importDefault(require("typescript")); | ||
@@ -24,3 +25,2 @@ /** | ||
} | ||
exports.convertDefaultValue = convertDefaultValue; | ||
function convertExpression(expression) { | ||
@@ -62,2 +62,1 @@ switch (expression.kind) { | ||
} | ||
exports.convertExpression = convertExpression; |
import ts from "typescript"; | ||
import type { Application } from "../application"; | ||
import { Comment, CommentDisplayPart, ProjectReflection, Reflection, ReflectionSymbolId, SomeType } from "../models/index"; | ||
import { Comment, type CommentDisplayPart, ProjectReflection, type Reflection, type ReflectionSymbolId, type SomeType } from "../models/index"; | ||
import { Context } from "./context"; | ||
@@ -11,3 +11,3 @@ import { ConverterComponent } from "./components"; | ||
import type { CommentStyle, ValidationOptions } from "../utils/options/declaration"; | ||
import { ExternalSymbolResolver, ExternalResolveResult } from "./comments/linkResolver"; | ||
import { type ExternalSymbolResolver, type ExternalResolveResult } from "./comments/linkResolver"; | ||
import type { DeclarationReference } from "./comments/declarationReference"; | ||
@@ -118,2 +118,4 @@ /** | ||
/** @internal */ | ||
addProjectDocuments(project: ProjectReflection): void; | ||
/** @internal */ | ||
convertSymbol(context: Context, symbol: ts.Symbol, exportSymbol?: ts.Symbol): void; | ||
@@ -131,3 +133,6 @@ /** | ||
*/ | ||
parseRawComment(file: MinimalSourceFile): Comment; | ||
parseRawComment(file: MinimalSourceFile): { | ||
content: CommentDisplayPart[]; | ||
frontmatter: Record<string, unknown>; | ||
}; | ||
/** | ||
@@ -134,0 +139,0 @@ * Adds a new resolver that the theme can use to try to figure out how to link to a symbol declared |
@@ -211,2 +211,3 @@ "use strict"; | ||
this.trigger(Converter.EVENT_BEGIN, context); | ||
this.addProjectDocuments(project); | ||
this.compile(entryPoints, context); | ||
@@ -219,2 +220,13 @@ this.resolve(context); | ||
/** @internal */ | ||
addProjectDocuments(project) { | ||
const projectDocuments = (0, utils_1.getDocumentEntryPoints)(this.application.logger, this.application.options); | ||
for (const { displayName, path } of projectDocuments) { | ||
const file = new utils_1.MinimalSourceFile((0, utils_1.readFile)(path), path); | ||
const { content, frontmatter } = this.parseRawComment(file); | ||
const docRefl = new index_1.DocumentReflection(displayName, project, content, frontmatter); | ||
project.addChild(docRefl); | ||
project.registerReflection(docRefl); | ||
} | ||
} | ||
/** @internal */ | ||
convertSymbol(context, symbol, exportSymbol) { | ||
@@ -237,3 +249,3 @@ (0, symbols_1.convertSymbol)(context, symbol, exportSymbol); | ||
parseRawComment(file) { | ||
return (0, parser_1.parseComment)((0, rawLexer_1.lexCommentString)(file.text), this.config, file, this.application.logger); | ||
return (0, parser_1.parseCommentString)((0, rawLexer_1.lexCommentString)(file.text), this.config, file, this.application.logger); | ||
} | ||
@@ -320,11 +332,4 @@ /** | ||
const readme = (0, utils_1.readFile)(entryPoint.readmeFile); | ||
const comment = this.parseRawComment(new utils_1.MinimalSourceFile(readme, entryPoint.readmeFile)); | ||
if (comment.blockTags.length || comment.modifierTags.size) { | ||
const ignored = [ | ||
...comment.blockTags.map((tag) => tag.tag), | ||
...comment.modifierTags, | ||
]; | ||
context.logger.warn(`Block and modifier tags will be ignored within the readme:\n\t${ignored.join("\n\t")}`); | ||
} | ||
reflection.readme = comment.summary; | ||
const { content } = this.parseRawComment(new utils_1.MinimalSourceFile(readme, entryPoint.readmeFile)); | ||
reflection.readme = content; | ||
} | ||
@@ -518,5 +523,3 @@ reflection.packageVersion = entryPoint.version; | ||
.getSymbolsInScope(node, typescript_1.default.SymbolFlags.ModuleMember) | ||
.filter((s) => s | ||
.getDeclarations() | ||
?.some((d) => d.getSourceFile() === sourceFile)); | ||
.filter((s) => s.getDeclarations()?.some((d) => d.getSourceFile() === sourceFile)); | ||
// Detect declaration files with declare module "foo" as their only export | ||
@@ -523,0 +526,0 @@ // and lift that up one level as the source file symbol |
import ts from "typescript"; | ||
import type { Context } from "../context"; | ||
export declare function convertIndexSignature(context: Context, symbol: ts.Symbol): void; | ||
export declare function convertIndexSignatures(context: Context, symbol: ts.Symbol): void; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.convertIndexSignature = void 0; | ||
exports.convertIndexSignatures = convertIndexSignatures; | ||
const assert_1 = __importDefault(require("assert")); | ||
@@ -12,16 +12,13 @@ const typescript_1 = __importDefault(require("typescript")); | ||
const converter_events_1 = require("../converter-events"); | ||
function convertIndexSignature(context, symbol) { | ||
function convertIndexSignatures(context, symbol) { | ||
(0, assert_1.default)(context.scope instanceof models_1.DeclarationReflection); | ||
const indexSymbol = symbol.members?.get("__index"); | ||
if (indexSymbol) { | ||
// Right now TypeDoc models don't have a way to distinguish between string | ||
// and number index signatures... { [x: string]: 1 | 2; [x: number]: 2 } | ||
// will be misrepresented. | ||
const indexDeclaration = indexSymbol.getDeclarations()?.[0]; | ||
(0, assert_1.default)(indexDeclaration && | ||
typescript_1.default.isIndexSignatureDeclaration(indexDeclaration)); | ||
if (!indexSymbol) | ||
return; | ||
for (const indexDeclaration of indexSymbol.getDeclarations() || []) { | ||
(0, assert_1.default)(typescript_1.default.isIndexSignatureDeclaration(indexDeclaration)); | ||
const param = indexDeclaration.parameters[0]; | ||
(0, assert_1.default)(param && typescript_1.default.isParameter(param)); | ||
const index = new models_1.SignatureReflection("__index", models_1.ReflectionKind.IndexSignature, context.scope); | ||
index.comment = context.getComment(indexSymbol, index.kind); | ||
index.comment = context.getNodeComment(indexDeclaration, index.kind); | ||
index.parameters = [ | ||
@@ -33,6 +30,6 @@ new models_1.ParameterReflection(param.name.getText(), models_1.ReflectionKind.Parameter, index), | ||
context.registerReflection(index, indexSymbol); | ||
context.scope.indexSignature = index; | ||
context.scope.indexSignatures ||= []; | ||
context.scope.indexSignatures.push(index); | ||
context.trigger(converter_events_1.ConverterEvents.CREATE_SIGNATURE, index, indexDeclaration); | ||
} | ||
} | ||
exports.convertIndexSignature = convertIndexSignature; |
import ts from "typescript"; | ||
import { ParameterReflection, Reflection, ReflectionKind, SignatureReflection, TypeParameterReflection } from "../../models"; | ||
import { ParameterReflection, type Reflection, ReflectionKind, SignatureReflection, TypeParameterReflection } from "../../models"; | ||
import type { Context } from "../context"; | ||
@@ -4,0 +4,0 @@ export declare function createSignature(context: Context, kind: ReflectionKind.CallSignature | ReflectionKind.ConstructorSignature | ReflectionKind.GetSignature | ReflectionKind.SetSignature, signature: ts.Signature, symbol: ts.Symbol | undefined, declaration?: ts.SignatureDeclaration | ts.JSDocSignature): void; |
@@ -6,3 +6,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.convertTemplateParameterNodes = exports.createTypeParamReflection = exports.convertTypeParameterNodes = exports.convertParameterNodes = exports.createConstructSignatureWithType = exports.createSignature = void 0; | ||
exports.createSignature = createSignature; | ||
exports.createConstructSignatureWithType = createConstructSignatureWithType; | ||
exports.convertParameterNodes = convertParameterNodes; | ||
exports.convertTypeParameterNodes = convertTypeParameterNodes; | ||
exports.createTypeParamReflection = createTypeParamReflection; | ||
exports.convertTemplateParameterNodes = convertTemplateParameterNodes; | ||
const typescript_1 = __importDefault(require("typescript")); | ||
@@ -38,7 +43,7 @@ const assert_1 = __importDefault(require("assert")); | ||
} | ||
if (declaration && | ||
(!parentReflection.comment || | ||
!(parentReflection.conversionFlags & | ||
models_1.ConversionFlags.VariableOrPropertySource))) { | ||
sigRef.comment = context.getSignatureComment(declaration); | ||
if (declaration) { | ||
const sigComment = context.getSignatureComment(declaration); | ||
if (parentReflection.comment?.discoveryId !== sigComment?.discoveryId) { | ||
sigRef.comment = sigComment; | ||
} | ||
} | ||
@@ -81,3 +86,2 @@ sigRef.typeParameters = convertTypeParameters(sigRefCtx, sigRef, signature.typeParameters); | ||
} | ||
exports.createSignature = createSignature; | ||
/** | ||
@@ -101,3 +105,2 @@ * Special cased constructor factory for functions tagged with `@class` | ||
} | ||
exports.createConstructSignatureWithType = createConstructSignatureWithType; | ||
function convertParameters(context, sigRef, parameters, parameterNodes) { | ||
@@ -186,3 +189,2 @@ return parameters.map((param, i) => { | ||
} | ||
exports.convertParameterNodes = convertParameterNodes; | ||
function checkForDestructuredParameterDefaults(param, decl) { | ||
@@ -234,3 +236,2 @@ if (!decl || !typescript_1.default.isParameter(decl)) | ||
} | ||
exports.convertTypeParameterNodes = convertTypeParameterNodes; | ||
function createTypeParamReflection(param, context) { | ||
@@ -255,3 +256,2 @@ const paramRefl = new models_1.TypeParameterReflection(param.name.text, context.scope, getVariance(param.modifiers)); | ||
} | ||
exports.createTypeParamReflection = createTypeParamReflection; | ||
function convertTemplateParameterNodes(context, nodes) { | ||
@@ -281,3 +281,2 @@ return nodes?.flatMap((node) => { | ||
} | ||
exports.convertTemplateParameterNodes = convertTemplateParameterNodes; | ||
function getVariance(modifiers) { | ||
@@ -284,0 +283,0 @@ const hasIn = modifiers?.some((mod) => mod.kind === typescript_1.default.SyntaxKind.InKeyword); |
@@ -9,3 +9,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.convertJsDocCallback = exports.convertJsDocAlias = void 0; | ||
exports.convertJsDocAlias = convertJsDocAlias; | ||
exports.convertJsDocCallback = convertJsDocCallback; | ||
const assert_1 = require("assert"); | ||
@@ -37,3 +38,2 @@ const typescript_1 = __importDefault(require("typescript")); | ||
} | ||
exports.convertJsDocAlias = convertJsDocAlias; | ||
function convertJsDocCallback(context, symbol, declaration, exportSymbol) { | ||
@@ -47,3 +47,2 @@ const alias = context.createDeclarationReflection(models_1.ReflectionKind.TypeAlias, symbol, exportSymbol); | ||
} | ||
exports.convertJsDocCallback = convertJsDocCallback; | ||
function convertJsDocInterface(context, declaration, symbol, exportSymbol) { | ||
@@ -50,0 +49,0 @@ const reflection = context.createDeclarationReflection(models_1.ReflectionKind.Interface, symbol, exportSymbol); |
@@ -1,2 +0,2 @@ | ||
import { DeclarationReflection } from "../../models"; | ||
import { type DeclarationReflection, type DocumentReflection } from "../../models"; | ||
import { ConverterComponent } from "../components"; | ||
@@ -9,3 +9,3 @@ /** | ||
export declare class CategoryPlugin extends ConverterComponent { | ||
sortFunction: (reflections: DeclarationReflection[]) => void; | ||
sortFunction: (reflections: Array<DeclarationReflection | DocumentReflection>) => void; | ||
accessor defaultCategory: string; | ||
@@ -62,3 +62,3 @@ accessor categoryOrder: string[]; | ||
private static sortCatCallback; | ||
static getCategories(reflection: DeclarationReflection): Set<string>; | ||
static getCategories(reflection: DeclarationReflection | DocumentReflection): Set<string>; | ||
} |
@@ -141,4 +141,3 @@ "use strict"; | ||
if (unusedBoosts.size) { | ||
context.logger.warn(`Not all categories specified in searchCategoryBoosts were used in the documentation.` + | ||
` The unused categories were:\n\t${Array.from(unusedBoosts).join("\n\t")}`); | ||
context.logger.warn(context.i18n.not_all_search_category_boosts_used_0(Array.from(unusedBoosts).join("\n\t"))); | ||
} | ||
@@ -222,3 +221,3 @@ } | ||
else { | ||
this.application.logger.warn(`Comment for ${parent.getFriendlyFullName()} includes @categoryDescription for "${header}", but no child is placed in that category.`); | ||
this.application.logger.warn(this.application.i18n.comment_for_0_includes_categoryDescription_for_1_but_no_child_in_group(parent.getFriendlyFullName(), header)); | ||
} | ||
@@ -247,11 +246,17 @@ return true; | ||
reflection.comment?.removeTags("@category"); | ||
for (const sig of reflection.getNonIndexSignatures()) { | ||
sig.comment?.removeTags("@category"); | ||
} | ||
if (reflection.type?.type === "reflection") { | ||
reflection.type.declaration.comment?.removeTags("@category"); | ||
for (const sig of reflection.type.declaration.getNonIndexSignatures()) { | ||
if (reflection.isDeclaration()) { | ||
for (const sig of reflection.getNonIndexSignatures()) { | ||
sig.comment?.removeTags("@category"); | ||
} | ||
if (reflection.type?.type === "reflection") { | ||
reflection.type.declaration.comment?.removeTags("@category"); | ||
for (const sig of reflection.type.declaration.getNonIndexSignatures()) { | ||
sig.comment?.removeTags("@category"); | ||
} | ||
} | ||
} | ||
if (reflection.isDocument() && "category" in reflection.frontmatter) { | ||
categories.add(String(reflection.frontmatter["category"])); | ||
delete reflection.frontmatter["category"]; | ||
} | ||
categories.delete(""); | ||
@@ -306,10 +311,12 @@ for (const cat of categories) { | ||
discoverCategories(reflection.comment); | ||
for (const sig of reflection.getNonIndexSignatures()) { | ||
discoverCategories(sig.comment); | ||
} | ||
if (reflection.type?.type === "reflection") { | ||
discoverCategories(reflection.type.declaration.comment); | ||
for (const sig of reflection.type.declaration.getNonIndexSignatures()) { | ||
if (reflection.isDeclaration()) { | ||
for (const sig of reflection.getNonIndexSignatures()) { | ||
discoverCategories(sig.comment); | ||
} | ||
if (reflection.type?.type === "reflection") { | ||
discoverCategories(reflection.type.declaration.comment); | ||
for (const sig of reflection.type.declaration.getNonIndexSignatures()) { | ||
discoverCategories(sig.comment); | ||
} | ||
} | ||
} | ||
@@ -316,0 +323,0 @@ categories.delete(""); |
@@ -115,3 +115,3 @@ import { ConverterComponent } from "../components"; | ||
private onResolve; | ||
private moveCommentToSignatures; | ||
private moveSignatureParamComments; | ||
private removeExcludedTags; | ||
@@ -118,0 +118,0 @@ /** |
@@ -284,2 +284,3 @@ "use strict"; | ||
reflection.comment = new models_1.Comment(tag.content); | ||
reflection.comment.sourcePath = comment.sourcePath; | ||
(0, utils_1.removeIfPresent)(comment.blockTags, tag); | ||
@@ -370,4 +371,3 @@ } | ||
!/[A-Z_][A-Z0-9_]/.test(reflection.comment.label)) { | ||
context.logger.warn(`The label "${reflection.comment.label}" for ${reflection.getFriendlyFullName()} cannot be referenced with a declaration reference. ` + | ||
`Labels may only contain A-Z, 0-9, and _, and may not start with a number.`); | ||
context.logger.warn(context.i18n.label_0_for_1_cannot_be_referenced(reflection.comment.label, reflection.getFriendlyFullName())); | ||
} | ||
@@ -377,70 +377,58 @@ mergeSeeTags(reflection.comment); | ||
} | ||
if (!(reflection instanceof models_1.DeclarationReflection)) { | ||
return; | ||
if (reflection instanceof models_1.DeclarationReflection && reflection.comment) { | ||
let sigs; | ||
if (reflection.type instanceof models_1.ReflectionType) { | ||
sigs = reflection.type.declaration.getNonIndexSignatures(); | ||
} | ||
else { | ||
sigs = reflection.getNonIndexSignatures(); | ||
} | ||
// For variables and properties, the symbol might own the comment but we might also | ||
// have @param and @returns comments for an owned signature. Only do this if there is | ||
// exactly one signature as otherwise we have no hope of doing validation right. | ||
if (sigs.length === 1 && !sigs[0].comment) { | ||
this.moveSignatureParamComments(sigs[0], reflection.comment); | ||
const returnsTag = reflection.comment.getTag("@returns"); | ||
if (returnsTag) { | ||
sigs[0].comment = new models_1.Comment(); | ||
sigs[0].comment.sourcePath = reflection.comment.sourcePath; | ||
sigs[0].comment.blockTags.push(returnsTag); | ||
reflection.comment.removeTags("@returns"); | ||
} | ||
} | ||
} | ||
if (reflection.type instanceof models_1.ReflectionType) { | ||
this.moveCommentToSignatures(reflection, reflection.type.declaration.getNonIndexSignatures()); | ||
if (reflection instanceof models_1.SignatureReflection) { | ||
this.moveSignatureParamComments(reflection); | ||
} | ||
else { | ||
this.moveCommentToSignatures(reflection, reflection.getNonIndexSignatures()); | ||
} | ||
} | ||
moveCommentToSignatures(reflection, signatures) { | ||
if (!signatures.length) { | ||
moveSignatureParamComments(signature, comment = signature.comment) { | ||
if (!comment) | ||
return; | ||
} | ||
const comment = reflection.kindOf(models_1.ReflectionKind.ClassOrInterface) | ||
? undefined | ||
: reflection.comment; | ||
for (const signature of signatures) { | ||
const signatureHadOwnComment = !!signature.comment; | ||
const childComment = (signature.comment ||= comment?.clone()); | ||
if (!childComment) | ||
continue; | ||
signature.parameters?.forEach((parameter, index) => { | ||
if (parameter.name === "__namedParameters") { | ||
const commentParams = childComment.blockTags.filter((tag) => tag.tag === "@param" && !tag.name?.includes(".")); | ||
if (signature.parameters?.length === commentParams.length && | ||
commentParams[index].name) { | ||
parameter.name = commentParams[index].name; | ||
} | ||
signature.parameters?.forEach((parameter, index) => { | ||
if (parameter.name === "__namedParameters") { | ||
const commentParams = comment.blockTags.filter((tag) => tag.tag === "@param" && !tag.name?.includes(".")); | ||
if (signature.parameters?.length === commentParams.length && | ||
commentParams[index].name) { | ||
parameter.name = commentParams[index].name; | ||
} | ||
const tag = childComment.getIdentifiedTag(parameter.name, "@param"); | ||
if (tag) { | ||
parameter.comment = new models_1.Comment(models_1.Comment.cloneDisplayParts(tag.content)); | ||
} | ||
}); | ||
for (const parameter of signature.typeParameters || []) { | ||
const tag = childComment.getIdentifiedTag(parameter.name, "@typeParam") || | ||
childComment.getIdentifiedTag(parameter.name, "@template") || | ||
childComment.getIdentifiedTag(`<${parameter.name}>`, "@param"); | ||
if (tag) { | ||
parameter.comment = new models_1.Comment(models_1.Comment.cloneDisplayParts(tag.content)); | ||
} | ||
} | ||
this.validateParamTags(signature, childComment, signature.parameters || [], signatureHadOwnComment); | ||
childComment?.removeTags("@param"); | ||
childComment?.removeTags("@typeParam"); | ||
childComment?.removeTags("@template"); | ||
} | ||
// Since this reflection has signatures, we need to remove the comment from the non-primary | ||
// declaration location. For functions/methods/constructors, this means removing it from | ||
// the wrapping reflection. For type aliases, classes, and interfaces, this means removing | ||
// it from the contained signatures... if it's the same as what is on the signature. | ||
// This is important so that in type aliases we don't end up with a comment rendered twice. | ||
if (reflection.kindOf(models_1.ReflectionKind.SignatureContainer)) { | ||
delete reflection.comment; | ||
} | ||
else { | ||
reflection.comment?.removeTags("@param"); | ||
reflection.comment?.removeTags("@typeParam"); | ||
reflection.comment?.removeTags("@template"); | ||
const parentComment = models_1.Comment.combineDisplayParts(reflection.comment?.summary); | ||
for (const sig of signatures) { | ||
if (models_1.Comment.combineDisplayParts(sig.comment?.summary) === | ||
parentComment) { | ||
delete sig.comment; | ||
} | ||
const tag = comment.getIdentifiedTag(parameter.name, "@param"); | ||
if (tag) { | ||
parameter.comment = new models_1.Comment(models_1.Comment.cloneDisplayParts(tag.content)); | ||
parameter.comment.sourcePath = comment.sourcePath; | ||
} | ||
}); | ||
for (const parameter of signature.typeParameters || []) { | ||
const tag = comment.getIdentifiedTag(parameter.name, "@typeParam") || | ||
comment.getIdentifiedTag(parameter.name, "@template") || | ||
comment.getIdentifiedTag(`<${parameter.name}>`, "@param"); | ||
if (tag) { | ||
parameter.comment = new models_1.Comment(models_1.Comment.cloneDisplayParts(tag.content)); | ||
parameter.comment.sourcePath = comment.sourcePath; | ||
} | ||
} | ||
this.validateParamTags(signature, comment, signature.parameters || []); | ||
comment.removeTags("@param"); | ||
comment.removeTags("@typeParam"); | ||
comment.removeTags("@template"); | ||
} | ||
@@ -540,9 +528,9 @@ removeExcludedTags(comment) { | ||
} | ||
validateParamTags(signature, comment, params, signatureHadOwnComment) { | ||
validateParamTags(signature, comment, params) { | ||
const paramTags = comment.blockTags.filter((tag) => tag.tag === "@param"); | ||
(0, utils_1.removeIf)(paramTags, (tag) => params.some((param) => param.name === tag.name)); | ||
moveNestedParamTags(/* in-out */ paramTags, params); | ||
if (signatureHadOwnComment && paramTags.length) { | ||
moveNestedParamTags(/* in-out */ paramTags, params, comment.sourcePath); | ||
if (paramTags.length) { | ||
for (const tag of paramTags) { | ||
this.application.logger.warn(`The signature ${signature.getFriendlyFullName()} has an @param with name "${tag.name}", which was not used.`); | ||
this.application.logger.warn(this.application.i18n.signature_0_has_unused_param_with_name_1(signature.getFriendlyFullName(), tag.name ?? "(missing)")); | ||
} | ||
@@ -595,3 +583,3 @@ } | ||
function moveNestedParamTags( | ||
/* in-out */ paramTags, parameters) { | ||
/* in-out */ paramTags, parameters, sourcePath) { | ||
const used = new Set(); | ||
@@ -608,2 +596,3 @@ for (const param of parameters) { | ||
child.comment = new models_1.Comment(models_1.Comment.cloneDisplayParts(tag.content)); | ||
child.comment.sourcePath = sourcePath; | ||
used.add(paramTags.indexOf(tag)); | ||
@@ -640,5 +629,7 @@ } | ||
child.comment = new models_1.Comment(models_1.Comment.cloneDisplayParts(prop.content)); | ||
child.comment.sourcePath = comment.sourcePath; | ||
if (child instanceof models_1.DeclarationReflection && child.signatures) { | ||
for (const sig of child.signatures) { | ||
sig.comment = new models_1.Comment(models_1.Comment.cloneDisplayParts(prop.content)); | ||
sig.comment.sourcePath = comment.sourcePath; | ||
} | ||
@@ -645,0 +636,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { ContainerReflection, DeclarationReflection } from "../../models/reflections/index"; | ||
import { ContainerReflection, type DeclarationReflection, type DocumentReflection } from "../../models/reflections/index"; | ||
import { ReflectionGroup } from "../../models/ReflectionGroup"; | ||
@@ -10,3 +10,3 @@ import { ConverterComponent } from "../components"; | ||
export declare class GroupPlugin extends ConverterComponent { | ||
sortFunction: (reflections: DeclarationReflection[]) => void; | ||
sortFunction: (reflections: Array<DeclarationReflection | DocumentReflection>) => void; | ||
accessor boosts: Record<string, number>; | ||
@@ -34,3 +34,3 @@ accessor groupOrder: string[]; | ||
*/ | ||
getGroups(reflection: DeclarationReflection): Set<string>; | ||
getGroups(reflection: DeclarationReflection | DocumentReflection): Set<string>; | ||
/** | ||
@@ -44,3 +44,3 @@ * Create a grouped representation of the given list of reflections. | ||
*/ | ||
getReflectionGroups(parent: ContainerReflection, reflections: DeclarationReflection[]): ReflectionGroup[]; | ||
getReflectionGroups(parent: ContainerReflection, reflections: Array<DeclarationReflection | DocumentReflection>): ReflectionGroup[]; | ||
/** | ||
@@ -47,0 +47,0 @@ * Callback used to sort groups by name. |
@@ -60,2 +60,22 @@ "use strict"; | ||
const models_1 = require("../../models"); | ||
// Same as the defaultKindSortOrder in sort.ts | ||
const defaultGroupOrder = [ | ||
index_1.ReflectionKind.Document, | ||
index_1.ReflectionKind.Reference, | ||
// project is never a child so never added to a group | ||
index_1.ReflectionKind.Module, | ||
index_1.ReflectionKind.Namespace, | ||
index_1.ReflectionKind.Enum, | ||
index_1.ReflectionKind.EnumMember, | ||
index_1.ReflectionKind.Class, | ||
index_1.ReflectionKind.Interface, | ||
index_1.ReflectionKind.TypeAlias, | ||
index_1.ReflectionKind.Constructor, | ||
index_1.ReflectionKind.Property, | ||
index_1.ReflectionKind.Variable, | ||
index_1.ReflectionKind.Function, | ||
index_1.ReflectionKind.Accessor, | ||
index_1.ReflectionKind.Method, | ||
// others are never added to groups | ||
]; | ||
/** | ||
@@ -104,2 +124,5 @@ * A handler that sorts and groups the found reflections in the resolving phase. | ||
GroupPlugin.WEIGHTS = this.groupOrder; | ||
if (GroupPlugin.WEIGHTS.length === 0) { | ||
GroupPlugin.WEIGHTS = defaultGroupOrder.map((kind) => this.application.internationalization.kindPluralString(kind)); | ||
} | ||
}, | ||
@@ -129,15 +152,20 @@ [converter_1.Converter.EVENT_RESOLVE_END]: this.onEndResolve, | ||
this.application.options.isSet("searchGroupBoosts")) { | ||
context.logger.warn(`Not all groups specified in searchGroupBoosts were used in the documentation.` + | ||
` The unused groups were:\n\t${Array.from(unusedBoosts).join("\n\t")}`); | ||
context.logger.warn(context.i18n.not_all_search_group_boosts_used_0(Array.from(unusedBoosts).join("\n\t"))); | ||
} | ||
} | ||
group(reflection) { | ||
if (reflection.children && | ||
reflection.children.length > 0 && | ||
!reflection.groups) { | ||
if (this.sortEntryPoints || | ||
!reflection.children.some((c) => c.kindOf(index_1.ReflectionKind.Module))) { | ||
this.sortFunction(reflection.children); | ||
if (reflection.childrenIncludingDocuments && !reflection.groups) { | ||
if (reflection.children) { | ||
if (this.sortEntryPoints || | ||
!reflection.children.some((c) => c.kindOf(index_1.ReflectionKind.Module))) { | ||
this.sortFunction(reflection.children); | ||
this.sortFunction(reflection.documents || []); | ||
this.sortFunction(reflection.childrenIncludingDocuments); | ||
} | ||
} | ||
reflection.groups = this.getReflectionGroups(reflection, reflection.children); | ||
else if (reflection.documents) { | ||
this.sortFunction(reflection.documents); | ||
this.sortFunction(reflection.childrenIncludingDocuments); | ||
} | ||
reflection.groups = this.getReflectionGroups(reflection, reflection.childrenIncludingDocuments); | ||
} | ||
@@ -164,15 +192,21 @@ } | ||
} | ||
extractGroupTags(reflection.comment); | ||
for (const sig of reflection.getNonIndexSignatures()) { | ||
extractGroupTags(sig.comment); | ||
} | ||
if (reflection.type?.type === "reflection") { | ||
extractGroupTags(reflection.type.declaration.comment); | ||
for (const sig of reflection.type.declaration.getNonIndexSignatures()) { | ||
if (reflection.isDeclaration()) { | ||
extractGroupTags(reflection.comment); | ||
for (const sig of reflection.getNonIndexSignatures()) { | ||
extractGroupTags(sig.comment); | ||
} | ||
if (reflection.type?.type === "reflection") { | ||
extractGroupTags(reflection.type.declaration.comment); | ||
for (const sig of reflection.type.declaration.getNonIndexSignatures()) { | ||
extractGroupTags(sig.comment); | ||
} | ||
} | ||
} | ||
if (reflection.isDocument() && "group" in reflection.frontmatter) { | ||
groups.add(String(reflection.frontmatter["group"])); | ||
delete reflection.frontmatter["group"]; | ||
} | ||
groups.delete(""); | ||
if (groups.size === 0) { | ||
groups.add(index_1.ReflectionKind.pluralString(reflection.kind)); | ||
groups.add(this.application.internationalization.kindPluralString(reflection.kind)); | ||
} | ||
@@ -217,3 +251,3 @@ for (const group of groups) { | ||
else { | ||
this.application.logger.warn(`Comment for ${parent.getFriendlyFullName()} includes @groupDescription for "${header}", but no child is placed in that group.`); | ||
this.application.logger.warn(this.application.i18n.comment_for_0_includes_groupDescription_for_1_but_no_child_in_group(parent.getFriendlyFullName(), header)); | ||
} | ||
@@ -220,0 +254,0 @@ return true; |
@@ -237,4 +237,3 @@ "use strict"; | ||
// We're probably broken... but I don't think this should be fatal. | ||
context.logger.warn(`Failed to retrieve${reflection.flags.isStatic ? " static" : ""} member "${reflection.escapedName ?? reflection.name}" of "${reflection.parent | ||
?.name}" for inheritance analysis. Please report a bug.`); | ||
context.logger.warn(`Failed to retrieve${reflection.flags.isStatic ? " static" : ""} member "${reflection.escapedName ?? reflection.name}" of "${reflection.parent?.name}" for inheritance analysis. Please report a bug.`); | ||
return; | ||
@@ -303,3 +302,5 @@ } | ||
link(reflection.setSignature); | ||
link(reflection.indexSignature); | ||
for (const sig of reflection.indexSignatures || []) { | ||
link(sig); | ||
} | ||
for (const sig of reflection.signatures ?? []) { | ||
@@ -306,0 +307,0 @@ link(sig); |
import { ConverterComponent } from "../components"; | ||
import { ValidationOptions } from "../../utils"; | ||
import { type ValidationOptions } from "../../utils"; | ||
/** | ||
@@ -4,0 +4,0 @@ * A plugin that handles `@inheritDoc` tags by copying documentation from another API item. |
@@ -113,3 +113,3 @@ "use strict"; | ||
if (!declRef || /\S/.test(source.substring(declRef[1]))) { | ||
this.application.logger.warn(`Declaration reference in @inheritDoc for ${reflection.getFriendlyFullName()} was not fully parsed and may resolve incorrectly.`); | ||
this.application.logger.warn(this.application.i18n.declaration_reference_in_inheritdoc_for_0_not_fully_parsed(reflection.getFriendlyFullName())); | ||
} | ||
@@ -140,3 +140,3 @@ let sourceRefl = declRef && (0, declarationReferenceResolver_1.resolveDeclarationReference)(reflection, declRef[0]); | ||
if (this.validation.invalidLink) { | ||
this.application.logger.warn(`Failed to find "${source}" to inherit the comment from in the comment for ${reflection.getFullName()}`); | ||
this.application.logger.warn(this.application.i18n.failed_to_find_0_to_inherit_comment_from_in_1(source, reflection.getFriendlyFullName())); | ||
} | ||
@@ -165,3 +165,3 @@ continue; | ||
if (!source.comment) { | ||
this.application.logger.warn(`${target.getFullName()} tried to copy a comment from ${source.getFullName()} with @inheritDoc, but the source has no associated comment.`); | ||
this.application.logger.warn(this.application.i18n.reflection_0_tried_to_copy_comment_from_1_but_source_had_no_comment(target.getFullName(), source.getFullName())); | ||
return; | ||
@@ -213,5 +213,3 @@ } | ||
parts.push(orig.name); | ||
this.application.logger.warn(`@inheritDoc specifies a circular inheritance chain: ${parts | ||
.reverse() | ||
.join(" -> ")}`); | ||
this.application.logger.warn(this.application.i18n.inheritdoc_circular_inheritance_chain_0(parts.reverse().join(" -> "))); | ||
}; | ||
@@ -242,2 +240,3 @@ for (const orig of this.dependencies.keys()) { | ||
t.comment = new models_1.Comment(s.comment?.summary); | ||
t.comment.sourcePath = s.comment?.sourcePath; | ||
} | ||
@@ -244,0 +243,0 @@ } |
import { ConverterComponent } from "../components"; | ||
import type { Context } from "../../converter"; | ||
import { ValidationOptions } from "../../utils"; | ||
import { ProjectReflection } from "../../models"; | ||
import { type ValidationOptions } from "../../utils"; | ||
import { type ProjectReflection } from "../../models"; | ||
/** | ||
@@ -6,0 +6,0 @@ * A plugin that resolves `{@link Foo}` tags. |
@@ -9,3 +9,2 @@ import { ConverterComponent } from "../components"; | ||
accessor readme: string; | ||
accessor stripYamlFrontmatter: boolean; | ||
accessor entryPointStrategy: EntryPointStrategy; | ||
@@ -29,5 +28,4 @@ accessor entryPoints: string[]; | ||
private onBegin; | ||
private processReadmeContents; | ||
private onBeginResolve; | ||
private addEntries; | ||
} |
@@ -90,3 +90,3 @@ "use strict"; | ||
let PackagePlugin = (() => { | ||
var _PackagePlugin_readme_accessor_storage, _PackagePlugin_stripYamlFrontmatter_accessor_storage, _PackagePlugin_entryPointStrategy_accessor_storage, _PackagePlugin_entryPoints_accessor_storage, _PackagePlugin_includeVersion_accessor_storage; | ||
var _PackagePlugin_readme_accessor_storage, _PackagePlugin_entryPointStrategy_accessor_storage, _PackagePlugin_entryPoints_accessor_storage, _PackagePlugin_includeVersion_accessor_storage; | ||
let _classDecorators = [(0, components_1.Component)({ name: "package" })]; | ||
@@ -100,5 +100,2 @@ let _classDescriptor; | ||
let _readme_extraInitializers = []; | ||
let _stripYamlFrontmatter_decorators; | ||
let _stripYamlFrontmatter_initializers = []; | ||
let _stripYamlFrontmatter_extraInitializers = []; | ||
let _entryPointStrategy_decorators; | ||
@@ -117,4 +114,3 @@ let _entryPointStrategy_initializers = []; | ||
_PackagePlugin_readme_accessor_storage.set(this, __runInitializers(this, _readme_initializers, void 0)); | ||
_PackagePlugin_stripYamlFrontmatter_accessor_storage.set(this, (__runInitializers(this, _readme_extraInitializers), __runInitializers(this, _stripYamlFrontmatter_initializers, void 0))); | ||
_PackagePlugin_entryPointStrategy_accessor_storage.set(this, (__runInitializers(this, _stripYamlFrontmatter_extraInitializers), __runInitializers(this, _entryPointStrategy_initializers, void 0))); | ||
_PackagePlugin_entryPointStrategy_accessor_storage.set(this, (__runInitializers(this, _readme_extraInitializers), __runInitializers(this, _entryPointStrategy_initializers, void 0))); | ||
_PackagePlugin_entryPoints_accessor_storage.set(this, (__runInitializers(this, _entryPointStrategy_extraInitializers), __runInitializers(this, _entryPoints_initializers, void 0))); | ||
@@ -129,4 +125,2 @@ _PackagePlugin_includeVersion_accessor_storage.set(this, (__runInitializers(this, _entryPoints_extraInitializers), __runInitializers(this, _includeVersion_initializers, void 0))); | ||
set readme(value) { __classPrivateFieldSet(this, _PackagePlugin_readme_accessor_storage, value, "f"); } | ||
get stripYamlFrontmatter() { return __classPrivateFieldGet(this, _PackagePlugin_stripYamlFrontmatter_accessor_storage, "f"); } | ||
set stripYamlFrontmatter(value) { __classPrivateFieldSet(this, _PackagePlugin_stripYamlFrontmatter_accessor_storage, value, "f"); } | ||
get entryPointStrategy() { return __classPrivateFieldGet(this, _PackagePlugin_entryPointStrategy_accessor_storage, "f"); } | ||
@@ -177,7 +171,7 @@ set entryPointStrategy(value) { __classPrivateFieldSet(this, _PackagePlugin_entryPointStrategy_accessor_storage, value, "f"); } | ||
try { | ||
this.readmeContents = this.processReadmeContents((0, utils_1.readFile)(this.readme)); | ||
this.readmeContents = (0, utils_1.readFile)(this.readme); | ||
this.readmeFile = this.readme; | ||
} | ||
catch { | ||
this.application.logger.error(`Provided README path, ${(0, paths_1.nicePath)(this.readme)} could not be read.`); | ||
this.application.logger.error(this.application.i18n.provided_readme_at_0_could_not_be_read((0, paths_1.nicePath)(this.readme))); | ||
} | ||
@@ -190,12 +184,6 @@ } | ||
this.readmeFile = result.file; | ||
this.readmeContents = this.processReadmeContents(result.content); | ||
this.readmeContents = result.content; | ||
} | ||
} | ||
} | ||
processReadmeContents(contents) { | ||
if (this.stripYamlFrontmatter) { | ||
return contents.replace(/^\s*---\r?\n[\s\S]*?\r?\n---\s*?\r?\n\s*/, ""); | ||
} | ||
return contents; | ||
} | ||
onBeginResolve(context) { | ||
@@ -206,11 +194,4 @@ this.addEntries(context.project); | ||
if (this.readmeFile && this.readmeContents) { | ||
const comment = this.application.converter.parseRawComment(new minimalSourceFile_1.MinimalSourceFile(this.readmeContents, this.readmeFile)); | ||
if (comment.blockTags.length || comment.modifierTags.size) { | ||
const ignored = [ | ||
...comment.blockTags.map((tag) => tag.tag), | ||
...comment.modifierTags, | ||
]; | ||
this.application.logger.warn(`Block and modifier tags will be ignored within the readme:\n\t${ignored.join("\n\t")}`); | ||
} | ||
project.readme = comment.summary; | ||
const { content } = this.application.converter.parseRawComment(new minimalSourceFile_1.MinimalSourceFile(this.readmeContents, this.readmeFile)); | ||
project.readme = content; | ||
} | ||
@@ -227,3 +208,3 @@ if (this.packageJson) { | ||
else if (!project.name) { | ||
this.application.logger.warn('The --name option was not specified, and no package.json was found. Defaulting project name to "Documentation".'); | ||
this.application.logger.warn(this.application.i18n.defaulting_project_name()); | ||
project.name = "Documentation"; | ||
@@ -234,3 +215,2 @@ } | ||
_PackagePlugin_readme_accessor_storage = new WeakMap(); | ||
_PackagePlugin_stripYamlFrontmatter_accessor_storage = new WeakMap(); | ||
_PackagePlugin_entryPointStrategy_accessor_storage = new WeakMap(); | ||
@@ -243,3 +223,2 @@ _PackagePlugin_entryPoints_accessor_storage = new WeakMap(); | ||
_readme_decorators = [(0, utils_1.Option)("readme")]; | ||
_stripYamlFrontmatter_decorators = [(0, utils_1.Option)("stripYamlFrontmatter")]; | ||
_entryPointStrategy_decorators = [(0, utils_1.Option)("entryPointStrategy")]; | ||
@@ -249,3 +228,2 @@ _entryPoints_decorators = [(0, utils_1.Option)("entryPoints")]; | ||
__esDecorate(_classThis, null, _readme_decorators, { kind: "accessor", name: "readme", static: false, private: false, access: { has: obj => "readme" in obj, get: obj => obj.readme, set: (obj, value) => { obj.readme = value; } }, metadata: _metadata }, _readme_initializers, _readme_extraInitializers); | ||
__esDecorate(_classThis, null, _stripYamlFrontmatter_decorators, { kind: "accessor", name: "stripYamlFrontmatter", static: false, private: false, access: { has: obj => "stripYamlFrontmatter" in obj, get: obj => obj.stripYamlFrontmatter, set: (obj, value) => { obj.stripYamlFrontmatter = value; } }, metadata: _metadata }, _stripYamlFrontmatter_initializers, _stripYamlFrontmatter_extraInitializers); | ||
__esDecorate(_classThis, null, _entryPointStrategy_decorators, { kind: "accessor", name: "entryPointStrategy", static: false, private: false, access: { has: obj => "entryPointStrategy" in obj, get: obj => obj.entryPointStrategy, set: (obj, value) => { obj.entryPointStrategy = value; } }, metadata: _metadata }, _entryPointStrategy_initializers, _entryPointStrategy_extraInitializers); | ||
@@ -252,0 +230,0 @@ __esDecorate(_classThis, null, _entryPoints_decorators, { kind: "accessor", name: "entryPoints", static: false, private: false, access: { has: obj => "entryPoints" in obj, get: obj => obj.entryPoints, set: (obj, value) => { obj.entryPoints = value; } }, metadata: _metadata }, _entryPoints_initializers, _entryPoints_extraInitializers); |
@@ -189,3 +189,3 @@ "use strict"; | ||
if (this.disableGit && !this.sourceLinkTemplate) { | ||
this.application.logger.error(`disableGit is set, but sourceLinkTemplate is not, so source links cannot be produced. Set a sourceLinkTemplate or disableSources to prevent source tracking.`); | ||
this.application.logger.error(context.i18n.disable_git_set_but_not_source_link_template()); | ||
return; | ||
@@ -196,3 +196,3 @@ } | ||
!this.gitRevision) { | ||
this.application.logger.warn(`disableGit is set and sourceLinkTemplate contains {gitRevision}, which will be replaced with an empty string as no revision was provided.`); | ||
this.application.logger.warn(context.i18n.disable_git_set_and_git_revision_used()); | ||
} | ||
@@ -199,0 +199,0 @@ const basePath = this.basePath || (0, utils_1.getCommonDirectory)([...this.fileNames]); |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.convertSymbol = void 0; | ||
exports.convertSymbol = convertSymbol; | ||
const assert_1 = __importDefault(require("assert")); | ||
@@ -18,2 +18,5 @@ const typescript_1 = __importDefault(require("typescript")); | ||
const reflections_1 = require("./utils/reflections"); | ||
const path_1 = require("path"); | ||
const utils_1 = require("../utils"); | ||
const paths_1 = require("../utils/paths"); | ||
const symbolConverters = { | ||
@@ -133,3 +136,2 @@ [typescript_1.default.SymbolFlags.RegularEnum]: convertEnum, | ||
} | ||
exports.convertSymbol = convertSymbol; | ||
function convertSymbols(context, symbols) { | ||
@@ -184,2 +186,24 @@ for (const symbol of symbols) { | ||
context.finalizeDeclarationReflection(reflection); | ||
let relativeTo = reflection.comment?.sourcePath; | ||
if (relativeTo) { | ||
relativeTo = (0, path_1.dirname)(relativeTo); | ||
const tags = reflection.comment?.getTags("@document") || []; | ||
reflection.comment?.removeTags("@document"); | ||
for (const tag of tags) { | ||
const path = models_1.Comment.combineDisplayParts(tag.content); | ||
let file; | ||
try { | ||
const resolved = (0, path_1.resolve)(relativeTo, path); | ||
file = new utils_1.MinimalSourceFile((0, utils_1.readFile)(resolved), resolved); | ||
} | ||
catch { | ||
context.logger.warn(context.logger.i18n.failed_to_read_0_when_processing_document_tag_in_1((0, paths_1.nicePath)(path), (0, paths_1.nicePath)(reflection.comment.sourcePath))); | ||
continue; | ||
} | ||
const { content, frontmatter } = context.converter.parseRawComment(file); | ||
const docRefl = new models_1.DocumentReflection((0, path_1.basename)(file.fileName).replace(/\.[^.]+$/, ""), reflection, content, frontmatter); | ||
reflection.addChild(docRefl); | ||
context.project.registerReflection(docRefl); | ||
} | ||
} | ||
} | ||
@@ -225,3 +249,3 @@ convertSymbols(context.withScope(reflection), context.checker | ||
if (type.getFlags() & typescript_1.default.TypeFlags.Union) { | ||
context.logger.warn(`Using @interface on a union type will discard properties not present on all branches of the union. TypeDoc's output may not accurately describe your source code.`, declaration); | ||
context.logger.warn(context.i18n.converting_union_as_interface(), declaration); | ||
} | ||
@@ -245,3 +269,3 @@ // Interfaces have properties | ||
// And finally, index signatures | ||
(0, index_signature_1.convertIndexSignature)(rc, symbol); | ||
(0, index_signature_1.convertIndexSignatures)(rc, symbol); | ||
} | ||
@@ -286,4 +310,2 @@ function convertFunctionOrMethod(context, symbol, exportSymbol) { | ||
const scope = context.withScope(reflection); | ||
// Can't use zip here. We might have less declarations than signatures | ||
// or less signatures than declarations. | ||
for (const sig of signatures) { | ||
@@ -366,3 +388,3 @@ (0, signature_1.createSignature)(scope, models_1.ReflectionKind.CallSignature, sig, symbol); | ||
// And finally, index signatures | ||
(0, index_signature_1.convertIndexSignature)(reflectionContext, symbol); | ||
(0, index_signature_1.convertIndexSignatures)(reflectionContext, symbol); | ||
// Normally this shouldn't matter, unless someone did something with skipLibCheck on. | ||
@@ -403,3 +425,2 @@ return typescript_1.default.SymbolFlags.Alias; | ||
: models_1.ReflectionKind.Property, symbol, exportSymbol); | ||
reflection.conversionFlags |= models_1.ConversionFlags.VariableOrPropertySource; | ||
const declaration = symbol.getDeclarations()?.[0]; | ||
@@ -571,3 +592,2 @@ let parameterType; | ||
setModifiers(symbol, accessDeclaration, reflection); | ||
reflection.conversionFlags |= models_1.ConversionFlags.VariableOrPropertySource; | ||
context.finalizeDeclarationReflection(reflection); | ||
@@ -604,3 +624,3 @@ const reflectionContext = context.withScope(reflection); | ||
if (!symbol.valueDeclaration) { | ||
context.logger.error(`No value declaration found when converting ${symbol.name} as a class`, symbol.declarations?.[0]); | ||
context.logger.error(context.i18n.converting_0_as_class_requires_value_declaration(symbol.name), symbol.declarations?.[0]); | ||
return; | ||
@@ -636,3 +656,3 @@ } | ||
else { | ||
context.logger.warn(`${reflection.getFriendlyFullName()} is being converted as a class, but does not have any construct signatures`, symbol.valueDeclaration); | ||
context.logger.warn(context.i18n.converting_0_as_class_without_construct_signatures(reflection.getFriendlyFullName()), symbol.valueDeclaration); | ||
} | ||
@@ -639,0 +659,0 @@ return (typescript_1.default.SymbolFlags.TypeAlias | |
import ts from "typescript"; | ||
import { SomeType } from "../models"; | ||
import { type SomeType } from "../models"; | ||
import type { Context } from "./context"; | ||
@@ -4,0 +4,0 @@ export interface TypeConverter<TNode extends ts.TypeNode = ts.TypeNode, TType extends ts.Type = ts.Type> { |
@@ -6,3 +6,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.convertType = exports.loadConverters = void 0; | ||
exports.loadConverters = loadConverters; | ||
exports.convertType = convertType; | ||
const assert_1 = __importDefault(require("assert")); | ||
@@ -65,3 +66,2 @@ const typescript_1 = __importDefault(require("typescript")); | ||
} | ||
exports.loadConverters = loadConverters; | ||
// This ought not be necessary, but we need some way to discover recursively | ||
@@ -127,3 +127,2 @@ // typed symbols which do not have type nodes. See the `recursive` symbol in the variables test. | ||
} | ||
exports.convertType = convertType; | ||
const arrayConverter = { | ||
@@ -387,3 +386,3 @@ kind: [typescript_1.default.SyntaxKind.ArrayType], | ||
} | ||
(0, index_signature_1.convertIndexSignature)(rc, symbol); | ||
(0, index_signature_1.convertIndexSignatures)(rc, symbol); | ||
return new models_1.ReflectionType(reflection); | ||
@@ -406,3 +405,3 @@ }, | ||
if (symbol) { | ||
(0, index_signature_1.convertIndexSignature)(context.withScope(reflection), symbol); | ||
(0, index_signature_1.convertIndexSignatures)(context.withScope(reflection), symbol); | ||
} | ||
@@ -409,0 +408,0 @@ return new models_1.ReflectionType(reflection); |
@@ -6,3 +6,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isObjectType = exports.getHeritageTypes = exports.isNamedNode = void 0; | ||
exports.isNamedNode = isNamedNode; | ||
exports.getHeritageTypes = getHeritageTypes; | ||
exports.isObjectType = isObjectType; | ||
const typescript_1 = __importDefault(require("typescript")); | ||
@@ -13,3 +15,2 @@ function isNamedNode(node) { | ||
} | ||
exports.isNamedNode = isNamedNode; | ||
function getHeritageTypes(declarations, kind) { | ||
@@ -29,6 +30,4 @@ const exprs = declarations.flatMap((d) => (d.heritageClauses ?? []) | ||
} | ||
exports.getHeritageTypes = getHeritageTypes; | ||
function isObjectType(type) { | ||
return typeof type.objectFlags === "number"; | ||
} | ||
exports.isObjectType = isObjectType; |
@@ -1,2 +0,2 @@ | ||
import { SomeType } from "../../models"; | ||
import { type SomeType } from "../../models"; | ||
export declare function removeUndefined(type: SomeType): SomeType; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeUndefined = void 0; | ||
exports.removeUndefined = removeUndefined; | ||
const models_1 = require("../../models"); | ||
@@ -21,2 +21,1 @@ function removeUndefined(type) { | ||
} | ||
exports.removeUndefined = removeUndefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.guessSourceUrlTemplate = exports.GitRepository = exports.AssumedRepository = exports.gitIsInstalled = void 0; | ||
exports.GitRepository = exports.AssumedRepository = void 0; | ||
exports.gitIsInstalled = gitIsInstalled; | ||
exports.guessSourceUrlTemplate = guessSourceUrlTemplate; | ||
const child_process_1 = require("child_process"); | ||
@@ -19,3 +21,2 @@ const base_path_1 = require("../utils/base-path"); | ||
} | ||
exports.gitIsInstalled = gitIsInstalled; | ||
class AssumedRepository { | ||
@@ -108,3 +109,3 @@ constructor(path, gitRevision, sourceLinkTemplate) { | ||
else { | ||
logger.warn(`The provided git remote "${gitRemote}" was not valid. Source links will be broken.`); | ||
logger.warn(logger.i18n.git_remote_0_not_valid(gitRemote)); | ||
} | ||
@@ -161,2 +162,1 @@ } | ||
} | ||
exports.guessSourceUrlTemplate = guessSourceUrlTemplate; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveAliasedSymbol = void 0; | ||
exports.resolveAliasedSymbol = resolveAliasedSymbol; | ||
const typescript_1 = __importDefault(require("typescript")); | ||
@@ -20,2 +20,1 @@ function resolveAliasedSymbol(symbol, checker) { | ||
} | ||
exports.resolveAliasedSymbol = resolveAliasedSymbol; |
@@ -72,6 +72,7 @@ import type { Reflection } from "../reflections"; | ||
* Helper function to convert an array of comment display parts into markdown suitable for | ||
* passing into Marked. `urlTo` will be used to resolve urls to any reflections linked to with | ||
* `@link` tags. | ||
* passing into markdown-it. | ||
* @param urlTo - Used to resolve urls to any reflections linked to with `@link` tags.. | ||
* @param useHtml - If set, will produce `<a>` links which can be colored according to the reflection type they are pointed at. | ||
*/ | ||
static displayPartsToMarkdown(parts: readonly CommentDisplayPart[], urlTo: (ref: Reflection) => string): string; | ||
static displayPartsToMarkdown(parts: readonly CommentDisplayPart[], urlTo: (ref: Reflection) => string, useHtml: boolean): string; | ||
/** | ||
@@ -123,2 +124,15 @@ * Helper utility to clone {@link Comment.summary} or {@link CommentTag.content} | ||
/** | ||
* Full path to the file where this comment originated from, if any. | ||
* This field will not be serialized, so will not be present when handling JSON-revived reflections. | ||
* | ||
* Note: This field is non-enumerable to make testing comment contents with `deepEqual` easier. | ||
*/ | ||
sourcePath?: string; | ||
/** | ||
* Internal discovery ID used to prevent symbol comments from | ||
* being duplicated on signatures. Only set when the comment was created | ||
* @internal | ||
*/ | ||
discoveryId?: number; | ||
/** | ||
* Creates a new Comment instance. | ||
@@ -125,0 +139,0 @@ */ |
"use strict"; | ||
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { | ||
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } | ||
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; | ||
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; | ||
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); | ||
var _, done = false; | ||
for (var i = decorators.length - 1; i >= 0; i--) { | ||
var context = {}; | ||
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; | ||
for (var p in contextIn.access) context.access[p] = contextIn.access[p]; | ||
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; | ||
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); | ||
if (kind === "accessor") { | ||
if (result === void 0) continue; | ||
if (result === null || typeof result !== "object") throw new TypeError("Object expected"); | ||
if (_ = accept(result.get)) descriptor.get = _; | ||
if (_ = accept(result.set)) descriptor.set = _; | ||
if (_ = accept(result.init)) initializers.unshift(_); | ||
} | ||
else if (_ = accept(result)) { | ||
if (kind === "field") initializers.unshift(_); | ||
else descriptor[key] = _; | ||
} | ||
} | ||
if (target) Object.defineProperty(target, contextIn.name, descriptor); | ||
done = true; | ||
}; | ||
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { | ||
var useValue = arguments.length > 2; | ||
for (var i = 0; i < initializers.length; i++) { | ||
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); | ||
} | ||
return useValue ? value : void 0; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -7,2 +41,3 @@ exports.Comment = exports.CommentTag = void 0; | ||
const ReflectionSymbolId_1 = require("../reflections/ReflectionSymbolId"); | ||
const general_1 = require("../../utils/general"); | ||
/** | ||
@@ -50,317 +85,361 @@ * A model that represents a single TypeDoc comment tag. | ||
*/ | ||
class Comment { | ||
/** | ||
* Debugging utility for combining parts into a simple string. Not suitable for | ||
* rendering, but can be useful in tests. | ||
*/ | ||
static combineDisplayParts(parts) { | ||
let result = ""; | ||
for (const item of parts || []) { | ||
switch (item.kind) { | ||
case "text": | ||
case "code": | ||
result += item.text; | ||
break; | ||
case "inline-tag": | ||
result += `{${item.tag} ${item.text}}`; | ||
break; | ||
default: | ||
(0, utils_1.assertNever)(item); | ||
let Comment = (() => { | ||
var _a; | ||
let _sourcePath_decorators; | ||
let _sourcePath_initializers = []; | ||
let _sourcePath_extraInitializers = []; | ||
let _discoveryId_decorators; | ||
let _discoveryId_initializers = []; | ||
let _discoveryId_extraInitializers = []; | ||
return _a = class Comment { | ||
/** | ||
* Debugging utility for combining parts into a simple string. Not suitable for | ||
* rendering, but can be useful in tests. | ||
*/ | ||
static combineDisplayParts(parts) { | ||
let result = ""; | ||
for (const item of parts || []) { | ||
switch (item.kind) { | ||
case "text": | ||
case "code": | ||
result += item.text; | ||
break; | ||
case "inline-tag": | ||
result += `{${item.tag} ${item.text}}`; | ||
break; | ||
default: | ||
(0, utils_1.assertNever)(item); | ||
} | ||
} | ||
return result; | ||
} | ||
} | ||
return result; | ||
} | ||
/** | ||
* Helper function to convert an array of comment display parts into markdown suitable for | ||
* passing into Marked. `urlTo` will be used to resolve urls to any reflections linked to with | ||
* `@link` tags. | ||
*/ | ||
static displayPartsToMarkdown(parts, urlTo) { | ||
const result = []; | ||
for (const part of parts) { | ||
switch (part.kind) { | ||
case "text": | ||
case "code": | ||
result.push(part.text); | ||
break; | ||
case "inline-tag": | ||
switch (part.tag) { | ||
case "@label": | ||
case "@inheritdoc": // Shouldn't happen | ||
break; // Not rendered. | ||
case "@link": | ||
case "@linkcode": | ||
case "@linkplain": { | ||
if (part.target) { | ||
let url; | ||
let kindClass; | ||
if (typeof part.target === "string") { | ||
url = part.target; | ||
/** | ||
* Helper function to convert an array of comment display parts into markdown suitable for | ||
* passing into markdown-it. | ||
* @param urlTo - Used to resolve urls to any reflections linked to with `@link` tags.. | ||
* @param useHtml - If set, will produce `<a>` links which can be colored according to the reflection type they are pointed at. | ||
*/ | ||
static displayPartsToMarkdown(parts, urlTo, useHtml) { | ||
const result = []; | ||
for (const part of parts) { | ||
switch (part.kind) { | ||
case "text": | ||
case "code": | ||
result.push(part.text); | ||
break; | ||
case "inline-tag": | ||
switch (part.tag) { | ||
case "@label": | ||
case "@inheritdoc": // Shouldn't happen | ||
break; // Not rendered. | ||
case "@link": | ||
case "@linkcode": | ||
case "@linkplain": { | ||
if (part.target) { | ||
let url; | ||
let kindClass; | ||
if (typeof part.target === "string") { | ||
url = part.target; | ||
} | ||
else if (part.target && "id" in part.target) { | ||
// No point in trying to resolve a ReflectionSymbolId at this point, we've already | ||
// tried and failed during the resolution step. | ||
url = urlTo(part.target); | ||
kindClass = kind_1.ReflectionKind.classString(part.target.kind); | ||
} | ||
if (useHtml) { | ||
const text = part.tag === "@linkcode" | ||
? `<code>${part.text}</code>` | ||
: part.text; | ||
result.push(url | ||
? `<a href="${url}"${kindClass | ||
? ` class="${kindClass}"` | ||
: ""}>${text}</a>` | ||
: part.text); | ||
} | ||
else { | ||
const text = part.tag === "@linkcode" | ||
? "`" + part.text + "`" | ||
: part.text; | ||
result.push(url ? `[${text}](${url})` : text); | ||
} | ||
} | ||
else { | ||
result.push(part.text); | ||
} | ||
break; | ||
} | ||
else if (part.target && "id" in part.target) { | ||
// No point in trying to resolve a ReflectionSymbolId at this point, we've already | ||
// tried and failed during the resolution step. | ||
url = urlTo(part.target); | ||
kindClass = kind_1.ReflectionKind.classString(part.target.kind); | ||
} | ||
const text = part.tag === "@linkcode" | ||
? `<code>${part.text}</code>` | ||
: part.text; | ||
result.push(url | ||
? `<a href="${url}"${kindClass | ||
? ` class="${kindClass}"` | ||
: ""}>${text}</a>` | ||
: part.text); | ||
default: | ||
// Hmm... probably want to be able to render these somehow, so custom inline tags can be given | ||
// special rendering rules. Future capability. For now, just render their text. | ||
result.push(`{${part.tag} ${part.text}}`); | ||
break; | ||
} | ||
else { | ||
result.push(part.text); | ||
} | ||
break; | ||
} | ||
default: | ||
// Hmm... probably want to be able to render these somehow, so custom inline tags can be given | ||
// special rendering rules. Future capability. For now, just render their text. | ||
result.push(`{${part.tag} ${part.text}}`); | ||
break; | ||
(0, utils_1.assertNever)(part); | ||
} | ||
break; | ||
default: | ||
(0, utils_1.assertNever)(part); | ||
} | ||
return result.join(""); | ||
} | ||
} | ||
return result.join(""); | ||
} | ||
/** | ||
* Helper utility to clone {@link Comment.summary} or {@link CommentTag.content} | ||
*/ | ||
static cloneDisplayParts(parts) { | ||
return parts.map((p) => ({ ...p })); | ||
} | ||
static serializeDisplayParts(serializer, parts) { | ||
return parts?.map((part) => { | ||
switch (part.kind) { | ||
case "text": | ||
case "code": | ||
return { ...part }; | ||
case "inline-tag": { | ||
let target; | ||
if (typeof part.target === "string") { | ||
target = part.target; | ||
/** | ||
* Helper utility to clone {@link Comment.summary} or {@link CommentTag.content} | ||
*/ | ||
static cloneDisplayParts(parts) { | ||
return parts.map((p) => ({ ...p })); | ||
} | ||
static serializeDisplayParts(serializer, parts) { | ||
return parts?.map((part) => { | ||
switch (part.kind) { | ||
case "text": | ||
case "code": | ||
return { ...part }; | ||
case "inline-tag": { | ||
let target; | ||
if (typeof part.target === "string") { | ||
target = part.target; | ||
} | ||
else if (part.target) { | ||
if ("id" in part.target) { | ||
target = part.target.id; | ||
} | ||
else { | ||
target = part.target.toObject(serializer); | ||
} | ||
} | ||
return { | ||
...part, | ||
target, | ||
}; | ||
} | ||
} | ||
else if (part.target) { | ||
if ("id" in part.target) { | ||
target = part.target.id; | ||
}); | ||
} | ||
//Since display parts are plain objects, this lives here | ||
static deserializeDisplayParts(de, parts) { | ||
const links = []; | ||
const result = parts.map((part) => { | ||
switch (part.kind) { | ||
case "text": | ||
case "code": | ||
return { ...part }; | ||
case "inline-tag": { | ||
if (typeof part.target === "number") { | ||
const part2 = { | ||
kind: part.kind, | ||
tag: part.tag, | ||
text: part.text, | ||
target: undefined, | ||
tsLinkText: part.tsLinkText, | ||
}; | ||
links.push([part.target, part2]); | ||
return part2; | ||
} | ||
else if (typeof part.target === "string" || | ||
part.target === undefined) { | ||
return { | ||
kind: "inline-tag", | ||
tag: part.tag, | ||
text: part.text, | ||
target: part.target, | ||
tsLinkText: part.tsLinkText, | ||
}; | ||
} | ||
else if (typeof part.target === "object") { | ||
return { | ||
kind: "inline-tag", | ||
tag: part.tag, | ||
text: part.text, | ||
target: new ReflectionSymbolId_1.ReflectionSymbolId(part.target), | ||
tsLinkText: part.tsLinkText, | ||
}; | ||
} | ||
else { | ||
(0, utils_1.assertNever)(part.target); | ||
} | ||
} | ||
else { | ||
target = part.target.toObject(serializer); | ||
} | ||
}); | ||
if (links.length) { | ||
de.defer((project) => { | ||
for (const [oldId, part] of links) { | ||
part.target = project.getReflectionById(de.oldIdToNewId[oldId] ?? -1); | ||
if (!part.target) { | ||
de.logger.warn(de.application.i18n.serialized_project_referenced_0_not_part_of_project(oldId.toString())); | ||
} | ||
} | ||
}); | ||
} | ||
return result; | ||
} | ||
/** | ||
* Splits the provided parts into a header (first line, as a string) | ||
* and body (remaining lines). If the header line contains inline tags | ||
* they will be serialized to a string. | ||
*/ | ||
static splitPartsToHeaderAndBody(parts) { | ||
let index = parts.findIndex((part) => { | ||
switch (part.kind) { | ||
case "text": | ||
case "code": | ||
return part.text.includes("\n"); | ||
case "inline-tag": | ||
return false; | ||
} | ||
}); | ||
if (index === -1) { | ||
return { | ||
...part, | ||
target, | ||
header: _a.combineDisplayParts(parts), | ||
body: [], | ||
}; | ||
} | ||
} | ||
}); | ||
} | ||
//Since display parts are plain objects, this lives here | ||
static deserializeDisplayParts(de, parts) { | ||
const links = []; | ||
const result = parts.map((part) => { | ||
switch (part.kind) { | ||
case "text": | ||
case "code": | ||
return { ...part }; | ||
case "inline-tag": { | ||
if (typeof part.target === "number") { | ||
const part2 = { | ||
kind: part.kind, | ||
tag: part.tag, | ||
text: part.text, | ||
target: undefined, | ||
tsLinkText: part.tsLinkText, | ||
}; | ||
links.push([part.target, part2]); | ||
return part2; | ||
} | ||
else if (typeof part.target === "string" || | ||
part.target === undefined) { | ||
return { | ||
kind: "inline-tag", | ||
tag: part.tag, | ||
text: part.text, | ||
target: part.target, | ||
tsLinkText: part.tsLinkText, | ||
}; | ||
} | ||
else if (typeof part.target === "object") { | ||
return { | ||
kind: "inline-tag", | ||
tag: part.tag, | ||
text: part.text, | ||
target: new ReflectionSymbolId_1.ReflectionSymbolId(part.target), | ||
tsLinkText: part.tsLinkText, | ||
}; | ||
} | ||
else { | ||
(0, utils_1.assertNever)(part.target); | ||
} | ||
// Do not split a code block, stop the header at the end of the previous block | ||
if (parts[index].kind === "code") { | ||
--index; | ||
} | ||
} | ||
}); | ||
if (links.length) { | ||
de.defer((project) => { | ||
for (const [oldId, part] of links) { | ||
part.target = project.getReflectionById(de.oldIdToNewId[oldId] ?? -1); | ||
if (!part.target) { | ||
de.logger.warn(`Serialized project contained a link to ${oldId} (${part.text}), which was not a part of the project.`); | ||
} | ||
if (index === -1) { | ||
return { header: "", body: _a.cloneDisplayParts(parts) }; | ||
} | ||
}); | ||
} | ||
return result; | ||
} | ||
/** | ||
* Splits the provided parts into a header (first line, as a string) | ||
* and body (remaining lines). If the header line contains inline tags | ||
* they will be serialized to a string. | ||
*/ | ||
static splitPartsToHeaderAndBody(parts) { | ||
let index = parts.findIndex((part) => { | ||
switch (part.kind) { | ||
case "text": | ||
case "code": | ||
return part.text.includes("\n"); | ||
case "inline-tag": | ||
return false; | ||
let header = _a.combineDisplayParts(parts.slice(0, index)); | ||
const split = parts[index].text.indexOf("\n"); | ||
let body; | ||
if (split === -1) { | ||
header += parts[index].text; | ||
body = _a.cloneDisplayParts(parts.slice(index + 1)); | ||
} | ||
else { | ||
header += parts[index].text.substring(0, split); | ||
body = _a.cloneDisplayParts(parts.slice(index)); | ||
body[0].text = body[0].text.substring(split + 1); | ||
} | ||
if (!body[0].text) { | ||
body.shift(); | ||
} | ||
return { header: header.trim(), body }; | ||
} | ||
}); | ||
if (index === -1) { | ||
return { | ||
header: Comment.combineDisplayParts(parts), | ||
body: [], | ||
}; | ||
} | ||
// Do not split a code block, stop the header at the end of the previous block | ||
if (parts[index].kind === "code") { | ||
--index; | ||
} | ||
if (index === -1) { | ||
return { header: "", body: Comment.cloneDisplayParts(parts) }; | ||
} | ||
let header = Comment.combineDisplayParts(parts.slice(0, index)); | ||
const split = parts[index].text.indexOf("\n"); | ||
let body; | ||
if (split === -1) { | ||
header += parts[index].text; | ||
body = Comment.cloneDisplayParts(parts.slice(index + 1)); | ||
} | ||
else { | ||
header += parts[index].text.substring(0, split); | ||
body = Comment.cloneDisplayParts(parts.slice(index)); | ||
body[0].text = body[0].text.substring(split + 1); | ||
} | ||
if (!body[0].text) { | ||
body.shift(); | ||
} | ||
return { header: header.trim(), body }; | ||
} | ||
/** | ||
* Creates a new Comment instance. | ||
*/ | ||
constructor(summary = [], blockTags = [], modifierTags = new Set()) { | ||
/** | ||
* All associated block level tags. | ||
*/ | ||
this.blockTags = []; | ||
/** | ||
* All modifier tags present on the comment, e.g. `@alpha`, `@beta`. | ||
*/ | ||
this.modifierTags = new Set(); | ||
this.summary = summary; | ||
this.blockTags = blockTags; | ||
this.modifierTags = modifierTags; | ||
extractLabelTag(this); | ||
} | ||
/** | ||
* Create a deep clone of this comment. | ||
*/ | ||
clone() { | ||
return new Comment(Comment.cloneDisplayParts(this.summary), this.blockTags.map((tag) => tag.clone()), new Set(this.modifierTags)); | ||
} | ||
/** | ||
* Returns true if this comment is completely empty. | ||
* @internal | ||
*/ | ||
isEmpty() { | ||
return !this.hasVisibleComponent() && this.modifierTags.size === 0; | ||
} | ||
/** | ||
* Has this comment a visible component? | ||
* | ||
* @returns TRUE when this comment has a visible component. | ||
*/ | ||
hasVisibleComponent() { | ||
return (this.summary.some((x) => x.kind !== "text" || x.text !== "") || | ||
this.blockTags.length > 0); | ||
} | ||
/** | ||
* Test whether this comment contains a tag with the given name. | ||
* | ||
* @param tagName The name of the tag to look for. | ||
* @returns TRUE when this comment contains a tag with the given name, otherwise FALSE. | ||
*/ | ||
hasModifier(tagName) { | ||
return this.modifierTags.has(tagName); | ||
} | ||
removeModifier(tagName) { | ||
this.modifierTags.delete(tagName); | ||
} | ||
/** | ||
* Return the first tag with the given name. | ||
* | ||
* @param tagName The name of the tag to look for. | ||
* @returns The found tag or undefined. | ||
*/ | ||
getTag(tagName) { | ||
return this.blockTags.find((tag) => tag.tag === tagName); | ||
} | ||
/** | ||
* Get all tags with the given tag name. | ||
*/ | ||
getTags(tagName) { | ||
return this.blockTags.filter((tag) => tag.tag === tagName); | ||
} | ||
getIdentifiedTag(identifier, tagName) { | ||
return this.blockTags.find((tag) => tag.tag === tagName && tag.name === identifier); | ||
} | ||
/** | ||
* Removes all block tags with the given tag name from the comment. | ||
* @param tagName | ||
*/ | ||
removeTags(tagName) { | ||
(0, utils_1.removeIf)(this.blockTags, (tag) => tag.tag === tagName); | ||
} | ||
toObject(serializer) { | ||
return { | ||
summary: Comment.serializeDisplayParts(serializer, this.summary), | ||
blockTags: serializer.toObjectsOptional(this.blockTags), | ||
modifierTags: this.modifierTags.size > 0 | ||
? Array.from(this.modifierTags) | ||
: undefined, | ||
label: this.label, | ||
}; | ||
} | ||
fromObject(de, obj) { | ||
this.summary = Comment.deserializeDisplayParts(de, obj.summary); | ||
this.blockTags = | ||
obj.blockTags?.map((tagObj) => { | ||
const tag = new CommentTag(tagObj.tag, []); | ||
de.fromObject(tag, tagObj); | ||
return tag; | ||
}) || []; | ||
this.modifierTags = new Set(obj.modifierTags); | ||
this.label = obj.label; | ||
} | ||
} | ||
/** | ||
* Creates a new Comment instance. | ||
*/ | ||
constructor(summary = [], blockTags = [], modifierTags = new Set()) { | ||
/** | ||
* All associated block level tags. | ||
*/ | ||
this.blockTags = []; | ||
/** | ||
* All modifier tags present on the comment, e.g. `@alpha`, `@beta`. | ||
*/ | ||
this.modifierTags = new Set(); | ||
/** | ||
* Full path to the file where this comment originated from, if any. | ||
* This field will not be serialized, so will not be present when handling JSON-revived reflections. | ||
* | ||
* Note: This field is non-enumerable to make testing comment contents with `deepEqual` easier. | ||
*/ | ||
this.sourcePath = __runInitializers(this, _sourcePath_initializers, void 0); | ||
/** | ||
* Internal discovery ID used to prevent symbol comments from | ||
* being duplicated on signatures. Only set when the comment was created | ||
* @internal | ||
*/ | ||
this.discoveryId = (__runInitializers(this, _sourcePath_extraInitializers), __runInitializers(this, _discoveryId_initializers, void 0)); | ||
__runInitializers(this, _discoveryId_extraInitializers); | ||
this.summary = summary; | ||
this.blockTags = blockTags; | ||
this.modifierTags = modifierTags; | ||
extractLabelTag(this); | ||
} | ||
/** | ||
* Create a deep clone of this comment. | ||
*/ | ||
clone() { | ||
const comment = new _a(_a.cloneDisplayParts(this.summary), this.blockTags.map((tag) => tag.clone()), new Set(this.modifierTags)); | ||
comment.discoveryId = this.discoveryId; | ||
comment.sourcePath = this.sourcePath; | ||
return comment; | ||
} | ||
/** | ||
* Returns true if this comment is completely empty. | ||
* @internal | ||
*/ | ||
isEmpty() { | ||
return !this.hasVisibleComponent() && this.modifierTags.size === 0; | ||
} | ||
/** | ||
* Has this comment a visible component? | ||
* | ||
* @returns TRUE when this comment has a visible component. | ||
*/ | ||
hasVisibleComponent() { | ||
return (this.summary.some((x) => x.kind !== "text" || x.text !== "") || | ||
this.blockTags.length > 0); | ||
} | ||
/** | ||
* Test whether this comment contains a tag with the given name. | ||
* | ||
* @param tagName The name of the tag to look for. | ||
* @returns TRUE when this comment contains a tag with the given name, otherwise FALSE. | ||
*/ | ||
hasModifier(tagName) { | ||
return this.modifierTags.has(tagName); | ||
} | ||
removeModifier(tagName) { | ||
this.modifierTags.delete(tagName); | ||
} | ||
/** | ||
* Return the first tag with the given name. | ||
* | ||
* @param tagName The name of the tag to look for. | ||
* @returns The found tag or undefined. | ||
*/ | ||
getTag(tagName) { | ||
return this.blockTags.find((tag) => tag.tag === tagName); | ||
} | ||
/** | ||
* Get all tags with the given tag name. | ||
*/ | ||
getTags(tagName) { | ||
return this.blockTags.filter((tag) => tag.tag === tagName); | ||
} | ||
getIdentifiedTag(identifier, tagName) { | ||
return this.blockTags.find((tag) => tag.tag === tagName && tag.name === identifier); | ||
} | ||
/** | ||
* Removes all block tags with the given tag name from the comment. | ||
* @param tagName | ||
*/ | ||
removeTags(tagName) { | ||
(0, utils_1.removeIf)(this.blockTags, (tag) => tag.tag === tagName); | ||
} | ||
toObject(serializer) { | ||
return { | ||
summary: _a.serializeDisplayParts(serializer, this.summary), | ||
blockTags: serializer.toObjectsOptional(this.blockTags), | ||
modifierTags: this.modifierTags.size > 0 | ||
? Array.from(this.modifierTags) | ||
: undefined, | ||
label: this.label, | ||
}; | ||
} | ||
fromObject(de, obj) { | ||
this.summary = _a.deserializeDisplayParts(de, obj.summary); | ||
this.blockTags = | ||
obj.blockTags?.map((tagObj) => { | ||
const tag = new CommentTag(tagObj.tag, []); | ||
de.fromObject(tag, tagObj); | ||
return tag; | ||
}) || []; | ||
this.modifierTags = new Set(obj.modifierTags); | ||
this.label = obj.label; | ||
} | ||
}, | ||
(() => { | ||
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; | ||
_sourcePath_decorators = [general_1.NonEnumerable]; | ||
_discoveryId_decorators = [general_1.NonEnumerable]; | ||
__esDecorate(null, null, _sourcePath_decorators, { kind: "field", name: "sourcePath", static: false, private: false, access: { has: obj => "sourcePath" in obj, get: obj => obj.sourcePath, set: (obj, value) => { obj.sourcePath = value; } }, metadata: _metadata }, _sourcePath_initializers, _sourcePath_extraInitializers); | ||
__esDecorate(null, null, _discoveryId_decorators, { kind: "field", name: "discoveryId", static: false, private: false, access: { has: obj => "discoveryId" in obj, get: obj => obj.discoveryId, set: (obj, value) => { obj.discoveryId = value; } }, metadata: _metadata }, _discoveryId_initializers, _discoveryId_extraInitializers); | ||
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); | ||
})(), | ||
_a; | ||
})(); | ||
exports.Comment = Comment; | ||
@@ -367,0 +446,0 @@ function extractLabelTag(comment) { |
@@ -1,2 +0,2 @@ | ||
import type { CommentDisplayPart, DeclarationReflection } from "."; | ||
import type { CommentDisplayPart, DeclarationReflection, DocumentReflection } from "."; | ||
import type { Serializer, JSONOutput, Deserializer } from "../serialization"; | ||
@@ -22,3 +22,3 @@ /** | ||
*/ | ||
children: DeclarationReflection[]; | ||
children: Array<DeclarationReflection | DocumentReflection>; | ||
/** | ||
@@ -25,0 +25,0 @@ * Create a new ReflectionCategory instance. |
import { ReflectionCategory } from "./ReflectionCategory"; | ||
import type { CommentDisplayPart, DeclarationReflection, Reflection } from "."; | ||
import type { CommentDisplayPart, DeclarationReflection, DocumentReflection, Reflection } from "."; | ||
import type { Serializer, JSONOutput, Deserializer } from "../serialization"; | ||
@@ -24,3 +24,3 @@ /** | ||
*/ | ||
children: DeclarationReflection[]; | ||
children: Array<DeclarationReflection | DocumentReflection>; | ||
/** | ||
@@ -27,0 +27,0 @@ * Categories contained within this group. |
@@ -8,2 +8,3 @@ import { Comment } from "../comments/comment"; | ||
import type { DeclarationReflection } from "./declaration"; | ||
import type { DocumentReflection } from "./document"; | ||
/** | ||
@@ -79,9 +80,10 @@ * Reset the reflection id. | ||
Children = 0, | ||
Parameters = 1, | ||
TypeLiteral = 2, | ||
TypeParameter = 3, | ||
Signatures = 4, | ||
IndexSignature = 5, | ||
GetSignature = 6, | ||
SetSignature = 7 | ||
Documents = 1, | ||
Parameters = 2, | ||
TypeLiteral = 3, | ||
TypeParameter = 4, | ||
Signatures = 5, | ||
IndexSignature = 6, | ||
GetSignature = 7, | ||
SetSignature = 8 | ||
} | ||
@@ -206,2 +208,3 @@ export interface TraverseCallback { | ||
isDeclaration(): this is DeclarationReflection; | ||
isDocument(): this is DocumentReflection; | ||
/** | ||
@@ -215,3 +218,3 @@ * Check if this reflection or any of its parents have been marked with the `@deprecated` tag. | ||
* Note: This may not necessarily traverse child reflections contained within the `type` property | ||
* of the reflection, and should not be relied on for this. Support for checking object types will likely be removed in v0.26. | ||
* of the reflection, and should not be relied on for this. Support for checking object types will likely be removed in v0.27. | ||
* | ||
@@ -218,0 +221,0 @@ * The given callback will be invoked for all children, signatures and type parameters |
@@ -37,3 +37,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Reflection = exports.TraverseProperty = exports.ReflectionFlags = exports.ReflectionFlag = exports.resetReflectionID = void 0; | ||
exports.Reflection = exports.TraverseProperty = exports.ReflectionFlags = exports.ReflectionFlag = void 0; | ||
exports.resetReflectionID = resetReflectionID; | ||
const comment_1 = require("../comments/comment"); | ||
@@ -55,3 +56,2 @@ const utils_1 = require("./utils"); | ||
} | ||
exports.resetReflectionID = resetReflectionID; | ||
var ReflectionFlag; | ||
@@ -226,9 +226,10 @@ (function (ReflectionFlag) { | ||
TraverseProperty[TraverseProperty["Children"] = 0] = "Children"; | ||
TraverseProperty[TraverseProperty["Parameters"] = 1] = "Parameters"; | ||
TraverseProperty[TraverseProperty["TypeLiteral"] = 2] = "TypeLiteral"; | ||
TraverseProperty[TraverseProperty["TypeParameter"] = 3] = "TypeParameter"; | ||
TraverseProperty[TraverseProperty["Signatures"] = 4] = "Signatures"; | ||
TraverseProperty[TraverseProperty["IndexSignature"] = 5] = "IndexSignature"; | ||
TraverseProperty[TraverseProperty["GetSignature"] = 6] = "GetSignature"; | ||
TraverseProperty[TraverseProperty["SetSignature"] = 7] = "SetSignature"; | ||
TraverseProperty[TraverseProperty["Documents"] = 1] = "Documents"; | ||
TraverseProperty[TraverseProperty["Parameters"] = 2] = "Parameters"; | ||
TraverseProperty[TraverseProperty["TypeLiteral"] = 3] = "TypeLiteral"; | ||
TraverseProperty[TraverseProperty["TypeParameter"] = 4] = "TypeParameter"; | ||
TraverseProperty[TraverseProperty["Signatures"] = 5] = "Signatures"; | ||
TraverseProperty[TraverseProperty["IndexSignature"] = 6] = "IndexSignature"; | ||
TraverseProperty[TraverseProperty["GetSignature"] = 7] = "GetSignature"; | ||
TraverseProperty[TraverseProperty["SetSignature"] = 8] = "SetSignature"; | ||
})(TraverseProperty || (exports.TraverseProperty = TraverseProperty = {})); | ||
@@ -281,4 +282,6 @@ /** | ||
kindOf(kind) { | ||
const kindArray = Array.isArray(kind) ? kind : [kind]; | ||
return kindArray.some((kind) => (this.kind & kind) !== 0); | ||
const kindFlags = Array.isArray(kind) | ||
? kind.reduce((a, b) => a | b, 0) | ||
: kind; | ||
return (this.kind & kindFlags) !== 0; | ||
} | ||
@@ -403,2 +406,5 @@ /** | ||
} | ||
isDocument() { | ||
return false; | ||
} | ||
/** | ||
@@ -405,0 +411,0 @@ * Check if this reflection or any of its parents have been marked with the `@deprecated` tag. |
@@ -1,2 +0,2 @@ | ||
import { Reflection, TraverseCallback } from "./abstract"; | ||
import { Reflection, type TraverseCallback } from "./abstract"; | ||
import { ReflectionCategory } from "../ReflectionCategory"; | ||
@@ -6,2 +6,3 @@ import { ReflectionGroup } from "../ReflectionGroup"; | ||
import type { Serializer, JSONOutput, Deserializer } from "../../serialization"; | ||
import type { DocumentReflection } from "./document"; | ||
import type { DeclarationReflection } from "./declaration"; | ||
@@ -13,6 +14,25 @@ /** | ||
/** | ||
* The children of this reflection. | ||
* The children of this reflection. Do not add reflections to this array | ||
* manually. Instead call {@link addChild}. | ||
*/ | ||
children?: DeclarationReflection[]; | ||
children?: Array<DeclarationReflection>; | ||
/** | ||
* Documents associated with this reflection. | ||
* | ||
* These are not children as including them as children requires code handle both | ||
* types, despite being mostly unrelated and handled separately. | ||
* | ||
* Including them here in a separate array neatly handles that problem, but also | ||
* introduces another one for rendering. When rendering, documents should really | ||
* actually be considered part of the "children" of a reflection. For this reason, | ||
* we also maintain a list of child declarations with child documents which is used | ||
* when rendering. | ||
*/ | ||
documents?: Array<DocumentReflection>; | ||
/** | ||
* Union of the {@link children} and {@link documents} arrays which dictates the | ||
* sort order for rendering. | ||
*/ | ||
childrenIncludingDocuments?: Array<DeclarationReflection | DocumentReflection>; | ||
/** | ||
* All children grouped by their kind. | ||
@@ -32,2 +52,4 @@ */ | ||
getChildrenByKind(kind: ReflectionKind): DeclarationReflection[]; | ||
addChild(child: DeclarationReflection | DocumentReflection): void; | ||
removeChild(child: DeclarationReflection | DocumentReflection): void; | ||
traverse(callback: TraverseCallback): void; | ||
@@ -34,0 +56,0 @@ toObject(serializer: Serializer): JSONOutput.ContainerReflection; |
@@ -7,2 +7,3 @@ "use strict"; | ||
const ReflectionGroup_1 = require("../ReflectionGroup"); | ||
const utils_1 = require("../../utils"); | ||
/** | ||
@@ -21,2 +22,32 @@ * @category Reflections | ||
} | ||
addChild(child) { | ||
if (child.isDeclaration()) { | ||
this.children ||= []; | ||
this.children.push(child); | ||
} | ||
else { | ||
this.documents ||= []; | ||
this.documents.push(child); | ||
} | ||
this.childrenIncludingDocuments ||= []; | ||
this.childrenIncludingDocuments.push(child); | ||
} | ||
removeChild(child) { | ||
if (child.isDeclaration()) { | ||
(0, utils_1.removeIfPresent)(this.children, child); | ||
if (this.children?.length === 0) { | ||
delete this.children; | ||
} | ||
} | ||
else { | ||
(0, utils_1.removeIfPresent)(this.documents, child); | ||
if (this.documents?.length === 0) { | ||
delete this.documents; | ||
} | ||
} | ||
(0, utils_1.removeIfPresent)(this.childrenIncludingDocuments, child); | ||
if (this.childrenIncludingDocuments?.length === 0) { | ||
delete this.childrenIncludingDocuments; | ||
} | ||
} | ||
traverse(callback) { | ||
@@ -28,2 +59,7 @@ for (const child of this.children?.slice() || []) { | ||
} | ||
for (const child of this.documents?.slice() || []) { | ||
if (callback(child, abstract_1.TraverseProperty.Documents) === false) { | ||
return; | ||
} | ||
} | ||
} | ||
@@ -34,2 +70,8 @@ toObject(serializer) { | ||
children: serializer.toObjectsOptional(this.children), | ||
documents: serializer.toObjectsOptional(this.documents), | ||
// If we only have one type of child, don't bother writing the duplicate info about | ||
// ordering with documents to the serialized file. | ||
childrenIncludingDocuments: this.children?.length && this.documents?.length | ||
? this.childrenIncludingDocuments?.map((refl) => refl.id) | ||
: undefined, | ||
groups: serializer.toObjectsOptional(this.groups), | ||
@@ -42,2 +84,24 @@ categories: serializer.toObjectsOptional(this.categories), | ||
this.children = de.reviveMany(obj.children, (child) => de.constructReflection(child)); | ||
this.documents = de.reviveMany(obj.documents, (child) => de.constructReflection(child)); | ||
const byId = new Map(); | ||
for (const child of this.children || []) { | ||
byId.set(child.id, child); | ||
} | ||
for (const child of this.documents || []) { | ||
byId.set(child.id, child); | ||
} | ||
for (const id of obj.childrenIncludingDocuments || []) { | ||
const child = byId.get(de.oldIdToNewId[id] ?? -1); | ||
if (child) { | ||
this.childrenIncludingDocuments ||= []; | ||
this.childrenIncludingDocuments.push(child); | ||
byId.delete(de.oldIdToNewId[id] ?? -1); | ||
} | ||
} | ||
if (byId.size) { | ||
// Anything left in byId wasn't included in the childrenIncludingDocuments array. | ||
// This is expected if we're dealing with a JSON file produced by TypeDoc 0.25. | ||
this.childrenIncludingDocuments ||= []; | ||
this.childrenIncludingDocuments.push(...byId.values()); | ||
} | ||
this.groups = de.reviveMany(obj.groups, (group) => new ReflectionGroup_1.ReflectionGroup(group.title, this)); | ||
@@ -44,0 +108,0 @@ this.categories = de.reviveMany(obj.categories, (cat) => new ReflectionCategory_1.ReflectionCategory(cat.title)); |
import type * as ts from "typescript"; | ||
import { ReferenceType, Type, type SomeType } from "../types"; | ||
import { type ReferenceType, type Type, type SomeType } from "../types"; | ||
import { type TraverseCallback } from "./abstract"; | ||
@@ -8,3 +8,3 @@ import { ContainerReflection } from "./container"; | ||
import type { Serializer, JSONOutput, Deserializer } from "../../serialization"; | ||
import { CommentDisplayPart } from "../comments"; | ||
import { type CommentDisplayPart } from "../comments"; | ||
import { SourceReference } from "../sources/file"; | ||
@@ -31,9 +31,2 @@ /** | ||
/** | ||
* @internal | ||
*/ | ||
export declare enum ConversionFlags { | ||
None = 0, | ||
VariableOrPropertySource = 1 | ||
} | ||
/** | ||
* A reflection that represents a single declaration emitted by the TypeScript compiler. | ||
@@ -82,3 +75,3 @@ * | ||
*/ | ||
indexSignature?: SignatureReflection; | ||
indexSignatures?: SignatureReflection[]; | ||
/** | ||
@@ -145,7 +138,2 @@ * The get signature of this declaration. | ||
packageVersion?: string; | ||
/** | ||
* Flags for information about a reflection which is needed solely during conversion. | ||
* @internal | ||
*/ | ||
conversionFlags: ConversionFlags; | ||
isDeclaration(): this is DeclarationReflection; | ||
@@ -152,0 +140,0 @@ hasGetterOrSetter(): boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DeclarationReflection = exports.ConversionFlags = void 0; | ||
exports.DeclarationReflection = void 0; | ||
const types_1 = require("../types"); | ||
@@ -12,10 +12,2 @@ const abstract_1 = require("./abstract"); | ||
/** | ||
* @internal | ||
*/ | ||
var ConversionFlags; | ||
(function (ConversionFlags) { | ||
ConversionFlags[ConversionFlags["None"] = 0] = "None"; | ||
ConversionFlags[ConversionFlags["VariableOrPropertySource"] = 1] = "VariableOrPropertySource"; | ||
})(ConversionFlags || (exports.ConversionFlags = ConversionFlags = {})); | ||
/** | ||
* A reflection that represents a single declaration emitted by the TypeScript compiler. | ||
@@ -31,7 +23,2 @@ * | ||
this.variant = "declaration"; | ||
/** | ||
* Flags for information about a reflection which is needed solely during conversion. | ||
* @internal | ||
*/ | ||
this.conversionFlags = ConversionFlags.None; | ||
} | ||
@@ -49,4 +36,4 @@ isDeclaration() { | ||
} | ||
if (this.indexSignature) { | ||
result.push(this.indexSignature); | ||
if (this.indexSignatures) { | ||
result = result.concat(this.indexSignatures); | ||
} | ||
@@ -81,4 +68,4 @@ if (this.getSignature) { | ||
} | ||
if (this.indexSignature) { | ||
if (callback(this.indexSignature, abstract_1.TraverseProperty.IndexSignature) === false) { | ||
for (const signature of this.indexSignatures?.slice() || []) { | ||
if (callback(signature, abstract_1.TraverseProperty.IndexSignature) === false) { | ||
return; | ||
@@ -125,3 +112,3 @@ } | ||
signatures: serializer.toObjectsOptional(this.signatures), | ||
indexSignature: serializer.toObject(this.indexSignature), | ||
indexSignatures: serializer.toObjectsOptional(this.indexSignatures), | ||
getSignature: serializer.toObject(this.getSignature), | ||
@@ -157,3 +144,3 @@ setSignature: serializer.toObject(this.setSignature), | ||
else { | ||
de.logger.warn(`Serialized project contained a reflection with id ${id} but it was not present in deserialized project.`); | ||
de.logger.warn(de.application.i18n.serialized_project_referenced_0_not_part_of_project(id.toString())); | ||
} | ||
@@ -170,3 +157,11 @@ } | ||
this.signatures = de.reviveMany(obj.signatures, (r) => de.constructReflection(r)); | ||
this.indexSignature = de.revive(obj.indexSignature, (r) => de.constructReflection(r)); | ||
// TypeDoc 0.25, remove check with 0.28. | ||
if (obj.indexSignature) { | ||
this.indexSignatures = [ | ||
de.revive(obj.indexSignature, (r) => de.constructReflection(r)), | ||
]; | ||
} | ||
else { | ||
this.indexSignatures = de.reviveMany(obj.indexSignatures, (r) => de.constructReflection(r)); | ||
} | ||
this.getSignature = de.revive(obj.getSignature, (r) => de.constructReflection(r)); | ||
@@ -173,0 +168,0 @@ this.setSignature = de.revive(obj.setSignature, (r) => de.constructReflection(r)); |
export { Reflection, ReflectionFlag, ReflectionFlags, TraverseProperty, } from "./abstract"; | ||
export type { TraverseCallback, ReflectionVisitor } from "./abstract"; | ||
export type { ReflectionVisitor, TraverseCallback } from "./abstract"; | ||
export { ContainerReflection } from "./container"; | ||
export { DeclarationReflection, ConversionFlags } from "./declaration"; | ||
export { DeclarationReflection } from "./declaration"; | ||
export type { DeclarationHierarchy } from "./declaration"; | ||
export { DocumentReflection } from "./document"; | ||
export { ReflectionKind } from "./kind"; | ||
@@ -10,2 +11,3 @@ export { ParameterReflection } from "./parameter"; | ||
export { ReferenceReflection } from "./reference"; | ||
export { ReflectionSymbolId, type ReflectionSymbolIdString, } from "./ReflectionSymbolId"; | ||
export { SignatureReflection } from "./signature"; | ||
@@ -15,2 +17,1 @@ export { TypeParameterReflection, VarianceModifier } from "./type-parameter"; | ||
export type { ReflectionVariant } from "./variant"; | ||
export { ReflectionSymbolId, type ReflectionSymbolIdString, } from "./ReflectionSymbolId"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ReflectionSymbolId = exports.splitUnquotedString = exports.VarianceModifier = exports.TypeParameterReflection = exports.SignatureReflection = exports.ReferenceReflection = exports.ProjectReflection = exports.ParameterReflection = exports.ReflectionKind = exports.ConversionFlags = exports.DeclarationReflection = exports.ContainerReflection = exports.TraverseProperty = exports.ReflectionFlags = exports.ReflectionFlag = exports.Reflection = void 0; | ||
exports.splitUnquotedString = exports.VarianceModifier = exports.TypeParameterReflection = exports.SignatureReflection = exports.ReflectionSymbolId = exports.ReferenceReflection = exports.ProjectReflection = exports.ParameterReflection = exports.ReflectionKind = exports.DocumentReflection = exports.DeclarationReflection = exports.ContainerReflection = exports.TraverseProperty = exports.ReflectionFlags = exports.ReflectionFlag = exports.Reflection = void 0; | ||
var abstract_1 = require("./abstract"); | ||
@@ -13,3 +13,4 @@ Object.defineProperty(exports, "Reflection", { enumerable: true, get: function () { return abstract_1.Reflection; } }); | ||
Object.defineProperty(exports, "DeclarationReflection", { enumerable: true, get: function () { return declaration_1.DeclarationReflection; } }); | ||
Object.defineProperty(exports, "ConversionFlags", { enumerable: true, get: function () { return declaration_1.ConversionFlags; } }); | ||
var document_1 = require("./document"); | ||
Object.defineProperty(exports, "DocumentReflection", { enumerable: true, get: function () { return document_1.DocumentReflection; } }); | ||
var kind_1 = require("./kind"); | ||
@@ -23,2 +24,4 @@ Object.defineProperty(exports, "ReflectionKind", { enumerable: true, get: function () { return kind_1.ReflectionKind; } }); | ||
Object.defineProperty(exports, "ReferenceReflection", { enumerable: true, get: function () { return reference_1.ReferenceReflection; } }); | ||
var ReflectionSymbolId_1 = require("./ReflectionSymbolId"); | ||
Object.defineProperty(exports, "ReflectionSymbolId", { enumerable: true, get: function () { return ReflectionSymbolId_1.ReflectionSymbolId; } }); | ||
var signature_1 = require("./signature"); | ||
@@ -31,3 +34,1 @@ Object.defineProperty(exports, "SignatureReflection", { enumerable: true, get: function () { return signature_1.SignatureReflection; } }); | ||
Object.defineProperty(exports, "splitUnquotedString", { enumerable: true, get: function () { return utils_1.splitUnquotedString; } }); | ||
var ReflectionSymbolId_1 = require("./ReflectionSymbolId"); | ||
Object.defineProperty(exports, "ReflectionSymbolId", { enumerable: true, get: function () { return ReflectionSymbolId_1.ReflectionSymbolId; } }); |
@@ -29,3 +29,7 @@ import type { EnumKeys } from "../../utils"; | ||
TypeAlias = 2097152, | ||
Reference = 4194304 | ||
Reference = 4194304, | ||
/** | ||
* Generic non-ts content to be included in the generated docs as its own page. | ||
*/ | ||
Document = 8388608 | ||
} | ||
@@ -71,7 +75,15 @@ /** @category Reflections */ | ||
const SignatureContainer: number; | ||
/** @internal */ | ||
const VariableContainer: number; | ||
/** @internal */ | ||
const MethodContainer: number; | ||
/** | ||
* Get a non-localized kind string. For the localized string, use `app.internationalization.kindSingularString(kind)` | ||
*/ | ||
function singularString(kind: ReflectionKind): string; | ||
/** | ||
* Get a non-localized kind string. For the localized string, use `app.internationalization.kindPluralString(kind)` | ||
*/ | ||
function pluralString(kind: ReflectionKind): string; | ||
function classString(kind: ReflectionKind): string; | ||
} |
@@ -33,2 +33,6 @@ "use strict"; | ||
ReflectionKind[ReflectionKind["Reference"] = 4194304] = "Reference"; | ||
/** | ||
* Generic non-ts content to be included in the generated docs as its own page. | ||
*/ | ||
ReflectionKind[ReflectionKind["Document"] = 8388608] = "Document"; | ||
})(ReflectionKind || (exports.ReflectionKind = ReflectionKind = {})); | ||
@@ -108,3 +112,5 @@ /** @category Reflections */ | ||
ReflectionKind.SignatureContainer = ReflectionKind.ContainsCallSignatures | ReflectionKind.Accessor; | ||
/** @internal */ | ||
ReflectionKind.VariableContainer = ReflectionKind.SomeModule | ReflectionKind.Project; | ||
/** @internal */ | ||
ReflectionKind.MethodContainer = ReflectionKind.ClassOrInterface | | ||
@@ -125,2 +131,5 @@ ReflectionKind.VariableOrProperty | | ||
}; | ||
/** | ||
* Get a non-localized kind string. For the localized string, use `app.internationalization.kindSingularString(kind)` | ||
*/ | ||
function singularString(kind) { | ||
@@ -135,2 +144,5 @@ if (kind in SINGULARS) { | ||
ReflectionKind.singularString = singularString; | ||
/** | ||
* Get a non-localized kind string. For the localized string, use `app.internationalization.kindPluralString(kind)` | ||
*/ | ||
function pluralString(kind) { | ||
@@ -137,0 +149,0 @@ if (kind in PLURALS) { |
import type { SomeType } from ".."; | ||
import { Reflection, TraverseCallback } from "./abstract"; | ||
import { Reflection, type TraverseCallback } from "./abstract"; | ||
import type { SignatureReflection } from "./signature"; | ||
@@ -4,0 +4,0 @@ import type { Serializer, JSONOutput, Deserializer } from "../../serialization"; |
@@ -1,6 +0,6 @@ | ||
import { Reflection } from "./abstract"; | ||
import { type Reflection } from "./abstract"; | ||
import { ContainerReflection } from "./container"; | ||
import type * as ts from "typescript"; | ||
import { ReflectionKind } from "./kind"; | ||
import { CommentDisplayPart } from "../comments"; | ||
import { type CommentDisplayPart } from "../comments"; | ||
import { ReflectionSymbolId } from "./ReflectionSymbolId"; | ||
@@ -7,0 +7,0 @@ import type { Serializer } from "../../serialization/serializer"; |
@@ -109,7 +109,5 @@ "use strict"; | ||
} | ||
if (property === abstract_1.TraverseProperty.Children) { | ||
(0, utils_1.removeIfPresent)(parent.children, reflection); | ||
if (!parent.children?.length) { | ||
delete parent.children; | ||
} | ||
if (property === abstract_1.TraverseProperty.Children || | ||
property == abstract_1.TraverseProperty.Documents) { | ||
parent.removeChild(reflection); | ||
} | ||
@@ -120,3 +118,6 @@ else if (property === abstract_1.TraverseProperty.GetSignature) { | ||
else if (property === abstract_1.TraverseProperty.IndexSignature) { | ||
delete parent.indexSignature; | ||
(0, utils_1.removeIfPresent)(parent.indexSignatures, reflection); | ||
if (!parent.indexSignatures?.length) { | ||
delete parent.indexSignatures; | ||
} | ||
} | ||
@@ -297,3 +298,3 @@ else if (property === abstract_1.TraverseProperty.Parameters) { | ||
else { | ||
de.logger.warn(`Serialized project contained a reflection with id ${id} but it was not present in deserialized project.`); | ||
de.logger.warn(de.application.i18n.serialized_project_referenced_0_not_part_of_project(id.toString())); | ||
} | ||
@@ -300,0 +301,0 @@ } |
@@ -6,3 +6,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.addInferredDeclarationMapPaths = exports.ReflectionSymbolId = void 0; | ||
exports.ReflectionSymbolId = void 0; | ||
exports.addInferredDeclarationMapPaths = addInferredDeclarationMapPaths; | ||
const fs_1 = require("fs"); | ||
@@ -113,2 +114,1 @@ const path_1 = require("path"); | ||
} | ||
exports.addInferredDeclarationMapPaths = addInferredDeclarationMapPaths; |
@@ -1,3 +0,3 @@ | ||
import { SomeType, ReferenceType } from "../types"; | ||
import { Reflection, TraverseCallback } from "./abstract"; | ||
import { type SomeType, type ReferenceType } from "../types"; | ||
import { Reflection, type TraverseCallback } from "./abstract"; | ||
import type { ParameterReflection } from "./parameter"; | ||
@@ -4,0 +4,0 @@ import type { TypeParameterReflection } from "./type-parameter"; |
import type { SomeType } from "../types"; | ||
import { Reflection, TraverseCallback } from "./abstract"; | ||
import { Reflection, type TraverseCallback } from "./abstract"; | ||
import type { DeclarationReflection } from "./declaration"; | ||
@@ -4,0 +4,0 @@ import type { Serializer, JSONOutput, Deserializer } from "../../serialization"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.splitUnquotedString = void 0; | ||
exports.splitUnquotedString = splitUnquotedString; | ||
function splitUnquotedString(input, delimiter) { | ||
@@ -30,2 +30,1 @@ if (input.startsWith(delimiter)) { | ||
} | ||
exports.splitUnquotedString = splitUnquotedString; |
import type { DeclarationReflection } from "./declaration"; | ||
import type { DocumentReflection } from "./document"; | ||
import type { ParameterReflection } from "./parameter"; | ||
@@ -18,2 +19,3 @@ import type { ProjectReflection } from "./project"; | ||
typeParam: TypeParameterReflection; | ||
document: DocumentReflection; | ||
} |
@@ -231,7 +231,7 @@ import * as ts from "typescript"; | ||
templateType: SomeType; | ||
readonlyModifier?: "+" | "-" | undefined; | ||
optionalModifier?: "+" | "-" | undefined; | ||
readonlyModifier?: ("+" | "-") | undefined; | ||
optionalModifier?: ("+" | "-") | undefined; | ||
nameType?: SomeType | undefined; | ||
readonly type = "mapped"; | ||
constructor(parameter: string, parameterType: SomeType, templateType: SomeType, readonlyModifier?: "+" | "-" | undefined, optionalModifier?: "+" | "-" | undefined, nameType?: SomeType | undefined); | ||
constructor(parameter: string, parameterType: SomeType, templateType: SomeType, readonlyModifier?: ("+" | "-") | undefined, optionalModifier?: ("+" | "-") | undefined, nameType?: SomeType | undefined); | ||
protected getTypeString(): string; | ||
@@ -406,3 +406,3 @@ needsParenthesis(): boolean; | ||
constructor(declaration: DeclarationReflection); | ||
protected getTypeString(): "Object" | "Function"; | ||
protected getTypeString(): "Function" | "Object"; | ||
needsParenthesis(): boolean; | ||
@@ -409,0 +409,0 @@ toObject(serializer: Serializer): JSONOutput.ReflectionType; |
@@ -26,3 +26,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.UnknownType = exports.UnionType = exports.TypeOperatorType = exports.NamedTupleMember = exports.TupleType = exports.TemplateLiteralType = exports.RestType = exports.ReflectionType = exports.ReferenceType = exports.QueryType = exports.PredicateType = exports.OptionalType = exports.MappedType = exports.LiteralType = exports.IntrinsicType = exports.IntersectionType = exports.InferredType = exports.IndexedAccessType = exports.ConditionalType = exports.ArrayType = exports.TypeContext = exports.makeRecursiveVisitor = exports.Type = void 0; | ||
exports.UnknownType = exports.UnionType = exports.TypeOperatorType = exports.NamedTupleMember = exports.TupleType = exports.TemplateLiteralType = exports.RestType = exports.ReflectionType = exports.ReferenceType = exports.QueryType = exports.PredicateType = exports.OptionalType = exports.MappedType = exports.LiteralType = exports.IntrinsicType = exports.IntersectionType = exports.InferredType = exports.IndexedAccessType = exports.ConditionalType = exports.ArrayType = exports.TypeContext = exports.Type = void 0; | ||
exports.makeRecursiveVisitor = makeRecursiveVisitor; | ||
const ts = __importStar(require("typescript")); | ||
@@ -148,3 +149,2 @@ const tsutils_1 = require("../utils/tsutils"); | ||
} | ||
exports.makeRecursiveVisitor = makeRecursiveVisitor; | ||
/** | ||
@@ -831,3 +831,3 @@ * Enumeration that can be used when traversing types to track the location of recursion. | ||
else { | ||
de.logger.warn(`Serialized project contained a reference to ${obj.target} (${this.qualifiedName}), which was not a part of the project.`); | ||
de.logger.warn(de.application.i18n.serialized_project_referenced_0_not_part_of_project(obj.target.toString())); | ||
} | ||
@@ -834,0 +834,0 @@ }); |
import { Event } from "../utils/events"; | ||
import type { ProjectReflection } from "../models/reflections/project"; | ||
import type { RenderTemplate, UrlMapping } from "./models/UrlMapping"; | ||
import type { DeclarationReflection, Reflection, ReflectionKind } from "../models"; | ||
import type { DeclarationReflection, DocumentReflection, Reflection, ReflectionKind } from "../models"; | ||
/** | ||
@@ -148,6 +148,6 @@ * An event emitted by the {@link Renderer} class at the very beginning and | ||
*/ | ||
searchResults: DeclarationReflection[]; | ||
searchResults: Array<DeclarationReflection | DocumentReflection>; | ||
/** | ||
* Additional search fields to be used when creating the search index. | ||
* `name` and `comment` may be specified to overwrite TypeDoc's search fields. | ||
* `name`, `comment` and `document` may be specified to overwrite TypeDoc's search fields. | ||
* | ||
@@ -159,3 +159,3 @@ * Do not use `id` as a custom search field. | ||
* Weights for the fields defined in `searchFields`. The default will weight | ||
* `name` as 10x more important than comment content. | ||
* `name` as 10x more important than comment and document content. | ||
* | ||
@@ -173,3 +173,3 @@ * If a field added to {@link searchFields} is not added to this object, it | ||
removeResult(index: number): void; | ||
constructor(name: string, searchResults: DeclarationReflection[]); | ||
constructor(name: string, searchResults: Array<DeclarationReflection | DocumentReflection>); | ||
} |
@@ -137,3 +137,3 @@ "use strict"; | ||
* Weights for the fields defined in `searchFields`. The default will weight | ||
* `name` as 10x more important than comment content. | ||
* `name` as 10x more important than comment and document content. | ||
* | ||
@@ -149,2 +149,3 @@ * If a field added to {@link searchFields} is not added to this object, it | ||
comment: 1, | ||
document: 1, | ||
}; | ||
@@ -151,0 +152,0 @@ this.searchResults = searchResults; |
@@ -7,3 +7,3 @@ export { PageEvent, RendererEvent, MarkdownEvent, IndexEvent } from "./events"; | ||
export { Theme } from "./theme"; | ||
export { DefaultTheme, type NavigationElement, } from "./themes/default/DefaultTheme"; | ||
export { DefaultTheme, Slugger, type NavigationElement, } from "./themes/default/DefaultTheme"; | ||
export { DefaultThemeRenderContext } from "./themes/default/DefaultThemeRenderContext"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Theme = exports.Renderer = exports.UrlMapping = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = void 0; | ||
exports.DefaultThemeRenderContext = exports.Slugger = exports.DefaultTheme = exports.Theme = exports.Renderer = exports.UrlMapping = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = void 0; | ||
var events_1 = require("./events"); | ||
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "PageEvent", { enumerable: true, get: function () { return events_1.PageEvent; } }); | ||
Object.defineProperty(exports, "DefaultTheme", { enumerable: true, get: function () { return DefaultTheme_1.DefaultTheme; } }); | ||
Object.defineProperty(exports, "Slugger", { enumerable: true, get: function () { return DefaultTheme_1.Slugger; } }); | ||
var DefaultThemeRenderContext_1 = require("./themes/default/DefaultThemeRenderContext"); | ||
Object.defineProperty(exports, "DefaultThemeRenderContext", { enumerable: true, get: function () { return DefaultThemeRenderContext_1.DefaultThemeRenderContext; } }); |
@@ -92,3 +92,3 @@ "use strict"; | ||
else { | ||
this.application.logger.error(`Custom CSS file at ${this.customCss} does not exist.`); | ||
this.application.logger.error(this.application.i18n.custom_css_file_0_does_not_exist(this.customCss)); | ||
event.preventDefault(); | ||
@@ -95,0 +95,0 @@ } |
@@ -8,3 +8,4 @@ import { RendererComponent } from "../components"; | ||
export declare class JavascriptIndexPlugin extends RendererComponent { | ||
accessor searchComments: boolean; | ||
private accessor searchComments; | ||
private accessor searchDocuments; | ||
/** | ||
@@ -22,2 +23,3 @@ * Create a new JavascriptIndexPlugin instance. | ||
private getCommentSearchText; | ||
private getDocumentSearchText; | ||
} |
@@ -92,3 +92,3 @@ "use strict"; | ||
let JavascriptIndexPlugin = (() => { | ||
var _JavascriptIndexPlugin_searchComments_accessor_storage; | ||
var _JavascriptIndexPlugin_searchComments_accessor_storage, _JavascriptIndexPlugin_searchDocuments_accessor_storage; | ||
let _classDecorators = [(0, components_1.Component)({ name: "javascript-index" })]; | ||
@@ -102,5 +102,10 @@ let _classDescriptor; | ||
let _searchComments_extraInitializers = []; | ||
let _searchDocuments_decorators; | ||
let _searchDocuments_initializers = []; | ||
let _searchDocuments_extraInitializers = []; | ||
var JavascriptIndexPlugin = _classThis = class extends _classSuper { | ||
get searchComments() { return __classPrivateFieldGet(this, _JavascriptIndexPlugin_searchComments_accessor_storage, "f"); } | ||
set searchComments(value) { __classPrivateFieldSet(this, _JavascriptIndexPlugin_searchComments_accessor_storage, value, "f"); } | ||
get searchDocuments() { return __classPrivateFieldGet(this, _JavascriptIndexPlugin_searchDocuments_accessor_storage, "f"); } | ||
set searchDocuments(value) { __classPrivateFieldSet(this, _JavascriptIndexPlugin_searchDocuments_accessor_storage, value, "f"); } | ||
/** | ||
@@ -130,3 +135,4 @@ * Create a new JavascriptIndexPlugin instance. | ||
const initialSearchResults = Object.values(event.project.reflections).filter((refl) => { | ||
return (refl instanceof models_1.DeclarationReflection && | ||
return ((refl instanceof models_1.DeclarationReflection || | ||
refl instanceof models_1.DocumentReflection) && | ||
refl.url && | ||
@@ -171,2 +177,3 @@ refl.name && | ||
comment: this.getCommentSearchText(reflection), | ||
document: this.getDocumentSearchText(reflection), | ||
...indexEvent.searchFields[rows.length], | ||
@@ -192,7 +199,9 @@ id: rows.length, | ||
comments.push(reflection.comment); | ||
reflection.signatures?.forEach((s) => s.comment && comments.push(s.comment)); | ||
reflection.getSignature?.comment && | ||
comments.push(reflection.getSignature.comment); | ||
reflection.setSignature?.comment && | ||
comments.push(reflection.setSignature.comment); | ||
if (reflection.isDeclaration()) { | ||
reflection.signatures?.forEach((s) => s.comment && comments.push(s.comment)); | ||
reflection.getSignature?.comment && | ||
comments.push(reflection.getSignature.comment); | ||
reflection.setSignature?.comment && | ||
comments.push(reflection.setSignature.comment); | ||
} | ||
if (!comments.length) { | ||
@@ -208,9 +217,18 @@ return; | ||
} | ||
getDocumentSearchText(reflection) { | ||
if (!this.searchDocuments) | ||
return; | ||
if (reflection.isDocument()) { | ||
return reflection.content.flatMap((c) => c.text).join("\n"); | ||
} | ||
} | ||
constructor() { | ||
super(...arguments); | ||
_JavascriptIndexPlugin_searchComments_accessor_storage.set(this, __runInitializers(this, _searchComments_initializers, void 0)); | ||
__runInitializers(this, _searchComments_extraInitializers); | ||
_JavascriptIndexPlugin_searchDocuments_accessor_storage.set(this, (__runInitializers(this, _searchComments_extraInitializers), __runInitializers(this, _searchDocuments_initializers, void 0))); | ||
__runInitializers(this, _searchDocuments_extraInitializers); | ||
} | ||
}; | ||
_JavascriptIndexPlugin_searchComments_accessor_storage = new WeakMap(); | ||
_JavascriptIndexPlugin_searchDocuments_accessor_storage = new WeakMap(); | ||
__setFunctionName(_classThis, "JavascriptIndexPlugin"); | ||
@@ -220,3 +238,5 @@ (() => { | ||
_searchComments_decorators = [(0, utils_1.Option)("searchInComments")]; | ||
_searchDocuments_decorators = [(0, utils_1.Option)("searchInDocuments")]; | ||
__esDecorate(_classThis, null, _searchComments_decorators, { kind: "accessor", name: "searchComments", static: false, private: false, access: { has: obj => "searchComments" in obj, get: obj => obj.searchComments, set: (obj, value) => { obj.searchComments = value; } }, metadata: _metadata }, _searchComments_initializers, _searchComments_extraInitializers); | ||
__esDecorate(_classThis, null, _searchDocuments_decorators, { kind: "accessor", name: "searchDocuments", static: false, private: false, access: { has: obj => "searchDocuments" in obj, get: obj => obj.searchDocuments, set: (obj, value) => { obj.searchDocuments = value; } }, metadata: _metadata }, _searchDocuments_initializers, _searchDocuments_extraInitializers); | ||
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); | ||
@@ -223,0 +243,0 @@ JavascriptIndexPlugin = _classThis = _classDescriptor.value; |
import { RendererComponent } from "../components"; | ||
export declare class SitemapPlugin extends RendererComponent { | ||
accessor sitemapBaseUrl: string; | ||
accessor hostedBaseUrl: string; | ||
initialize(): void; | ||
@@ -5,0 +5,0 @@ private onRendererBegin; |
@@ -62,4 +62,5 @@ "use strict"; | ||
const html_1 = require("../../utils/html"); | ||
const jsx_1 = require("../../utils/jsx"); | ||
let SitemapPlugin = (() => { | ||
var _SitemapPlugin_sitemapBaseUrl_accessor_storage; | ||
var _SitemapPlugin_hostedBaseUrl_accessor_storage; | ||
let _classDecorators = [(0, components_1.Component)({ name: "sitemap" })]; | ||
@@ -70,8 +71,8 @@ let _classDescriptor; | ||
let _classSuper = components_1.RendererComponent; | ||
let _sitemapBaseUrl_decorators; | ||
let _sitemapBaseUrl_initializers = []; | ||
let _sitemapBaseUrl_extraInitializers = []; | ||
let _hostedBaseUrl_decorators; | ||
let _hostedBaseUrl_initializers = []; | ||
let _hostedBaseUrl_extraInitializers = []; | ||
var SitemapPlugin = _classThis = class extends _classSuper { | ||
get sitemapBaseUrl() { return __classPrivateFieldGet(this, _SitemapPlugin_sitemapBaseUrl_accessor_storage, "f"); } | ||
set sitemapBaseUrl(value) { __classPrivateFieldSet(this, _SitemapPlugin_sitemapBaseUrl_accessor_storage, value, "f"); } | ||
get hostedBaseUrl() { return __classPrivateFieldGet(this, _SitemapPlugin_hostedBaseUrl_accessor_storage, "f"); } | ||
set hostedBaseUrl(value) { __classPrivateFieldSet(this, _SitemapPlugin_hostedBaseUrl_accessor_storage, value, "f"); } | ||
initialize() { | ||
@@ -84,5 +85,15 @@ this.listenTo(this.owner, events_1.RendererEvent.BEGIN, this.onRendererBegin); | ||
} | ||
if (event.isDefaultPrevented || !this.sitemapBaseUrl) { | ||
if (event.isDefaultPrevented || !this.hostedBaseUrl) { | ||
return; | ||
} | ||
this.owner.hooks.on("head.begin", (context) => { | ||
if (context.page.url === "index.html") { | ||
return { | ||
tag: "link", | ||
props: { rel: "canonical", href: this.hostedBaseUrl }, | ||
children: [], | ||
}; | ||
} | ||
return { tag: jsx_1.Fragment, props: null, children: [] }; | ||
}); | ||
this.owner.preRenderAsyncJobs.push((event) => this.buildSitemap(event)); | ||
@@ -100,3 +111,3 @@ } | ||
tag: "loc", | ||
children: new URL(url.url, this.sitemapBaseUrl).toString(), | ||
children: new URL(url.url, this.hostedBaseUrl).toString(), | ||
}, | ||
@@ -121,12 +132,12 @@ { | ||
super(...arguments); | ||
_SitemapPlugin_sitemapBaseUrl_accessor_storage.set(this, __runInitializers(this, _sitemapBaseUrl_initializers, void 0)); | ||
__runInitializers(this, _sitemapBaseUrl_extraInitializers); | ||
_SitemapPlugin_hostedBaseUrl_accessor_storage.set(this, __runInitializers(this, _hostedBaseUrl_initializers, void 0)); | ||
__runInitializers(this, _hostedBaseUrl_extraInitializers); | ||
} | ||
}; | ||
_SitemapPlugin_sitemapBaseUrl_accessor_storage = new WeakMap(); | ||
_SitemapPlugin_hostedBaseUrl_accessor_storage = new WeakMap(); | ||
__setFunctionName(_classThis, "SitemapPlugin"); | ||
(() => { | ||
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; | ||
_sitemapBaseUrl_decorators = [(0, utils_1.Option)("sitemapBaseUrl")]; | ||
__esDecorate(_classThis, null, _sitemapBaseUrl_decorators, { kind: "accessor", name: "sitemapBaseUrl", static: false, private: false, access: { has: obj => "sitemapBaseUrl" in obj, get: obj => obj.sitemapBaseUrl, set: (obj, value) => { obj.sitemapBaseUrl = value; } }, metadata: _metadata }, _sitemapBaseUrl_initializers, _sitemapBaseUrl_extraInitializers); | ||
_hostedBaseUrl_decorators = [(0, utils_1.Option)("hostedBaseUrl")]; | ||
__esDecorate(_classThis, null, _hostedBaseUrl_decorators, { kind: "accessor", name: "hostedBaseUrl", static: false, private: false, access: { has: obj => "hostedBaseUrl" in obj, get: obj => obj.hostedBaseUrl, set: (obj, value) => { obj.hostedBaseUrl = value; } }, metadata: _metadata }, _hostedBaseUrl_initializers, _hostedBaseUrl_extraInitializers); | ||
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); | ||
@@ -133,0 +144,0 @@ SitemapPlugin = _classThis = _classDescriptor.value; |
@@ -8,3 +8,3 @@ import type { Application } from "../application"; | ||
import { EventHooks } from "../utils"; | ||
import type { Theme as ShikiTheme } from "shiki"; | ||
import type { BundledTheme as ShikiTheme } from "shiki" with { "resolution-mode": "import" }; | ||
import type { JsxElement } from "../utils/jsx.elements"; | ||
@@ -11,0 +11,0 @@ import type { DefaultThemeRenderContext } from "./themes/default/DefaultThemeRenderContext"; |
@@ -310,3 +310,3 @@ "use strict"; | ||
catch (error) { | ||
this.application.logger.error(`Could not write ${page.filename}`); | ||
this.application.logger.error(this.application.i18n.could_not_write_0(page.filename)); | ||
} | ||
@@ -326,5 +326,3 @@ } | ||
if (!ctor) { | ||
this.application.logger.error(`The theme '${this.themeName}' is not defined. The available themes are: ${[ | ||
...this.themes.keys(), | ||
].join(", ")}`); | ||
this.application.logger.error(this.application.i18n.theme_0_is_not_defined_available_are_1(this.themeName, [...this.themes.keys()].join(", "))); | ||
return false; | ||
@@ -354,3 +352,3 @@ } | ||
catch (error) { | ||
this.application.logger.warn("Could not empty the output directory."); | ||
this.application.logger.warn(this.application.i18n.could_not_empty_output_directory_0(directory)); | ||
return false; | ||
@@ -363,3 +361,3 @@ } | ||
catch (error) { | ||
this.application.logger.error(`Could not create output directory ${directory}.`); | ||
this.application.logger.error(this.application.i18n.could_not_create_output_directory_0(directory)); | ||
return false; | ||
@@ -375,3 +373,3 @@ } | ||
catch (error) { | ||
this.application.logger.warn("Could not create .nojekyll file."); | ||
this.application.logger.warn(this.application.i18n.could_not_write_0(path.join(directory, ".nojekyll"))); | ||
return false; | ||
@@ -378,0 +376,0 @@ } |
import { Theme } from "../../theme"; | ||
import type { Renderer } from "../../renderer"; | ||
import { Reflection, ReflectionKind, ProjectReflection, ContainerReflection, DeclarationReflection } from "../../../models"; | ||
import { RenderTemplate, UrlMapping } from "../../models/UrlMapping"; | ||
import { type Reflection, ReflectionKind, ProjectReflection, type ContainerReflection, DeclarationReflection, type DocumentReflection } from "../../../models"; | ||
import { type RenderTemplate, UrlMapping } from "../../models/UrlMapping"; | ||
import type { PageEvent } from "../../events"; | ||
@@ -17,2 +17,10 @@ import type { MarkedPlugin } from "../../plugins"; | ||
/** | ||
* Responsible for getting a unique anchor for elements within a page. | ||
*/ | ||
export declare class Slugger { | ||
private seen; | ||
private serialize; | ||
slug(value: string): string; | ||
} | ||
/** | ||
* Default theme implementation of TypeDoc. If a theme does not provide a custom | ||
@@ -63,2 +71,3 @@ * {@link Theme} implementation, this theme class will be used. | ||
4194304: () => JSX.Element; | ||
8388608: () => JSX.Element; | ||
checkbox: () => JSX.Element; | ||
@@ -70,2 +79,3 @@ chevronDown: () => JSX.Element; | ||
getRenderContext(pageEvent: PageEvent<Reflection>): DefaultThemeRenderContext; | ||
documentTemplate: (pageEvent: PageEvent<DocumentReflection>) => JSX.Element; | ||
reflectionTemplate: (pageEvent: PageEvent<ContainerReflection>) => JSX.Element; | ||
@@ -75,3 +85,3 @@ indexTemplate: (pageEvent: PageEvent<ProjectReflection>) => JSX.Element; | ||
defaultLayoutTemplate: (pageEvent: PageEvent<Reflection>, template: RenderTemplate<PageEvent<Reflection>>) => JSX.Element; | ||
getReflectionClasses(reflection: DeclarationReflection): string; | ||
getReflectionClasses(reflection: DeclarationReflection | DocumentReflection): string; | ||
/** | ||
@@ -119,3 +129,3 @@ * Mappings of reflections kinds to templates used by this theme. | ||
*/ | ||
buildUrls(reflection: DeclarationReflection, urls: UrlMapping[]): UrlMapping[]; | ||
buildUrls(reflection: DeclarationReflection | DocumentReflection, urls: UrlMapping[]): UrlMapping[]; | ||
render(page: PageEvent<Reflection>, template: RenderTemplate<PageEvent<Reflection>>): string; | ||
@@ -128,2 +138,4 @@ private _navigationCache; | ||
buildNavigation(project: ProjectReflection): NavigationElement[]; | ||
private sluggers; | ||
getSlugger(reflection: Reflection): Slugger; | ||
/** | ||
@@ -130,0 +142,0 @@ * Generate an anchor url for the given reflection and all of its children. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DefaultTheme = void 0; | ||
exports.DefaultTheme = exports.Slugger = void 0; | ||
const theme_1 = require("../../theme"); | ||
@@ -12,2 +12,37 @@ const models_1 = require("../../../models"); | ||
/** | ||
* Responsible for getting a unique anchor for elements within a page. | ||
*/ | ||
class Slugger { | ||
constructor() { | ||
this.seen = new Map(); | ||
} | ||
serialize(value) { | ||
// Extracted from marked@4.3.0 | ||
return (value | ||
.toLowerCase() | ||
.trim() | ||
// remove html tags | ||
.replace(/<[!/a-z].*?>/gi, "") | ||
// remove unwanted chars | ||
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, "") | ||
.replace(/\s/g, "-")); | ||
} | ||
slug(value) { | ||
const originalSlug = this.serialize(value); | ||
let slug = originalSlug; | ||
let count = 0; | ||
if (this.seen.has(slug)) { | ||
count = this.seen.get(originalSlug); | ||
do { | ||
count++; | ||
slug = originalSlug + "-" + count; | ||
} while (this.seen.has(slug)); | ||
} | ||
this.seen.set(originalSlug, count); | ||
this.seen.set(slug, 0); | ||
return slug; | ||
} | ||
} | ||
exports.Slugger = Slugger; | ||
/** | ||
* Default theme implementation of TypeDoc. If a theme does not provide a custom | ||
@@ -45,2 +80,5 @@ * {@link Theme} implementation, this theme class will be used. | ||
this.icons = { ...icon_1.icons }; | ||
this.documentTemplate = (pageEvent) => { | ||
return this.getRenderContext(pageEvent).documentTemplate(pageEvent); | ||
}; | ||
this.reflectionTemplate = (pageEvent) => { | ||
@@ -97,3 +135,9 @@ return this.getRenderContext(pageEvent).reflectionTemplate(pageEvent); | ||
}, | ||
{ | ||
kind: [models_1.ReflectionKind.Document], | ||
directory: "variables", | ||
template: this.documentTemplate, | ||
}, | ||
]; | ||
this.sluggers = new Map(); | ||
this.markedPlugin = renderer.getComponent("marked"); | ||
@@ -110,2 +154,3 @@ } | ||
const urls = []; | ||
this.sluggers.set(project, new Slugger()); | ||
if (false == hasReadme(this.application.options.getValue("readme"))) { | ||
@@ -129,7 +174,3 @@ project.url = "index.html"; | ||
} | ||
project.children?.forEach((child) => { | ||
if (child instanceof models_1.DeclarationReflection) { | ||
this.buildUrls(child, urls); | ||
} | ||
}); | ||
project.childrenIncludingDocuments?.forEach((child) => this.buildUrls(child, urls)); | ||
return urls; | ||
@@ -174,2 +215,3 @@ } | ||
urls.push(new UrlMapping_1.UrlMapping(url, reflection, mapping.template)); | ||
this.sluggers.set(reflection, new Slugger()); | ||
reflection.url = url; | ||
@@ -179,3 +221,3 @@ reflection.hasOwnDocument = true; | ||
reflection.traverse((child) => { | ||
if (child instanceof models_1.DeclarationReflection) { | ||
if (child.isDeclaration() || child.isDocument()) { | ||
this.buildUrls(child, urls); | ||
@@ -214,5 +256,2 @@ } | ||
const leaves = this.application.options.getValue("navigationLeaves"); | ||
if (opts.fullTree) { | ||
this.application.logger.warn(`The navigation.fullTree option no longer has any affect and will be removed in v0.26`); | ||
} | ||
return getNavigationElements(project) || []; | ||
@@ -247,3 +286,3 @@ function toNavigation(element) { | ||
} | ||
if (!parent.kindOf(models_1.ReflectionKind.SomeModule | models_1.ReflectionKind.Project)) { | ||
if (!parent.kindOf(models_1.ReflectionKind.SomeModule | models_1.ReflectionKind.Project) || parent.isDocument()) { | ||
return; | ||
@@ -258,7 +297,7 @@ } | ||
if (opts.includeFolders && | ||
parent.children?.every((child) => child.kindOf(models_1.ReflectionKind.Module)) && | ||
parent.children.some((child) => child.name.includes("/"))) { | ||
return deriveModuleFolders(parent.children); | ||
parent.childrenIncludingDocuments?.every((child) => child.kindOf(models_1.ReflectionKind.Module | models_1.ReflectionKind.Document)) && | ||
parent.childrenIncludingDocuments.some((child) => child.name.includes("/"))) { | ||
return deriveModuleFolders(parent.childrenIncludingDocuments); | ||
} | ||
return parent.children?.map(toNavigation); | ||
return parent.childrenIncludingDocuments?.map(toNavigation); | ||
} | ||
@@ -313,2 +352,9 @@ function deriveModuleFolders(children) { | ||
} | ||
getSlugger(reflection) { | ||
if (this.sluggers.has(reflection)) { | ||
return this.sluggers.get(reflection); | ||
} | ||
// A slugger should always be defined at least for the project | ||
return this.getSlugger(reflection.parent); | ||
} | ||
/** | ||
@@ -349,3 +395,3 @@ * Generate an anchor url for the given reflection and all of its children. | ||
if (key === "inherited") { | ||
if (reflection.inheritedFrom) { | ||
if (reflection.isDeclaration() && reflection.inheritedFrom) { | ||
classes.push("tsd-is-inherited"); | ||
@@ -352,0 +398,0 @@ } |
import type { PageEvent, RendererHooks } from "../.."; | ||
import { CommentDisplayPart, DeclarationReflection, Reflection } from "../../../models"; | ||
import { JSX, NeverIfInternal, Options } from "../../../utils"; | ||
import type { Internationalization, TranslationProxy } from "../../../internationalization/internationalization"; | ||
import { type DocumentReflection, type CommentDisplayPart, type DeclarationReflection, type Reflection } from "../../../models"; | ||
import { type NeverIfInternal, type Options } from "../../../utils"; | ||
import type { DefaultTheme } from "./DefaultTheme"; | ||
import { icons } from "./partials/icon"; | ||
import { type icons } from "./partials/icon"; | ||
export declare class DefaultThemeRenderContext { | ||
@@ -11,8 +12,6 @@ private theme; | ||
options: Options; | ||
internationalization: Internationalization; | ||
i18n: TranslationProxy; | ||
constructor(theme: DefaultTheme, page: PageEvent<Reflection>, options: Options); | ||
/** | ||
* @deprecated Will be removed in 0.26, no longer required. | ||
*/ | ||
iconsCache(): JSX.Element; | ||
/** | ||
* Icons available for use within the page. | ||
@@ -24,3 +23,3 @@ * | ||
get icons(): Readonly<typeof icons>; | ||
hook: (name: keyof RendererHooks) => JSX.Element[]; | ||
hook: (name: keyof RendererHooks) => import("../../../utils/jsx.elements").JsxElement[]; | ||
/** Avoid this in favor of urlTo if possible */ | ||
@@ -31,7 +30,8 @@ relativeURL: (url: string, cacheBust?: boolean) => string; | ||
getNavigation: () => import("./DefaultTheme").NavigationElement[]; | ||
getReflectionClasses: (refl: DeclarationReflection) => string; | ||
reflectionTemplate: (props: PageEvent<import("../../../models").ContainerReflection>) => JSX.Element; | ||
indexTemplate: (props: PageEvent<import("../../../models").ProjectReflection>) => JSX.Element; | ||
hierarchyTemplate: (props: PageEvent<import("../../../models").ProjectReflection>) => JSX.Element; | ||
defaultLayout: (template: import("../..").RenderTemplate<PageEvent<Reflection>>, props: PageEvent<Reflection>) => JSX.Element; | ||
getReflectionClasses: (refl: DeclarationReflection | DocumentReflection) => string; | ||
documentTemplate: (props: PageEvent<DocumentReflection>) => import("../../../utils/jsx.elements").JsxElement; | ||
reflectionTemplate: (props: PageEvent<import("../../../models").ContainerReflection>) => import("../../../utils/jsx.elements").JsxElement; | ||
indexTemplate: (props: PageEvent<import("../../../models").ProjectReflection>) => import("../../../utils/jsx.elements").JsxElement; | ||
hierarchyTemplate: (props: PageEvent<import("../../../models").ProjectReflection>) => import("../../../utils/jsx.elements").JsxElement; | ||
defaultLayout: (template: import("../..").RenderTemplate<PageEvent<Reflection>>, props: PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement; | ||
/** | ||
@@ -45,40 +45,40 @@ * Rendered just after the description for a reflection. | ||
*/ | ||
reflectionPreview: (props: Reflection) => JSX.Element | undefined; | ||
analytics: () => JSX.Element | undefined; | ||
breadcrumb: (props: Reflection) => JSX.Element | undefined; | ||
commentSummary: (props: Reflection) => JSX.Element | undefined; | ||
commentTags: (props: Reflection) => JSX.Element | undefined; | ||
reflectionFlags: (props: Reflection) => JSX.Element; | ||
footer: () => JSX.Element; | ||
header: (props: PageEvent<Reflection>) => JSX.Element; | ||
hierarchy: (props: import("../../../models").DeclarationHierarchy | undefined) => JSX.Element | undefined; | ||
index: (props: import("../../../models").ContainerReflection) => JSX.Element; | ||
member: (props: DeclarationReflection) => JSX.Element; | ||
memberDeclaration: (props: DeclarationReflection) => JSX.Element; | ||
memberGetterSetter: (props: DeclarationReflection) => JSX.Element; | ||
memberReference: (props: import("../../../models").ReferenceReflection) => JSX.Element; | ||
reflectionPreview: (props: Reflection) => import("../../../utils/jsx.elements").JsxElement | undefined; | ||
analytics: () => import("../../../utils/jsx.elements").JsxElement | undefined; | ||
breadcrumb: (props: Reflection) => import("../../../utils/jsx.elements").JsxElement | undefined; | ||
commentSummary: (props: Reflection) => import("../../../utils/jsx.elements").JsxElement | undefined; | ||
commentTags: (props: Reflection) => import("../../../utils/jsx.elements").JsxElement | undefined; | ||
reflectionFlags: (props: Reflection) => import("../../../utils/jsx.elements").JsxElement; | ||
footer: () => import("../../../utils/jsx.elements").JsxElement | undefined; | ||
header: (props: PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement; | ||
hierarchy: (props: import("../../../models").DeclarationHierarchy | undefined) => import("../../../utils/jsx.elements").JsxElement | undefined; | ||
index: (props: import("../../../models").ContainerReflection) => import("../../../utils/jsx.elements").JsxElement; | ||
member: (props: DeclarationReflection | DocumentReflection) => import("../../../utils/jsx.elements").JsxElement; | ||
memberDeclaration: (props: DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement; | ||
memberGetterSetter: (props: DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement; | ||
memberReference: (props: import("../../../models").ReferenceReflection) => import("../../../utils/jsx.elements").JsxElement; | ||
memberSignatureBody: (props: import("../../../models").SignatureReflection, r_1?: { | ||
hideSources?: boolean | undefined; | ||
} | undefined) => JSX.Element; | ||
} | undefined) => import("../../../utils/jsx.elements").JsxElement; | ||
memberSignatureTitle: (props: import("../../../models").SignatureReflection, r_1?: { | ||
hideName?: boolean | undefined; | ||
arrowStyle?: boolean | undefined; | ||
} | undefined) => JSX.Element; | ||
memberSignatures: (props: DeclarationReflection) => JSX.Element; | ||
memberSources: (props: import("../../../models").SignatureReflection | DeclarationReflection) => JSX.Element; | ||
members: (props: import("../../../models").ContainerReflection) => JSX.Element; | ||
membersGroup: (group: import("../../../models").ReflectionGroup) => JSX.Element; | ||
sidebar: (props: PageEvent<Reflection>) => JSX.Element; | ||
pageSidebar: (props: PageEvent<Reflection>) => JSX.Element; | ||
sidebarLinks: () => JSX.Element | null; | ||
settings: () => JSX.Element; | ||
navigation: (props: PageEvent<Reflection>) => JSX.Element; | ||
pageNavigation: (props: PageEvent<Reflection>) => JSX.Element; | ||
parameter: (props: DeclarationReflection) => JSX.Element; | ||
toolbar: (props: PageEvent<Reflection>) => JSX.Element; | ||
} | undefined) => import("../../../utils/jsx.elements").JsxElement; | ||
memberSignatures: (props: DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement; | ||
memberSources: (props: import("../../../models").SignatureReflection | DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement; | ||
members: (props: import("../../../models").ContainerReflection) => import("../../../utils/jsx.elements").JsxElement; | ||
membersGroup: (group: import("../../../models").ReflectionGroup) => import("../../../utils/jsx.elements").JsxElement; | ||
sidebar: (props: PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement; | ||
pageSidebar: (props: PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement; | ||
sidebarLinks: () => import("../../../utils/jsx.elements").JsxElement | null; | ||
settings: () => import("../../../utils/jsx.elements").JsxElement; | ||
navigation: (props: PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement; | ||
pageNavigation: (props: PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement; | ||
parameter: (props: DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement; | ||
toolbar: (props: PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement; | ||
type: (type: import("../../../models").Type | undefined, options?: { | ||
topLevelLinks: boolean; | ||
} | undefined) => JSX.Element; | ||
typeAndParent: (props: import("../../../models").Type) => JSX.Element; | ||
typeParameters: (typeParameters: import("../../../models").TypeParameterReflection[]) => JSX.Element; | ||
} | undefined) => import("../../../utils/jsx.elements").JsxElement; | ||
typeAndParent: (props: import("../../../models").Type) => import("../../../utils/jsx.elements").JsxElement; | ||
typeParameters: (typeParameters: import("../../../models").TypeParameterReflection[]) => import("../../../utils/jsx.elements").JsxElement; | ||
} |
@@ -5,3 +5,2 @@ "use strict"; | ||
const models_1 = require("../../../models"); | ||
const utils_1 = require("../../../utils"); | ||
const default_1 = require("./layouts/default"); | ||
@@ -34,2 +33,3 @@ const partials_1 = require("./partials"); | ||
const templates_1 = require("./templates"); | ||
const document_1 = require("./templates/document"); | ||
const hierarchy_2 = require("./templates/hierarchy"); | ||
@@ -58,8 +58,12 @@ const reflection_1 = require("./templates/reflection"); | ||
if (md instanceof Array) { | ||
return this.theme.markedPlugin.parseMarkdown(models_1.Comment.displayPartsToMarkdown(md, this.urlTo), this.page); | ||
return this.theme.markedPlugin.parseMarkdown(models_1.Comment.displayPartsToMarkdown(md, this.urlTo, true), // GERRIT come back here | ||
this.page, this); | ||
} | ||
return md ? this.theme.markedPlugin.parseMarkdown(md, this.page) : ""; | ||
return md | ||
? this.theme.markedPlugin.parseMarkdown(md, this.page, this) | ||
: ""; | ||
}; | ||
this.getNavigation = () => this.theme.getNavigation(this.page.project); | ||
this.getReflectionClasses = (refl) => this.theme.getReflectionClasses(refl); | ||
this.documentTemplate = bind(document_1.documentTemplate, this); | ||
this.reflectionTemplate = bind(reflection_1.reflectionTemplate, this); | ||
@@ -109,11 +113,7 @@ this.indexTemplate = bind(templates_1.indexTemplate, this); | ||
this.options = options; | ||
this._refIcons = (0, icon_1.buildRefIcons)(icon_1.icons, this); | ||
this.internationalization = theme.application.internationalization; | ||
this.i18n = this.internationalization.proxy; | ||
this._refIcons = (0, icon_1.buildRefIcons)(theme.icons, this); | ||
} | ||
/** | ||
* @deprecated Will be removed in 0.26, no longer required. | ||
*/ | ||
iconsCache() { | ||
return utils_1.JSX.createElement(utils_1.JSX.Fragment, null); | ||
} | ||
/** | ||
* Icons available for use within the page. | ||
@@ -120,0 +120,0 @@ * |
@@ -6,3 +6,3 @@ "use strict"; | ||
const lib_1 = require("../../lib"); | ||
const defaultLayout = (context, template, props) => (utils_1.JSX.createElement("html", { class: "default", lang: context.options.getValue("htmlLang") }, | ||
const defaultLayout = (context, template, props) => (utils_1.JSX.createElement("html", { class: "default", lang: context.options.getValue("lang") }, | ||
utils_1.JSX.createElement("head", null, | ||
@@ -9,0 +9,0 @@ utils_1.JSX.createElement("meta", { charSet: "utf-8" }), |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.analytics = void 0; | ||
exports.analytics = analytics; | ||
const utils_1 = require("../../../../utils"); | ||
@@ -20,2 +20,1 @@ function analytics(context) { | ||
} | ||
exports.analytics = analytics; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.anchorIcon = void 0; | ||
exports.anchorIcon = anchorIcon; | ||
const utils_1 = require("../../../../utils"); | ||
@@ -8,4 +8,3 @@ function anchorIcon(context, anchor) { | ||
return utils_1.JSX.createElement(utils_1.JSX.Fragment, null); | ||
return (utils_1.JSX.createElement("a", { href: `#${anchor}`, "aria-label": "Permalink", class: "tsd-anchor-icon" }, context.icons.anchor())); | ||
return (utils_1.JSX.createElement("a", { href: `#${anchor}`, "aria-label": context.i18n.theme_permalink(), class: "tsd-anchor-icon" }, context.icons.anchor())); | ||
} | ||
exports.anchorIcon = anchorIcon; |
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
import { JSX } from "../../../../utils"; | ||
import { Reflection } from "../../../../models"; | ||
import { type Reflection } from "../../../../models"; | ||
export declare function commentSummary({ markdown }: DefaultThemeRenderContext, props: Reflection): JSX.Element | undefined; | ||
export declare function commentTags({ markdown }: DefaultThemeRenderContext, props: Reflection): JSX.Element | undefined; | ||
export declare function reflectionFlags(_context: DefaultThemeRenderContext, props: Reflection): JSX.Element; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.reflectionFlags = exports.commentTags = exports.commentSummary = void 0; | ||
exports.commentSummary = commentSummary; | ||
exports.commentTags = commentTags; | ||
exports.reflectionFlags = reflectionFlags; | ||
const utils_1 = require("../../../../utils"); | ||
@@ -14,3 +16,2 @@ const models_1 = require("../../../../models"); | ||
} | ||
exports.commentSummary = commentSummary; | ||
function commentTags({ markdown }, props) { | ||
@@ -31,3 +32,2 @@ if (!props.comment) | ||
} | ||
exports.commentTags = commentTags; | ||
const flagsNotRendered = ["@showCategories", "@showGroups", "@hideCategories", "@hideGroups"]; | ||
@@ -47,2 +47,1 @@ function reflectionFlags(_context, props) { | ||
} | ||
exports.reflectionFlags = reflectionFlags; |
import { JSX } from "../../../../utils"; | ||
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
export declare function footer(context: DefaultThemeRenderContext): JSX.Element; | ||
export declare function footer(context: DefaultThemeRenderContext): JSX.Element | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.footer = void 0; | ||
exports.footer = footer; | ||
const utils_1 = require("../../../../utils"); | ||
function footer(context) { | ||
const hideGenerator = context.options.getValue("hideGenerator"); | ||
if (hideGenerator) | ||
return; | ||
const message = context.i18n.theme_generated_using_typedoc(); | ||
// Only handles one occurrence, but that's all I expect... | ||
const index = message.indexOf("TypeDoc"); | ||
let display; | ||
if (index == -1) { | ||
display = utils_1.JSX.createElement("p", { class: "tsd-generator" }, message); | ||
} | ||
else { | ||
const pre = message.substring(0, index); | ||
const post = message.substring(index + "TypeDoc".length); | ||
display = (utils_1.JSX.createElement("p", { class: "tsd-generator" }, | ||
pre, | ||
utils_1.JSX.createElement("a", { href: "https://typedoc.org/", target: "_blank" }, "TypeDoc"), | ||
post)); | ||
} | ||
return (utils_1.JSX.createElement("footer", null, | ||
context.hook("footer.begin"), | ||
hideGenerator || (utils_1.JSX.createElement("p", { class: "tsd-generator" }, | ||
"Generated using ", | ||
utils_1.JSX.createElement("a", { href: "https://typedoc.org/", target: "_blank" }, "TypeDoc"))), | ||
hideGenerator || display, | ||
context.hook("footer.end"))); | ||
} | ||
exports.footer = footer; |
import { JSX } from "../../../../utils"; | ||
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
import type { PageEvent } from "../../../events"; | ||
import { Reflection } from "../../../../models"; | ||
import { type Reflection } from "../../../../models"; | ||
export declare const header: (context: DefaultThemeRenderContext, props: PageEvent<Reflection>) => JSX.Element; |
@@ -11,4 +11,5 @@ "use strict"; | ||
!!props.model.parent && utils_1.JSX.createElement("ul", { class: "tsd-breadcrumb" }, context.breadcrumb(props.model)), | ||
utils_1.JSX.createElement(HeadingLevel, { class: (0, lib_1.classNames)({ deprecated: props.model.isDeprecated() }) }, | ||
props.model.kind !== models_1.ReflectionKind.Project && `${models_1.ReflectionKind.singularString(props.model.kind)} `, | ||
!props.model.isDocument() && (utils_1.JSX.createElement(HeadingLevel, { class: (0, lib_1.classNames)({ deprecated: props.model.isDeprecated() }) }, | ||
props.model.kind !== models_1.ReflectionKind.Project && | ||
`${context.internationalization.kindSingularString(props.model.kind)} `, | ||
(0, lib_1.getDisplayName)(props.model), | ||
@@ -19,4 +20,4 @@ (0, lib_1.hasTypeParameters)(props.model) && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
">")), | ||
context.reflectionFlags(props.model)))); | ||
context.reflectionFlags(props.model))))); | ||
}; | ||
exports.header = header; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hierarchy = void 0; | ||
exports.hierarchy = hierarchy; | ||
const utils_1 = require("../../../../utils"); | ||
@@ -21,11 +21,10 @@ const isLinkedReferenceType = (type) => type.visit({ | ||
"(", | ||
utils_1.JSX.createElement("a", { class: "link", href: context.relativeURL("hierarchy.html") + "#" + context.page.model.getFullName() }, "view full"), | ||
utils_1.JSX.createElement("a", { href: context.relativeURL("hierarchy.html") + "#" + context.page.model.getFullName() }, context.i18n.theme_hierarchy_view_full()), | ||
")")) : (utils_1.JSX.createElement(utils_1.JSX.Fragment, null)); | ||
return (utils_1.JSX.createElement("section", { class: "tsd-panel tsd-hierarchy" }, | ||
utils_1.JSX.createElement("h4", null, | ||
"Hierarchy", | ||
context.i18n.theme_hierarchy(), | ||
fullLink), | ||
hierarchyList(context, props))); | ||
} | ||
exports.hierarchy = hierarchy; | ||
function hierarchyList(context, props) { | ||
@@ -32,0 +31,0 @@ return (utils_1.JSX.createElement("ul", { class: "tsd-hierarchy" }, props.types.map((item, i, l) => (utils_1.JSX.createElement("li", null, |
@@ -6,3 +6,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.icons = exports.buildRefIcons = void 0; | ||
exports.icons = void 0; | ||
exports.buildRefIcons = buildRefIcons; | ||
const assert_1 = __importDefault(require("assert")); | ||
@@ -31,3 +32,2 @@ const models_1 = require("../../../../models"); | ||
} | ||
exports.buildRefIcons = buildRefIcons; | ||
exports.icons = { | ||
@@ -80,2 +80,7 @@ [models_1.ReflectionKind.Accessor]: () => kindIcon(utils_1.JSX.createElement("path", { d: "M8.85 16L11.13 7.24H12.582L14.85 16H13.758L13.182 13.672H10.53L9.954 16H8.85ZM10.746 12.76H12.954L12.282 10.06C12.154 9.548 12.054 9.12 11.982 8.776C11.91 8.432 11.866 8.208 11.85 8.104C11.834 8.208 11.79 8.432 11.718 8.776C11.646 9.12 11.546 9.544 11.418 10.048L10.746 12.76Z", fill: "var(--color-text)" }), "#FF4D4D", true), | ||
[models_1.ReflectionKind.Variable]: () => kindIcon(utils_1.JSX.createElement("path", { d: "M11.106 16L8.85 7.24H9.966L11.454 13.192C11.558 13.608 11.646 13.996 11.718 14.356C11.79 14.708 11.842 14.976 11.874 15.16C11.906 14.976 11.954 14.708 12.018 14.356C12.09 13.996 12.178 13.608 12.282 13.192L13.758 7.24H14.85L12.582 16H11.106Z", fill: "var(--color-text)" }), "var(--color-ts-variable)"), | ||
[models_1.ReflectionKind.Document]: () => kindIcon(utils_1.JSX.createElement("g", { stroke: "var(--color-text)", fill: "var(--color-icon-background)" }, | ||
utils_1.JSX.createElement("polygon", { points: "6,5 6,19 18,19, 18,9 15,5" }), | ||
utils_1.JSX.createElement("line", { x1: "9", y1: "9", x2: "14", y2: "9" }), | ||
utils_1.JSX.createElement("line", { x1: "9", y1: "12", x2: "15", y2: "12" }), | ||
utils_1.JSX.createElement("line", { x1: "9", y1: "15", x2: "15", y2: "15" })), "var(--color-document)"), | ||
chevronDown: () => (utils_1.JSX.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none" }, | ||
@@ -82,0 +87,0 @@ utils_1.JSX.createElement("path", { d: "M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z", fill: "var(--color-text)" }))), |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.index = void 0; | ||
exports.index = index; | ||
const lib_1 = require("../../lib"); | ||
@@ -33,3 +33,4 @@ const utils_1 = require("../../../../utils"); | ||
context.icons.chevronSmall(), | ||
" Index")), | ||
" ", | ||
context.i18n.theme_index())), | ||
utils_1.JSX.createElement("div", { class: "tsd-accordion-details" }, content))); | ||
@@ -39,3 +40,3 @@ } | ||
content = (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("h3", { class: "tsd-index-heading uppercase" }, "Index"), | ||
utils_1.JSX.createElement("h3", { class: "tsd-index-heading uppercase" }, context.i18n.theme_index()), | ||
content)); | ||
@@ -47,2 +48,1 @@ } | ||
} | ||
exports.index = index; |
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
import { JSX } from "../../../../utils"; | ||
import { DeclarationReflection } from "../../../../models"; | ||
export declare function member(context: DefaultThemeRenderContext, props: DeclarationReflection): JSX.Element; | ||
import { type DeclarationReflection, type DocumentReflection } from "../../../../models"; | ||
export declare function member(context: DefaultThemeRenderContext, props: DeclarationReflection | DocumentReflection): JSX.Element; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.memberDeclaration = void 0; | ||
exports.memberDeclaration = memberDeclaration; | ||
const utils_1 = require("../../../../utils"); | ||
@@ -9,3 +9,3 @@ const lib_1 = require("../../lib"); | ||
return (utils_1.JSX.createElement("div", { class: "tsd-type-declaration" }, | ||
utils_1.JSX.createElement("h4", null, "Type declaration"), | ||
utils_1.JSX.createElement("h4", null, context.i18n.theme_type_declaration()), | ||
context.parameter(type.declaration))); | ||
@@ -41,2 +41,1 @@ } | ||
} | ||
exports.memberDeclaration = memberDeclaration; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.member = void 0; | ||
exports.member = member; | ||
const lib_1 = require("../../lib"); | ||
@@ -15,2 +15,14 @@ const utils_1 = require("../../../../utils"); | ||
}); | ||
// With the default url derivation, we'll never hit this case as documents are always placed into their | ||
// own pages. Handle it here in case someone creates a custom url scheme which embeds guides within the page. | ||
if (props.isDocument()) { | ||
return (utils_1.JSX.createElement("section", { class: (0, lib_1.classNames)({ "tsd-panel": true, "tsd-member": true }, context.getReflectionClasses(props)) }, | ||
utils_1.JSX.createElement("a", { id: props.anchor, class: "tsd-anchor" }), | ||
!!props.name && (utils_1.JSX.createElement("h3", { class: "tsd-anchor-link" }, | ||
context.reflectionFlags(props), | ||
utils_1.JSX.createElement("span", { class: (0, lib_1.classNames)({ deprecated: props.isDeprecated() }) }, (0, lib_1.wbr)(props.name)), | ||
(0, anchor_icon_1.anchorIcon)(context, props.anchor))), | ||
utils_1.JSX.createElement("div", { class: "tsd-comment tsd-typography" }, | ||
utils_1.JSX.createElement(utils_1.Raw, { html: context.markdown(props.content) })))); | ||
} | ||
return (utils_1.JSX.createElement("section", { class: (0, lib_1.classNames)({ "tsd-panel": true, "tsd-member": true }, context.getReflectionClasses(props)) }, | ||
@@ -31,2 +43,1 @@ utils_1.JSX.createElement("a", { id: props.anchor, class: "tsd-anchor" }), | ||
} | ||
exports.member = member; |
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
import { JSX } from "../../../../utils"; | ||
import type { ReferenceReflection } from "../../../../models"; | ||
export declare const memberReference: ({ urlTo }: DefaultThemeRenderContext, props: ReferenceReflection) => JSX.Element; | ||
export declare const memberReference: ({ urlTo, i18n }: DefaultThemeRenderContext, props: ReferenceReflection) => JSX.Element; |
@@ -5,18 +5,21 @@ "use strict"; | ||
const utils_1 = require("../../../../utils"); | ||
const memberReference = ({ urlTo }, props) => { | ||
const memberReference = ({ urlTo, i18n }, props) => { | ||
const referenced = props.tryGetTargetReflectionDeep(); | ||
if (!referenced) { | ||
return utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
"Re-exports ", | ||
props.name); | ||
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
i18n.theme_re_exports(), | ||
" ", | ||
props.name)); | ||
} | ||
if (props.name === referenced.name) { | ||
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
"Re-exports ", | ||
i18n.theme_re_exports(), | ||
" ", | ||
utils_1.JSX.createElement("a", { href: urlTo(referenced) }, referenced.name))); | ||
} | ||
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
"Renames and re-exports ", | ||
i18n.theme_renames_and_re_exports(), | ||
" ", | ||
utils_1.JSX.createElement("a", { href: urlTo(referenced) }, referenced.name))); | ||
}; | ||
exports.memberReference = memberReference; |
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
import { JSX } from "../../../../utils"; | ||
import { SignatureReflection } from "../../../../models"; | ||
import { type SignatureReflection } from "../../../../models"; | ||
export declare function memberSignatureBody(context: DefaultThemeRenderContext, props: SignatureReflection, { hideSources }?: { | ||
hideSources?: boolean; | ||
}): JSX.Element; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.memberSignatureBody = void 0; | ||
exports.memberSignatureBody = memberSignatureBody; | ||
const utils_1 = require("../../../../utils"); | ||
@@ -14,3 +14,3 @@ const models_1 = require("../../../../models"); | ||
props.parameters && props.parameters.length > 0 && (utils_1.JSX.createElement("div", { class: "tsd-parameters" }, | ||
utils_1.JSX.createElement("h4", { class: "tsd-parameters-title" }, "Parameters"), | ||
utils_1.JSX.createElement("h4", { class: "tsd-parameters-title" }, context.i18n.kind_plural_parameter()), | ||
utils_1.JSX.createElement("ul", { class: "tsd-parameter-list" }, props.parameters.map((item) => (utils_1.JSX.createElement("li", null, | ||
@@ -31,3 +31,4 @@ utils_1.JSX.createElement("span", null, | ||
utils_1.JSX.createElement("h4", { class: "tsd-returns-title" }, | ||
"Returns ", | ||
context.i18n.theme_returns(), | ||
" ", | ||
context.type(props.type)), | ||
@@ -39,2 +40,1 @@ returnsTag && utils_1.JSX.createElement(utils_1.Raw, { html: context.markdown(returnsTag.content) }), | ||
} | ||
exports.memberSignatureBody = memberSignatureBody; |
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
import { JSX } from "../../../../utils"; | ||
import { SignatureReflection } from "../../../../models"; | ||
import { type SignatureReflection } from "../../../../models"; | ||
export declare function memberSignatureTitle(context: DefaultThemeRenderContext, props: SignatureReflection, { hideName, arrowStyle }?: { | ||
@@ -5,0 +5,0 @@ hideName?: boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.memberSignatureTitle = void 0; | ||
exports.memberSignatureTitle = memberSignatureTitle; | ||
const lib_1 = require("../../lib"); | ||
@@ -38,2 +38,1 @@ const utils_1 = require("../../../../utils"); | ||
} | ||
exports.memberSignatureTitle = memberSignatureTitle; |
@@ -8,3 +8,4 @@ "use strict"; | ||
return (utils_1.JSX.createElement("li", null, | ||
"Defined in ", | ||
context.i18n.theme_defined_in(), | ||
" ", | ||
item.fileName, | ||
@@ -16,3 +17,4 @@ ":", | ||
return (utils_1.JSX.createElement("li", null, | ||
"Defined in ", | ||
context.i18n.theme_defined_in(), | ||
" ", | ||
utils_1.JSX.createElement("a", { href: item.url, class: "external", target: "_blank" }, | ||
@@ -24,3 +26,4 @@ item.fileName, | ||
return (utils_1.JSX.createElement("li", null, | ||
"Defined in ", | ||
context.i18n.theme_defined_in(), | ||
" ", | ||
utils_1.JSX.createElement("a", { href: item.url }, | ||
@@ -35,3 +38,4 @@ item.fileName, | ||
sources.push(utils_1.JSX.createElement("p", null, | ||
"Implementation of ", | ||
context.i18n.theme_implementation_of(), | ||
" ", | ||
context.typeAndParent(props.implementationOf))); | ||
@@ -41,3 +45,4 @@ } | ||
sources.push(utils_1.JSX.createElement("p", null, | ||
"Inherited from ", | ||
context.i18n.theme_inherited_from(), | ||
" ", | ||
context.typeAndParent(props.inheritedFrom))); | ||
@@ -47,3 +52,4 @@ } | ||
sources.push(utils_1.JSX.createElement("p", null, | ||
"Overrides ", | ||
context.i18n.theme_overrides(), | ||
" ", | ||
context.typeAndParent(props.overwrites))); | ||
@@ -50,0 +56,0 @@ } |
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
import { JSX } from "../../../../utils"; | ||
import { ContainerReflection } from "../../../../models"; | ||
import { type ContainerReflection } from "../../../../models"; | ||
export declare function members(context: DefaultThemeRenderContext, props: ContainerReflection): JSX.Element; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.membersGroup = void 0; | ||
exports.membersGroup = membersGroup; | ||
const utils_1 = require("../../../../utils"); | ||
@@ -19,2 +19,1 @@ function membersGroup(context, group) { | ||
} | ||
exports.membersGroup = membersGroup; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.members = void 0; | ||
exports.members = members; | ||
const utils_1 = require("../../../../utils"); | ||
@@ -15,2 +15,1 @@ const models_1 = require("../../../../models"); | ||
} | ||
exports.members = members; |
@@ -1,2 +0,2 @@ | ||
import { Reflection } from "../../../../models"; | ||
import { type Reflection } from "../../../../models"; | ||
import { JSX } from "../../../../utils"; | ||
@@ -3,0 +3,0 @@ import type { PageEvent } from "../../../events"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pageNavigation = exports.pageSidebar = exports.navigation = exports.settings = exports.sidebarLinks = exports.sidebar = void 0; | ||
exports.navigation = void 0; | ||
exports.sidebar = sidebar; | ||
exports.sidebarLinks = sidebarLinks; | ||
exports.settings = settings; | ||
exports.pageSidebar = pageSidebar; | ||
exports.pageNavigation = pageNavigation; | ||
const models_1 = require("../../../../models"); | ||
@@ -12,3 +17,2 @@ const utils_1 = require("../../../../utils"); | ||
} | ||
exports.sidebar = sidebar; | ||
function buildFilterItem(context, name, displayName, defaultValue) { | ||
@@ -23,7 +27,9 @@ return (utils_1.JSX.createElement("li", { class: "tsd-filter-item" }, | ||
const links = Object.entries(context.options.getValue("sidebarLinks")); | ||
if (!links.length) | ||
const navLinks = Object.entries(context.options.getValue("navigationLinks")); | ||
if (!links.length && !navLinks.length) | ||
return null; | ||
return (utils_1.JSX.createElement("nav", { id: "tsd-sidebar-links", class: "tsd-navigation" }, links.map(([label, url]) => (utils_1.JSX.createElement("a", { href: url }, label))))); | ||
return (utils_1.JSX.createElement("nav", { id: "tsd-sidebar-links", class: "tsd-navigation" }, | ||
links.map(([label, url]) => (utils_1.JSX.createElement("a", { href: url }, label))), | ||
navLinks.map(([label, url]) => (utils_1.JSX.createElement("a", { href: url, class: "tsd-nav-link" }, label))))); | ||
} | ||
exports.sidebarLinks = sidebarLinks; | ||
function settings(context) { | ||
@@ -53,16 +59,15 @@ const defaultFilters = context.options.getValue("visibilityFilters"); | ||
context.icons.chevronDown(), | ||
"Settings")), | ||
context.i18n.theme_settings())), | ||
utils_1.JSX.createElement("div", { class: "tsd-accordion-details" }, | ||
visibilityOptions.length && (utils_1.JSX.createElement("div", { class: "tsd-filter-visibility" }, | ||
utils_1.JSX.createElement("h4", { class: "uppercase" }, "Member Visibility"), | ||
utils_1.JSX.createElement("h4", { class: "uppercase" }, context.i18n.theme_member_visibility()), | ||
utils_1.JSX.createElement("form", null, | ||
utils_1.JSX.createElement("ul", { id: "tsd-filter-options" }, ...visibilityOptions)))), | ||
utils_1.JSX.createElement("div", { class: "tsd-theme-toggle" }, | ||
utils_1.JSX.createElement("h4", { class: "uppercase" }, "Theme"), | ||
utils_1.JSX.createElement("h4", { class: "uppercase" }, context.i18n.theme_theme()), | ||
utils_1.JSX.createElement("select", { id: "tsd-theme" }, | ||
utils_1.JSX.createElement("option", { value: "os" }, "OS"), | ||
utils_1.JSX.createElement("option", { value: "light" }, "Light"), | ||
utils_1.JSX.createElement("option", { value: "dark" }, "Dark"))))))); | ||
utils_1.JSX.createElement("option", { value: "os" }, context.i18n.theme_os()), | ||
utils_1.JSX.createElement("option", { value: "light" }, context.i18n.theme_light()), | ||
utils_1.JSX.createElement("option", { value: "dark" }, context.i18n.theme_dark()))))))); | ||
} | ||
exports.settings = settings; | ||
const navigation = function navigation(context, props) { | ||
@@ -82,3 +87,2 @@ return (utils_1.JSX.createElement("nav", { class: "tsd-navigation" }, | ||
} | ||
exports.pageSidebar = pageSidebar; | ||
function pageNavigation(context, props) { | ||
@@ -120,5 +124,4 @@ const levels = [[]]; | ||
context.icons.chevronDown(), | ||
"On This Page")), | ||
context.i18n.theme_on_this_page())), | ||
utils_1.JSX.createElement("div", { class: "tsd-accordion-details" }, levels[0]))); | ||
} | ||
exports.pageNavigation = pageNavigation; |
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
import { JSX } from "../../../../utils"; | ||
import { DeclarationReflection } from "../../../../models"; | ||
import { type DeclarationReflection } from "../../../../models"; | ||
export declare const parameter: (context: DefaultThemeRenderContext, props: DeclarationReflection) => JSX.Element; |
@@ -17,17 +17,3 @@ "use strict"; | ||
})))))))), | ||
!!props.indexSignature && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("li", { class: "tsd-parameter-index-signature" }, | ||
utils_1.JSX.createElement("h5", null, | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "["), | ||
props.indexSignature?.parameters?.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
!!item.flags.isRest && utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "..."), | ||
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(item) }, item.name), | ||
": ", | ||
context.type(item.type)))), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "]: "), | ||
context.type(props.indexSignature.type)), | ||
context.commentSummary(props.indexSignature), | ||
context.commentTags(props.indexSignature), | ||
props.indexSignature.type instanceof models_1.ReflectionType && | ||
context.parameter(props.indexSignature.type.declaration)))), | ||
props.indexSignatures?.map((index) => renderParamIndexSignature(context, index)), | ||
props.children?.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, item.signatures ? (utils_1.JSX.createElement("li", { class: "tsd-parameter" }, | ||
@@ -81,1 +67,15 @@ utils_1.JSX.createElement("h5", null, | ||
exports.parameter = parameter; | ||
function renderParamIndexSignature(context, index) { | ||
return (utils_1.JSX.createElement("li", { class: "tsd-parameter-index-signature" }, | ||
utils_1.JSX.createElement("h5", null, | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "["), | ||
index.parameters.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(item) }, item.name), | ||
": ", | ||
context.type(item.type)))), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "]: "), | ||
context.type(index.type)), | ||
context.commentSummary(index), | ||
context.commentTags(index), | ||
index.type instanceof models_1.ReflectionType && context.parameter(index.type.declaration))); | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.reflectionPreview = void 0; | ||
exports.reflectionPreview = reflectionPreview; | ||
const models_1 = require("../../../../models"); | ||
@@ -21,2 +21,1 @@ const utils_1 = require("../../../../utils"); | ||
} | ||
exports.reflectionPreview = reflectionPreview; |
@@ -11,11 +11,11 @@ "use strict"; | ||
utils_1.JSX.createElement("label", { for: "tsd-search-field", class: "tsd-widget tsd-toolbar-icon search no-caption" }, context.icons.search()), | ||
utils_1.JSX.createElement("input", { type: "text", id: "tsd-search-field", "aria-label": "Search" })), | ||
utils_1.JSX.createElement("input", { type: "text", id: "tsd-search-field", "aria-label": context.i18n.theme_search() })), | ||
utils_1.JSX.createElement("div", { class: "field" }, | ||
utils_1.JSX.createElement("div", { id: "tsd-toolbar-links" }, Object.entries(context.options.getValue("navigationLinks")).map(([label, url]) => (utils_1.JSX.createElement("a", { href: url }, label))))), | ||
utils_1.JSX.createElement("ul", { class: "results" }, | ||
utils_1.JSX.createElement("li", { class: "state loading" }, "Preparing search index..."), | ||
utils_1.JSX.createElement("li", { class: "state failure" }, "The search index is not available")), | ||
utils_1.JSX.createElement("li", { class: "state loading" }, context.i18n.theme_preparing_search_index()), | ||
utils_1.JSX.createElement("li", { class: "state failure" }, context.i18n.theme_search_index_not_available())), | ||
utils_1.JSX.createElement("a", { href: context.options.getValue("titleLink") || context.relativeURL("index.html"), class: "title" }, (0, lib_1.getDisplayName)(props.project))), | ||
utils_1.JSX.createElement("div", { class: "table-cell", id: "tsd-widgets" }, | ||
utils_1.JSX.createElement("a", { href: "#", class: "tsd-widget tsd-toolbar-icon menu no-caption", "data-toggle": "menu", "aria-label": "Menu" }, context.icons.menu()))))); | ||
utils_1.JSX.createElement("a", { href: "#", class: "tsd-widget tsd-toolbar-icon menu no-caption", "data-toggle": "menu", "aria-label": context.i18n.theme_menu() }, context.icons.menu()))))); | ||
exports.toolbar = toolbar; |
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
import { Type } from "../../../../models"; | ||
import { type Type } from "../../../../models"; | ||
import { JSX } from "../../../../utils"; | ||
@@ -4,0 +4,0 @@ export declare function validateStateIsClean(page: string): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.type = exports.validateStateIsClean = void 0; | ||
exports.validateStateIsClean = validateStateIsClean; | ||
exports.type = type; | ||
const models_1 = require("../../../../models"); | ||
@@ -62,3 +63,2 @@ const utils_1 = require("../../../../utils"); | ||
} | ||
exports.validateStateIsClean = validateStateIsClean; | ||
// The type helper accepts an optional needsParens parameter that is checked | ||
@@ -266,13 +266,14 @@ // if an inner type may result in invalid output without them. For example: | ||
} | ||
if (type.declaration.indexSignature) { | ||
const index = type.declaration.indexSignature; | ||
members.push(utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
"[", | ||
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(type.declaration.indexSignature) }, index.parameters[0].name), | ||
":", | ||
" ", | ||
renderType(context, index.parameters[0].type, models_1.TypeContext.none), | ||
"]", | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, ": "), | ||
renderType(context, index.type, models_1.TypeContext.none))); | ||
if (type.declaration.indexSignatures) { | ||
for (const index of type.declaration.indexSignatures) { | ||
members.push(utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
"[", | ||
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(index) }, index.parameters[0].name), | ||
":", | ||
" ", | ||
renderType(context, index.parameters[0].type, models_1.TypeContext.none), | ||
"]", | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, ": "), | ||
renderType(context, index.type, models_1.TypeContext.none))); | ||
} | ||
} | ||
@@ -367,2 +368,1 @@ if (!members.length && type.declaration.signatures?.length === 1) { | ||
} | ||
exports.type = type; |
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
import { Type } from "../../../../models"; | ||
import { type Type } from "../../../../models"; | ||
import { JSX } from "../../../../utils"; | ||
export declare const typeAndParent: (context: DefaultThemeRenderContext, props: Type) => JSX.Element; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.typeParameters = void 0; | ||
exports.typeParameters = typeParameters; | ||
const utils_1 = require("../../../../utils"); | ||
@@ -8,3 +8,3 @@ function typeParameters(context, typeParameters) { | ||
utils_1.JSX.createElement("section", { class: "tsd-panel" }, | ||
utils_1.JSX.createElement("h4", null, "Type Parameters"), | ||
utils_1.JSX.createElement("h4", null, context.i18n.kind_plural_type_parameter()), | ||
utils_1.JSX.createElement("ul", { class: "tsd-type-parameter-list" }, typeParameters?.map((item) => (utils_1.JSX.createElement("li", null, | ||
@@ -27,2 +27,1 @@ utils_1.JSX.createElement("span", null, | ||
} | ||
exports.typeParameters = typeParameters; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hierarchyTemplate = void 0; | ||
exports.hierarchyTemplate = hierarchyTemplate; | ||
const utils_1 = require("../../../../utils"); | ||
@@ -31,2 +31,1 @@ const lib_1 = require("../../lib"); | ||
} | ||
exports.hierarchyTemplate = hierarchyTemplate; |
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
import type { PageEvent } from "../../../events"; | ||
import { ContainerReflection } from "../../../../models"; | ||
import { type ContainerReflection } from "../../../../models"; | ||
import { JSX } from "../../../../utils"; | ||
export declare function reflectionTemplate(context: DefaultThemeRenderContext, props: PageEvent<ContainerReflection>): JSX.Element; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.reflectionTemplate = void 0; | ||
exports.reflectionTemplate = reflectionTemplate; | ||
const lib_1 = require("../../lib"); | ||
@@ -28,22 +28,11 @@ const models_1 = require("../../../../models"); | ||
!!props.model.implementedTypes && (utils_1.JSX.createElement("section", { class: "tsd-panel" }, | ||
utils_1.JSX.createElement("h4", null, "Implements"), | ||
utils_1.JSX.createElement("h4", null, context.i18n.theme_implements()), | ||
utils_1.JSX.createElement("ul", { class: "tsd-hierarchy" }, props.model.implementedTypes.map((item) => (utils_1.JSX.createElement("li", null, context.type(item))))))), | ||
!!props.model.implementedBy && (utils_1.JSX.createElement("section", { class: "tsd-panel" }, | ||
utils_1.JSX.createElement("h4", null, "Implemented by"), | ||
utils_1.JSX.createElement("h4", null, context.i18n.theme_implemented_by()), | ||
utils_1.JSX.createElement("ul", { class: "tsd-hierarchy" }, props.model.implementedBy.map((item) => (utils_1.JSX.createElement("li", null, context.type(item))))))), | ||
!!props.model.signatures && (utils_1.JSX.createElement("section", { class: "tsd-panel" }, context.memberSignatures(props.model))), | ||
!!props.model.indexSignature && (utils_1.JSX.createElement("section", { class: (0, lib_1.classNames)({ "tsd-panel": true }, context.getReflectionClasses(props.model)) }, | ||
utils_1.JSX.createElement("h4", { class: "tsd-before-signature" }, "Indexable"), | ||
utils_1.JSX.createElement("div", { class: "tsd-signature" }, | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "["), | ||
props.model.indexSignature.parameters.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
item.name, | ||
": ", | ||
context.type(item.type)))), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "]: "), | ||
context.type(props.model.indexSignature.type)), | ||
context.commentSummary(props.model.indexSignature), | ||
context.commentTags(props.model.indexSignature), | ||
props.model.indexSignature?.type instanceof models_1.ReflectionType && | ||
context.parameter(props.model.indexSignature.type.declaration))), | ||
!!props.model.signatures?.length && (utils_1.JSX.createElement("section", { class: "tsd-panel" }, context.memberSignatures(props.model))), | ||
!!props.model.indexSignatures?.length && (utils_1.JSX.createElement("section", { class: (0, lib_1.classNames)({ "tsd-panel": true }, context.getReflectionClasses(props.model)) }, | ||
utils_1.JSX.createElement("h4", { class: "tsd-before-signature" }, context.i18n.theme_indexable()), | ||
props.model.indexSignatures.map((index) => renderIndexSignature(context, index)))), | ||
!props.model.signatures && context.memberSources(props.model))), | ||
@@ -53,2 +42,15 @@ !!props.model.children?.length && context.index(props.model), | ||
} | ||
exports.reflectionTemplate = reflectionTemplate; | ||
function renderIndexSignature(context, index) { | ||
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("div", { class: "tsd-signature" }, | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "["), | ||
index.parameters.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(item) }, item.name), | ||
": ", | ||
context.type(item.type)))), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "]: "), | ||
context.type(index.type)), | ||
context.commentSummary(index), | ||
context.commentTags(index), | ||
index.type instanceof models_1.ReflectionType && context.parameter(index.type.declaration))); | ||
} |
import type { DefaultThemeRenderContext } from ".."; | ||
import { DeclarationReflection, ProjectReflection, Reflection, TypeParameterReflection } from "../../models"; | ||
import { DeclarationReflection, ProjectReflection, type Reflection, type TypeParameterReflection } from "../../models"; | ||
import { JSX } from "../../utils"; | ||
@@ -4,0 +4,0 @@ export declare function stringify(data: unknown): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getHierarchyRoots = exports.renderName = exports.camelToTitleCase = exports.renderTypeParametersSignature = exports.hasTypeParameters = exports.classNames = exports.join = exports.wbr = exports.getKindClass = exports.toStyleClass = exports.getDisplayName = exports.stringify = void 0; | ||
exports.stringify = stringify; | ||
exports.getDisplayName = getDisplayName; | ||
exports.toStyleClass = toStyleClass; | ||
exports.getKindClass = getKindClass; | ||
exports.wbr = wbr; | ||
exports.join = join; | ||
exports.classNames = classNames; | ||
exports.hasTypeParameters = hasTypeParameters; | ||
exports.renderTypeParametersSignature = renderTypeParametersSignature; | ||
exports.camelToTitleCase = camelToTitleCase; | ||
exports.renderName = renderName; | ||
exports.getHierarchyRoots = getHierarchyRoots; | ||
const models_1 = require("../../models"); | ||
@@ -12,3 +23,2 @@ const utils_1 = require("../../utils"); | ||
} | ||
exports.stringify = stringify; | ||
function getDisplayName(refl) { | ||
@@ -21,7 +31,5 @@ let version = ""; | ||
} | ||
exports.getDisplayName = getDisplayName; | ||
function toStyleClass(str) { | ||
return str.replace(/(\w)([A-Z])/g, (_m, m1, m2) => m1 + "-" + m2).toLowerCase(); | ||
} | ||
exports.toStyleClass = toStyleClass; | ||
function getKindClass(refl) { | ||
@@ -33,3 +41,2 @@ if (refl instanceof models_1.ReferenceReflection) { | ||
} | ||
exports.getKindClass = getKindClass; | ||
/** | ||
@@ -56,3 +63,2 @@ * Insert word break tags ``<wbr>`` into the given string. | ||
} | ||
exports.wbr = wbr; | ||
function join(joiner, list, cb) { | ||
@@ -68,3 +74,2 @@ const result = []; | ||
} | ||
exports.join = join; | ||
function classNames(names, extraCss) { | ||
@@ -79,3 +84,2 @@ const css = Object.keys(names) | ||
} | ||
exports.classNames = classNames; | ||
function hasTypeParameters(reflection) { | ||
@@ -86,3 +90,2 @@ return ((reflection instanceof models_1.DeclarationReflection || reflection instanceof models_1.SignatureReflection) && | ||
} | ||
exports.hasTypeParameters = hasTypeParameters; | ||
function renderTypeParametersSignature(context, typeParameters) { | ||
@@ -112,7 +115,5 @@ if (!typeParameters || typeParameters.length === 0) | ||
} | ||
exports.renderTypeParametersSignature = renderTypeParametersSignature; | ||
function camelToTitleCase(text) { | ||
return text.substring(0, 1).toUpperCase() + text.substring(1).replace(/[a-z][A-Z]/g, (x) => `${x[0]} ${x[1]}`); | ||
} | ||
exports.camelToTitleCase = camelToTitleCase; | ||
/** | ||
@@ -122,5 +123,2 @@ * Renders the reflection name with an additional `?` if optional. | ||
function renderName(refl) { | ||
if (!refl.name) { | ||
return utils_1.JSX.createElement("em", null, wbr(models_1.ReflectionKind.singularString(refl.kind))); | ||
} | ||
if (refl.flags.isOptional) { | ||
@@ -133,3 +131,2 @@ return utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
} | ||
exports.renderName = renderName; | ||
function getHierarchyRoots(project) { | ||
@@ -157,2 +154,1 @@ const allClasses = project.getReflectionsByKind(models_1.ReflectionKind.ClassOrInterface); | ||
} | ||
exports.getHierarchyRoots = getHierarchyRoots; |
import { ContextAwareRendererComponent } from "../components"; | ||
import { RendererEvent, MarkdownEvent, PageEvent } from "../events"; | ||
import type { Theme } from "shiki"; | ||
import { type RendererEvent, MarkdownEvent, type PageEvent } from "../events"; | ||
import type { BundledTheme } from "shiki" with { "resolution-mode": "import" }; | ||
import type { DefaultThemeRenderContext } from ".."; | ||
/** | ||
@@ -9,25 +10,12 @@ * Implements markdown and relativeURL helpers for templates. | ||
export declare class MarkedPlugin extends ContextAwareRendererComponent { | ||
accessor includeSource: string; | ||
accessor mediaSource: string; | ||
accessor lightTheme: Theme; | ||
accessor darkTheme: Theme; | ||
accessor lightTheme: BundledTheme; | ||
accessor darkTheme: BundledTheme; | ||
private parser?; | ||
/** | ||
* The path referenced files are located in. | ||
* This needing to be here really feels hacky... probably some nicer way to do this. | ||
* Revisit when adding support for arbitrary pages in 0.26. | ||
*/ | ||
private includes?; | ||
private renderContext; | ||
private lastHeaderSlug; | ||
/** | ||
* Path to the output media directory. | ||
*/ | ||
private mediaDirectory?; | ||
/** | ||
* The pattern used to find references in markdown. | ||
*/ | ||
private includePattern; | ||
/** | ||
* The pattern used to find media links. | ||
*/ | ||
private mediaPattern; | ||
private sources?; | ||
private outputFileName?; | ||
/** | ||
* Create a new MarkedPlugin instance. | ||
@@ -50,3 +38,3 @@ */ | ||
*/ | ||
parseMarkdown(text: string, page: PageEvent<any>): string; | ||
parseMarkdown(text: string, page: PageEvent<any>, context: DefaultThemeRenderContext): string; | ||
/** | ||
@@ -58,2 +46,3 @@ * Triggered before the renderer starts rendering a project. | ||
protected onBeginRenderer(event: RendererEvent): void; | ||
private getSlugger; | ||
/** | ||
@@ -64,3 +53,3 @@ * Creates an object with options that are passed to the markdown parser. | ||
*/ | ||
private createMarkedOptions; | ||
private setupParser; | ||
/** | ||
@@ -67,0 +56,0 @@ * Triggered when {@link MarkedPlugin} parses a markdown string. |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { | ||
@@ -52,9 +36,2 @@ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) { | ||
@@ -75,7 +52,8 @@ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MarkedPlugin = void 0; | ||
const fs = __importStar(require("fs")); | ||
const Path = __importStar(require("path")); | ||
const Marked = __importStar(require("marked")); | ||
const markdown_it_1 = __importDefault(require("markdown-it")); | ||
const components_1 = require("../components"); | ||
@@ -86,2 +64,12 @@ const events_1 = require("../events"); | ||
const html_1 = require("../../utils/html"); | ||
const DefaultTheme_1 = require("./default/DefaultTheme"); | ||
const anchor_icon_1 = require("./default/partials/anchor-icon"); | ||
let defaultSlugger; | ||
function getDefaultSlugger(logger) { | ||
if (!defaultSlugger) { | ||
logger.warn(logger.i18n.custom_theme_does_not_define_getSlugger()); | ||
defaultSlugger = new DefaultTheme_1.Slugger(); | ||
} | ||
return defaultSlugger; | ||
} | ||
/** | ||
@@ -92,3 +80,3 @@ * Implements markdown and relativeURL helpers for templates. | ||
let MarkedPlugin = (() => { | ||
var _MarkedPlugin_includeSource_accessor_storage, _MarkedPlugin_mediaSource_accessor_storage, _MarkedPlugin_lightTheme_accessor_storage, _MarkedPlugin_darkTheme_accessor_storage; | ||
var _MarkedPlugin_lightTheme_accessor_storage, _MarkedPlugin_darkTheme_accessor_storage; | ||
let _classDecorators = [(0, components_1.Component)({ name: "marked" })]; | ||
@@ -99,8 +87,2 @@ let _classDescriptor; | ||
let _classSuper = components_1.ContextAwareRendererComponent; | ||
let _includeSource_decorators; | ||
let _includeSource_initializers = []; | ||
let _includeSource_extraInitializers = []; | ||
let _mediaSource_decorators; | ||
let _mediaSource_initializers = []; | ||
let _mediaSource_extraInitializers = []; | ||
let _lightTheme_decorators; | ||
@@ -115,23 +97,12 @@ let _lightTheme_initializers = []; | ||
super(...arguments); | ||
_MarkedPlugin_includeSource_accessor_storage.set(this, __runInitializers(this, _includeSource_initializers, void 0)); | ||
_MarkedPlugin_mediaSource_accessor_storage.set(this, (__runInitializers(this, _includeSource_extraInitializers), __runInitializers(this, _mediaSource_initializers, void 0))); | ||
_MarkedPlugin_lightTheme_accessor_storage.set(this, (__runInitializers(this, _mediaSource_extraInitializers), __runInitializers(this, _lightTheme_initializers, void 0))); | ||
_MarkedPlugin_lightTheme_accessor_storage.set(this, __runInitializers(this, _lightTheme_initializers, void 0)); | ||
_MarkedPlugin_darkTheme_accessor_storage.set(this, (__runInitializers(this, _lightTheme_extraInitializers), __runInitializers(this, _darkTheme_initializers, void 0))); | ||
this.parser = __runInitializers(this, _darkTheme_extraInitializers); | ||
/** | ||
* The path referenced files are located in. | ||
* This needing to be here really feels hacky... probably some nicer way to do this. | ||
* Revisit when adding support for arbitrary pages in 0.26. | ||
*/ | ||
this.includes = __runInitializers(this, _darkTheme_extraInitializers); | ||
/** | ||
* The pattern used to find references in markdown. | ||
*/ | ||
this.includePattern = /\[\[include:([^\]]+?)\]\]/g; | ||
/** | ||
* The pattern used to find media links. | ||
*/ | ||
this.mediaPattern = /media:\/\/([^ ")\]}]+)/g; | ||
this.renderContext = null; | ||
this.lastHeaderSlug = ""; | ||
} | ||
get includeSource() { return __classPrivateFieldGet(this, _MarkedPlugin_includeSource_accessor_storage, "f"); } | ||
set includeSource(value) { __classPrivateFieldSet(this, _MarkedPlugin_includeSource_accessor_storage, value, "f"); } | ||
get mediaSource() { return __classPrivateFieldGet(this, _MarkedPlugin_mediaSource_accessor_storage, "f"); } | ||
set mediaSource(value) { __classPrivateFieldSet(this, _MarkedPlugin_mediaSource_accessor_storage, value, "f"); } | ||
get lightTheme() { return __classPrivateFieldGet(this, _MarkedPlugin_lightTheme_accessor_storage, "f"); } | ||
@@ -159,10 +130,3 @@ set lightTheme(value) { __classPrivateFieldSet(this, _MarkedPlugin_lightTheme_accessor_storage, value, "f"); } | ||
if (!(0, highlighter_1.isSupportedLanguage)(lang)) { | ||
// Extra newline because of the progress bar | ||
this.application.logger.warn(` | ||
Unsupported highlight language "${lang}" will not be highlighted. Run typedoc --help for a list of supported languages. | ||
target code block : | ||
\t${text.split("\n").join("\n\t")} | ||
source files :${this.sources?.map((source) => `\n\t${source.fileName}`).join()} | ||
output file : | ||
\t${this.outputFileName}`); | ||
this.application.logger.warn(this.application.i18n.unsupported_highlight_language_0_not_highlighted_in_comment_for_1(lang, this.page?.model.getFriendlyFullName() ?? "(unknown)")); | ||
return text; | ||
@@ -178,32 +142,7 @@ } | ||
*/ | ||
parseMarkdown(text, page) { | ||
if (this.includes) { | ||
text = text.replace(this.includePattern, (_match, path) => { | ||
path = Path.join(this.includes, path.trim()); | ||
if ((0, utils_1.isFile)(path)) { | ||
const contents = (0, utils_1.readFile)(path); | ||
const event = new events_1.MarkdownEvent(events_1.MarkdownEvent.INCLUDE, page, contents, contents); | ||
this.owner.trigger(event); | ||
return event.parsedText; | ||
} | ||
else { | ||
this.application.logger.warn("Could not find file to include: " + path); | ||
return ""; | ||
} | ||
}); | ||
} | ||
if (this.mediaDirectory) { | ||
text = text.replace(this.mediaPattern, (match, path) => { | ||
const fileName = Path.join(this.mediaDirectory, path); | ||
if ((0, utils_1.isFile)(fileName)) { | ||
return this.getRelativeUrl("media") + "/" + path; | ||
} | ||
else { | ||
this.application.logger.warn("Could not find media file: " + fileName); | ||
return match; | ||
} | ||
}); | ||
} | ||
parseMarkdown(text, page, context) { | ||
this.renderContext = context; | ||
const event = new events_1.MarkdownEvent(events_1.MarkdownEvent.PARSE, page, text, text); | ||
this.owner.trigger(event); | ||
this.renderContext = null; | ||
return event.parsedText; | ||
@@ -218,22 +157,9 @@ } | ||
super.onBeginRenderer(event); | ||
Marked.marked.setOptions(this.createMarkedOptions()); | ||
delete this.includes; | ||
if (this.includeSource) { | ||
if (fs.existsSync(this.includeSource) && fs.statSync(this.includeSource).isDirectory()) { | ||
this.includes = this.includeSource; | ||
} | ||
else { | ||
this.application.logger.warn("Could not find provided includes directory: " + this.includeSource); | ||
} | ||
this.setupParser(); | ||
} | ||
getSlugger() { | ||
if ("getSlugger" in this.owner.theme) { | ||
return this.owner.theme.getSlugger(this.page.model); | ||
} | ||
if (this.mediaSource) { | ||
if (fs.existsSync(this.mediaSource) && fs.statSync(this.mediaSource).isDirectory()) { | ||
this.mediaDirectory = Path.join(event.outputDirectory, "media"); | ||
(0, utils_1.copySync)(this.mediaSource, this.mediaDirectory); | ||
} | ||
else { | ||
this.mediaDirectory = undefined; | ||
this.application.logger.warn("Could not find provided media directory: " + this.mediaSource); | ||
} | ||
} | ||
return getDefaultSlugger(this.application.logger); | ||
} | ||
@@ -245,33 +171,45 @@ /** | ||
*/ | ||
createMarkedOptions() { | ||
const markedOptions = (this.application.options.getValue("markedOptions") ?? {}); | ||
// Set some default values if they are not specified via the TypeDoc option | ||
markedOptions.highlight ??= (text, lang) => this.getHighlighted(text, lang); | ||
if (!markedOptions.renderer) { | ||
markedOptions.renderer = new Marked.Renderer(); | ||
markedOptions.renderer.link = (href, title, text) => { | ||
// Prefix the #anchor links `#md:`. | ||
const target = href?.replace(/^#(?:md:)?(.+)/, "#md:$1") || undefined; | ||
return (0, utils_1.renderElement)(utils_1.JSX.createElement("a", { href: target, title: title || undefined }, | ||
utils_1.JSX.createElement(utils_1.JSX.Raw, { html: text }))); | ||
}; | ||
markedOptions.renderer.heading = (text, level, _, slugger) => { | ||
const slug = slugger.slug(text); | ||
// Prefix the slug with an extra `md:` to prevent conflicts with TypeDoc's anchors. | ||
this.page.pageHeadings.push({ | ||
link: `#md:${slug}`, | ||
text: (0, html_1.getTextContent)(text), | ||
level, | ||
}); | ||
const H = `h${level}`; | ||
return (0, utils_1.renderElement)(utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("a", { id: `md:${slug}`, class: "tsd-anchor" }), | ||
utils_1.JSX.createElement(H, null, | ||
utils_1.JSX.createElement("a", { href: `#md:${slug}` }, | ||
utils_1.JSX.createElement(utils_1.JSX.Raw, { html: text }))))); | ||
}; | ||
markedOptions.renderer.code = renderCode; | ||
} | ||
markedOptions.mangle ??= false; // See https://github.com/TypeStrong/typedoc/issues/1395 | ||
return markedOptions; | ||
setupParser() { | ||
this.parser = (0, markdown_it_1.default)({ | ||
...this.application.options.getValue("markdownItOptions"), | ||
html: true, | ||
highlight: (code, lang) => { | ||
code = (0, highlighter_1.highlight)(code, lang || "ts"); | ||
code = code.replace(/\n$/, "") + "\n"; | ||
if (!lang) { | ||
return `<pre><code>${code}</code><button>Copy</button></pre>\n`; | ||
} | ||
return `<pre><code class="${(0, html_1.escapeHtml)(lang)}">${code}</code><button>Copy</button></pre>\n`; | ||
}, | ||
}); | ||
const loader = this.application.options.getValue("markdownItLoader"); | ||
loader(this.parser); | ||
// Add anchor links for headings in readme, and add them to the "On this page" section | ||
this.parser.renderer.rules["heading_open"] = (tokens, idx) => { | ||
const token = tokens[idx]; | ||
const content = tokens[idx + 1].content; | ||
const level = token.markup.length; | ||
const slug = this.getSlugger().slug(content); | ||
this.lastHeaderSlug = slug; | ||
// Prefix the slug with an extra `md:` to prevent conflicts with TypeDoc's anchors. | ||
this.page.pageHeadings.push({ | ||
link: `#md:${slug}`, | ||
text: (0, html_1.getTextContent)(content), | ||
level, | ||
}); | ||
return `<a id="md:${slug}" class="tsd-anchor"></a><${token.tag} class="tsd-anchor-link">`; | ||
}; | ||
this.parser.renderer.rules["heading_close"] = (tokens, idx) => { | ||
return `${(0, utils_1.renderElement)((0, anchor_icon_1.anchorIcon)(this.renderContext, `md:${this.lastHeaderSlug}`))}</${tokens[idx].tag}>`; | ||
}; | ||
// Rewrite anchor links inline in a readme file to links targeting the `md:` prefixed anchors | ||
// that TypeDoc creates. | ||
this.parser.renderer.rules["link_open"] = (tokens, idx, options, _env, self) => { | ||
const token = tokens[idx]; | ||
const href = token.attrGet("href")?.replace(/^#(?:md:)?(.+)/, "#md:$1"); | ||
if (href) { | ||
token.attrSet("href", href); | ||
} | ||
return self.renderToken(tokens, idx, options); | ||
}; | ||
} | ||
@@ -284,7 +222,5 @@ /** | ||
onParseMarkdown(event) { | ||
event.parsedText = Marked.marked(event.parsedText); | ||
event.parsedText = this.parser.render(event.parsedText); | ||
} | ||
}; | ||
_MarkedPlugin_includeSource_accessor_storage = new WeakMap(); | ||
_MarkedPlugin_mediaSource_accessor_storage = new WeakMap(); | ||
_MarkedPlugin_lightTheme_accessor_storage = new WeakMap(); | ||
@@ -295,8 +231,4 @@ _MarkedPlugin_darkTheme_accessor_storage = new WeakMap(); | ||
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; | ||
_includeSource_decorators = [(0, utils_1.Option)("includes")]; | ||
_mediaSource_decorators = [(0, utils_1.Option)("media")]; | ||
_lightTheme_decorators = [(0, utils_1.Option)("lightHighlightTheme")]; | ||
_darkTheme_decorators = [(0, utils_1.Option)("darkHighlightTheme")]; | ||
__esDecorate(_classThis, null, _includeSource_decorators, { kind: "accessor", name: "includeSource", static: false, private: false, access: { has: obj => "includeSource" in obj, get: obj => obj.includeSource, set: (obj, value) => { obj.includeSource = value; } }, metadata: _metadata }, _includeSource_initializers, _includeSource_extraInitializers); | ||
__esDecorate(_classThis, null, _mediaSource_decorators, { kind: "accessor", name: "mediaSource", static: false, private: false, access: { has: obj => "mediaSource" in obj, get: obj => obj.mediaSource, set: (obj, value) => { obj.mediaSource = value; } }, metadata: _metadata }, _mediaSource_initializers, _mediaSource_extraInitializers); | ||
__esDecorate(_classThis, null, _lightTheme_decorators, { kind: "accessor", name: "lightTheme", static: false, private: false, access: { has: obj => "lightTheme" in obj, get: obj => obj.lightTheme, set: (obj, value) => { obj.lightTheme = value; } }, metadata: _metadata }, _lightTheme_initializers, _lightTheme_extraInitializers); | ||
@@ -312,18 +244,1 @@ __esDecorate(_classThis, null, _darkTheme_decorators, { kind: "accessor", name: "darkTheme", static: false, private: false, access: { has: obj => "darkTheme" in obj, get: obj => obj.darkTheme, set: (obj, value) => { obj.darkTheme = value; } }, metadata: _metadata }, _darkTheme_initializers, _darkTheme_extraInitializers); | ||
exports.MarkedPlugin = MarkedPlugin; | ||
// Basically a copy/paste of Marked's code, with the addition of the button | ||
// https://github.com/markedjs/marked/blob/v4.3.0/src/Renderer.js#L15-L39 | ||
function renderCode(code, infostring, escaped) { | ||
const lang = (infostring || "").match(/\S*/)[0]; | ||
if (this.options.highlight) { | ||
const out = this.options.highlight(code, lang); | ||
if (out != null && out !== code) { | ||
escaped = true; | ||
code = out; | ||
} | ||
} | ||
code = code.replace(/\n$/, "") + "\n"; | ||
if (!lang) { | ||
return `<pre><code>${escaped ? code : (0, html_1.escapeHtml)(code)}</code><button>Copy</button></pre>\n`; | ||
} | ||
return `<pre><code class="${this.options.langPrefix + (0, html_1.escapeHtml)(lang)}">${escaped ? code : (0, html_1.escapeHtml)(code)}</code><button>Copy</button></pre>\n`; | ||
} |
import type { Application } from "../application"; | ||
import { ProjectReflection, ReflectionVariant, TypeKindMap } from "../models/index"; | ||
import { ProjectReflection, type ReflectionVariant, type TypeKindMap } from "../models/index"; | ||
import type { Logger } from "../utils/loggers"; | ||
@@ -14,7 +14,7 @@ import type { JSONOutput } from "./index"; | ||
export declare class Deserializer { | ||
private app; | ||
readonly application: Application; | ||
private deferred; | ||
private deserializers; | ||
private activeReflection; | ||
constructor(app: Application); | ||
constructor(application: Application); | ||
get logger(): Logger; | ||
@@ -21,0 +21,0 @@ reflectionBuilders: { |
@@ -8,4 +8,4 @@ "use strict"; | ||
class Deserializer { | ||
constructor(app) { | ||
this.app = app; | ||
constructor(application) { | ||
this.application = application; | ||
this.deferred = []; | ||
@@ -18,2 +18,5 @@ this.deserializers = []; | ||
}, | ||
document(parent, obj) { | ||
return new index_1.DocumentReflection(obj.name, parent, [], {}); | ||
}, | ||
param(parent, obj) { | ||
@@ -106,3 +109,3 @@ return new index_1.ParameterReflection(obj.name, obj.kind, parent); | ||
get logger() { | ||
return this.app.logger; | ||
return this.application.logger; | ||
} | ||
@@ -140,3 +143,2 @@ addDeserializer(de) { | ||
const project = new index_1.ProjectReflection(name); | ||
project.children = []; | ||
this.project = project; | ||
@@ -147,3 +149,3 @@ for (const proj of projects) { | ||
project.registerReflection(projModule); | ||
project.children.push(projModule); | ||
project.addChild(projModule); | ||
this.oldIdToNewId = { [proj.id]: projModule.id }; | ||
@@ -150,0 +152,0 @@ this.fromObject(projModule, proj); |
@@ -35,3 +35,3 @@ /** | ||
export type ModelToObject<T> = T extends Array<infer U> ? _ModelToObject<U>[] : _ModelToObject<T>; | ||
type _ModelToObject<T> = T extends Primitive ? T : Required<T> extends Required<M.ReflectionGroup> ? ReflectionGroup : Required<T> extends Required<M.ReflectionCategory> ? ReflectionCategory : T extends M.SignatureReflection ? SignatureReflection : T extends M.ParameterReflection ? ParameterReflection : T extends M.DeclarationReflection ? DeclarationReflection : T extends M.TypeParameterReflection ? TypeParameterReflection : T extends M.ProjectReflection ? ProjectReflection : T extends M.ContainerReflection ? ContainerReflection : T extends M.ReferenceReflection ? ReferenceReflection : T extends M.Reflection ? Reflection : T extends M.SomeType ? TypeKindMap[T["type"]] : T extends M.Type ? SomeType : T extends M.Comment ? Comment : T extends M.CommentTag ? CommentTag : T extends M.CommentDisplayPart ? CommentDisplayPart : T extends M.SourceReference ? SourceReference : never; | ||
type _ModelToObject<T> = T extends Primitive ? T : Required<T> extends Required<M.ReflectionGroup> ? ReflectionGroup : Required<T> extends Required<M.ReflectionCategory> ? ReflectionCategory : T extends M.SignatureReflection ? SignatureReflection : T extends M.ParameterReflection ? ParameterReflection : T extends M.DeclarationReflection ? DeclarationReflection : T extends M.DocumentReflection ? DocumentReflection : T extends M.TypeParameterReflection ? TypeParameterReflection : T extends M.ProjectReflection ? ProjectReflection : T extends M.ContainerReflection ? ContainerReflection : T extends M.ReferenceReflection ? ReferenceReflection : T extends M.Reflection ? Reflection : T extends M.SomeType ? TypeKindMap[T["type"]] : T extends M.Type ? SomeType : T extends M.Comment ? Comment : T extends M.CommentTag ? CommentTag : T extends M.CommentDisplayPart ? CommentDisplayPart : T extends M.SourceReference ? SourceReference : never; | ||
type Primitive = string | number | undefined | null | boolean; | ||
@@ -66,2 +66,6 @@ type ToSerialized<T> = T extends Primitive ? T : T extends bigint ? { | ||
/** @category Reflections */ | ||
export interface DocumentReflection extends Omit<Reflection, "variant">, S<M.DocumentReflection, "variant" | "content" | "relevanceBoost"> { | ||
frontmatter: Record<string, unknown>; | ||
} | ||
/** @category Reflections */ | ||
export interface ReferenceReflection extends Omit<DeclarationReflection, "variant">, S<M.ReferenceReflection, "variant"> { | ||
@@ -83,3 +87,5 @@ /** | ||
/** @category Reflections */ | ||
export interface DeclarationReflection extends Omit<ContainerReflection, "variant">, S<M.DeclarationReflection, "variant" | "packageVersion" | "sources" | "relevanceBoost" | "type" | "signatures" | "indexSignature" | "defaultValue" | "overwrites" | "inheritedFrom" | "implementationOf" | "extendedTypes" | "extendedBy" | "implementedTypes" | "implementedBy" | "getSignature" | "setSignature" | "typeParameters" | "readme"> { | ||
export interface DeclarationReflection extends Omit<ContainerReflection, "variant">, S<M.DeclarationReflection, "variant" | "packageVersion" | "sources" | "relevanceBoost" | "type" | "signatures" | "indexSignatures" | "defaultValue" | "overwrites" | "inheritedFrom" | "implementationOf" | "extendedTypes" | "extendedBy" | "implementedTypes" | "implementedBy" | "getSignature" | "setSignature" | "typeParameters" | "readme"> { | ||
/** @deprecated moved to {@link indexSignatures} with 0.26. */ | ||
indexSignature?: SignatureReflection; | ||
} | ||
@@ -94,3 +100,4 @@ /** @category Reflections */ | ||
/** @category Reflections */ | ||
export interface ContainerReflection extends Reflection, S<M.ContainerReflection, "children" | "groups" | "categories"> { | ||
export interface ContainerReflection extends Reflection, S<M.ContainerReflection, "children" | "documents" | "groups" | "categories"> { | ||
childrenIncludingDocuments?: number[]; | ||
} | ||
@@ -97,0 +104,0 @@ /** @category Reflections */ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.filterMap = exports.zip = exports.partition = exports.unique = exports.removeIf = exports.removeIfPresent = exports.binaryFindPartition = exports.insertOrderSorted = exports.insertPrioritySorted = void 0; | ||
exports.insertPrioritySorted = insertPrioritySorted; | ||
exports.insertOrderSorted = insertOrderSorted; | ||
exports.binaryFindPartition = binaryFindPartition; | ||
exports.removeIfPresent = removeIfPresent; | ||
exports.removeIf = removeIf; | ||
exports.unique = unique; | ||
exports.partition = partition; | ||
exports.zip = zip; | ||
exports.filterMap = filterMap; | ||
/** | ||
@@ -15,3 +23,2 @@ * Inserts an item into an array sorted by priority. If two items have the same priority, | ||
} | ||
exports.insertPrioritySorted = insertPrioritySorted; | ||
/** | ||
@@ -29,3 +36,2 @@ * Inserts an item into an array sorted by order. If two items have the same order, | ||
} | ||
exports.insertOrderSorted = insertOrderSorted; | ||
/** | ||
@@ -54,3 +60,2 @@ * Performs a binary search of a given array, returning the index of the first item | ||
} | ||
exports.binaryFindPartition = binaryFindPartition; | ||
/** | ||
@@ -71,3 +76,2 @@ * Removes an item from the array if the array exists and the item is included | ||
} | ||
exports.removeIfPresent = removeIfPresent; | ||
/** | ||
@@ -86,3 +90,2 @@ * Remove items in an array which match a predicate. | ||
} | ||
exports.removeIf = removeIf; | ||
/** | ||
@@ -95,3 +98,2 @@ * Filters out duplicate values from the given iterable. | ||
} | ||
exports.unique = unique; | ||
function partition(iter, predicate) { | ||
@@ -110,3 +112,2 @@ const left = []; | ||
} | ||
exports.partition = partition; | ||
function* zip(...args) { | ||
@@ -122,3 +123,2 @@ const iterators = args.map((x) => x[Symbol.iterator]()); | ||
} | ||
exports.zip = zip; | ||
function filterMap(iter, fn) { | ||
@@ -134,2 +134,1 @@ const result = []; | ||
} | ||
exports.filterMap = filterMap; |
import type { Application } from "../application"; | ||
import { EventDispatcher, Event, EventMap } from "./events"; | ||
import { EventDispatcher, Event, type EventMap } from "./events"; | ||
/** | ||
@@ -4,0 +4,0 @@ * Exposes a reference to the root Application component. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ChildableComponent = exports.AbstractComponent = exports.ComponentEvent = exports.Component = void 0; | ||
exports.ChildableComponent = exports.AbstractComponent = exports.ComponentEvent = void 0; | ||
exports.Component = Component; | ||
const events_1 = require("./events"); | ||
@@ -46,3 +47,2 @@ const childMappings = []; | ||
} | ||
exports.Component = Component; | ||
class ComponentEvent extends events_1.Event { | ||
@@ -49,0 +49,0 @@ constructor(name, owner, component) { |
@@ -37,5 +37,16 @@ import ts from "typescript"; | ||
} | ||
export interface DocumentEntryPoint { | ||
displayName: string; | ||
path: string; | ||
} | ||
export declare function getEntryPoints(logger: Logger, options: Options): DocumentationEntryPoint[] | undefined; | ||
/** | ||
* Document entry points are markdown documents that the user has requested we include in the project with | ||
* an option rather than a `@document` tag. | ||
* | ||
* @returns A list of `.md` files to include in the documentation as documents. | ||
*/ | ||
export declare function getDocumentEntryPoints(logger: Logger, options: Options): DocumentEntryPoint[]; | ||
export declare function getWatchEntryPoints(logger: Logger, options: Options, program: ts.Program): DocumentationEntryPoint[] | undefined; | ||
export declare function getPackageDirectories(logger: Logger, options: Options, packageGlobPaths: string[]): string[]; | ||
export declare function getExpandedEntryPointsForPaths(logger: Logger, inputFiles: string[], options: Options, programs?: ts.Program[]): DocumentationEntryPoint[]; |
@@ -29,3 +29,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getExpandedEntryPointsForPaths = exports.getPackageDirectories = exports.getWatchEntryPoints = exports.getEntryPoints = exports.EntryPointStrategy = void 0; | ||
exports.EntryPointStrategy = void 0; | ||
exports.getEntryPoints = getEntryPoints; | ||
exports.getDocumentEntryPoints = getDocumentEntryPoints; | ||
exports.getWatchEntryPoints = getWatchEntryPoints; | ||
exports.getPackageDirectories = getPackageDirectories; | ||
exports.getExpandedEntryPointsForPaths = getExpandedEntryPointsForPaths; | ||
const path_1 = require("path"); | ||
@@ -65,3 +70,3 @@ const typescript_1 = __importDefault(require("typescript")); | ||
if (!options.isSet("entryPoints")) { | ||
logger.warn("No entry points were provided, this is likely a misconfiguration."); | ||
logger.warn(logger.i18n.no_entry_points_provided()); | ||
return []; | ||
@@ -93,3 +98,3 @@ } | ||
if (result && result.length === 0) { | ||
logger.error("Unable to find any entry points. See previous warnings."); | ||
logger.error(logger.i18n.unable_to_find_any_entry_points()); | ||
return; | ||
@@ -99,3 +104,26 @@ } | ||
} | ||
exports.getEntryPoints = getEntryPoints; | ||
/** | ||
* Document entry points are markdown documents that the user has requested we include in the project with | ||
* an option rather than a `@document` tag. | ||
* | ||
* @returns A list of `.md` files to include in the documentation as documents. | ||
*/ | ||
function getDocumentEntryPoints(logger, options) { | ||
const docGlobs = options.getValue("projectDocuments"); | ||
if (docGlobs.length === 0) { | ||
return []; | ||
} | ||
const docPaths = expandGlobs(docGlobs, [], logger); | ||
// We might want to expand this in the future, there are quite a lot of extensions | ||
// that have at some point or another been used for markdown: https://superuser.com/a/285878 | ||
const supportedFileRegex = /\.(md|markdown)$/; | ||
const expanded = expandInputFiles(logger, docPaths, options, supportedFileRegex); | ||
const baseDir = options.getValue("basePath") || (0, fs_1.deriveRootDir)(expanded); | ||
return expanded.map((path) => { | ||
return { | ||
displayName: (0, path_1.relative)(baseDir, path).replace(/\.[^.]+$/, ""), | ||
path, | ||
}; | ||
}); | ||
} | ||
function getWatchEntryPoints(logger, options, program) { | ||
@@ -114,6 +142,6 @@ let result; | ||
case exports.EntryPointStrategy.Packages: | ||
logger.error("Watch mode does not support 'packages' style entry points."); | ||
logger.error(logger.i18n.watch_does_not_support_packages_mode()); | ||
break; | ||
case exports.EntryPointStrategy.Merge: | ||
logger.error("Watch mode does not support 'merge' style entry points."); | ||
logger.error(logger.i18n.watch_does_not_support_merge_mode()); | ||
break; | ||
@@ -124,3 +152,3 @@ default: | ||
if (result && result.length === 0) { | ||
logger.error("Unable to find any entry points."); | ||
logger.error(logger.i18n.unable_to_find_any_entry_points()); | ||
return; | ||
@@ -130,3 +158,2 @@ } | ||
} | ||
exports.getWatchEntryPoints = getWatchEntryPoints; | ||
function getPackageDirectories(logger, options, packageGlobPaths) { | ||
@@ -139,3 +166,2 @@ const exclude = (0, paths_1.createMinimatch)(options.getValue("exclude")); | ||
} | ||
exports.getPackageDirectories = getPackageDirectories; | ||
function getModuleName(fileName, baseDir) { | ||
@@ -151,2 +177,3 @@ return (0, paths_1.normalizePath)((0, path_1.relative)(baseDir, fileName)).replace(/(\/index)?(\.d)?\.([cm][tj]s|[tj]sx?)$/, ""); | ||
const entryPoints = []; | ||
let expandSuggestion = true; | ||
entryLoop: for (const fileOrDir of inputFiles.map(paths_1.normalizePath)) { | ||
@@ -170,6 +197,7 @@ const toCheck = [fileOrDir]; | ||
} | ||
const suggestion = (0, fs_1.isDir)(fileOrDir) | ||
? " If you wanted to include files inside this directory, set --entryPointStrategy to expand or specify a glob." | ||
: ""; | ||
logger.warn(`The entry point ${(0, paths_1.nicePath)(fileOrDir)} is not referenced by the 'files' or 'include' option in your tsconfig.${suggestion}`); | ||
logger.warn(logger.i18n.entry_point_0_not_in_program((0, paths_1.nicePath)(fileOrDir))); | ||
if (expandSuggestion && (0, fs_1.isDir)(fileOrDir)) { | ||
expandSuggestion = false; | ||
logger.info(logger.i18n.use_expand_or_glob_for_files_in_dir()); | ||
} | ||
} | ||
@@ -179,5 +207,8 @@ return entryPoints; | ||
function getExpandedEntryPointsForPaths(logger, inputFiles, options, programs = getEntryPrograms(inputFiles, logger, options)) { | ||
return getEntryPointsForPaths(logger, expandInputFiles(logger, inputFiles, options), options, programs); | ||
const compilerOptions = options.getCompilerOptions(); | ||
const supportedFileRegex = compilerOptions.allowJs || compilerOptions.checkJs | ||
? /\.([cm][tj]s|[tj]sx?)$/ | ||
: /\.([cm]ts|tsx?)$/; | ||
return getEntryPointsForPaths(logger, expandInputFiles(logger, inputFiles, options, supportedFileRegex), options, programs); | ||
} | ||
exports.getExpandedEntryPointsForPaths = getExpandedEntryPointsForPaths; | ||
function expandGlobs(inputFiles, exclude, logger) { | ||
@@ -193,6 +224,6 @@ const excludePatterns = (0, paths_1.createMinimatch)(exclude); | ||
if (result.length === 0) { | ||
logger.warn(`The entrypoint glob ${(0, paths_1.nicePath)(entry)} did not match any files.`); | ||
logger.warn(logger.i18n.glob_0_did_not_match_any_files((0, paths_1.nicePath)(entry))); | ||
} | ||
else if (filtered.length === 0) { | ||
logger.warn(`The entrypoint glob ${(0, paths_1.nicePath)(entry)} did not match any files after applying exclude patterns.`); | ||
logger.warn(logger.i18n.entry_point_0_did_not_match_any_files_after_exclude((0, paths_1.nicePath)(entry))); | ||
} | ||
@@ -249,9 +280,5 @@ else { | ||
*/ | ||
function expandInputFiles(logger, entryPoints, options) { | ||
function expandInputFiles(logger, entryPoints, options, supportedFile) { | ||
const files = []; | ||
const exclude = (0, paths_1.createMinimatch)(options.getValue("exclude")); | ||
const compilerOptions = options.getCompilerOptions(); | ||
const supportedFileRegex = compilerOptions.allowJs || compilerOptions.checkJs | ||
? /\.([cm][tj]s|[tj]sx?)$/ | ||
: /\.([cm]ts|tsx?)$/; | ||
function add(file, entryPoint) { | ||
@@ -275,3 +302,3 @@ let stats; | ||
} | ||
else if (supportedFileRegex.test(file)) { | ||
else if (supportedFile.test(file)) { | ||
if (!entryPoint && (0, paths_1.matchesAny)(exclude, file)) { | ||
@@ -286,3 +313,3 @@ return; | ||
if (!FS.existsSync(resolved)) { | ||
logger.warn(`Provided entry point ${file} does not exist and will not be included in the docs.`); | ||
logger.warn(logger.i18n.entry_point_0_did_not_exist(file)); | ||
return; | ||
@@ -289,0 +316,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getEnumKeys = exports.debugFlags = exports.hasAnyFlag = exports.hasAllFlags = exports.removeFlag = exports.getEnumFlags = void 0; | ||
exports.getEnumFlags = getEnumFlags; | ||
exports.removeFlag = removeFlag; | ||
exports.hasAllFlags = hasAllFlags; | ||
exports.hasAnyFlag = hasAnyFlag; | ||
exports.debugFlags = debugFlags; | ||
exports.getEnumKeys = getEnumKeys; | ||
function getEnumFlags(flags) { | ||
@@ -13,3 +18,2 @@ const result = []; | ||
} | ||
exports.getEnumFlags = getEnumFlags; | ||
// T & {} reduces inference priority | ||
@@ -19,15 +23,11 @@ function removeFlag(flag, remove) { | ||
} | ||
exports.removeFlag = removeFlag; | ||
function hasAllFlags(flags, check) { | ||
return (flags & check) === check; | ||
} | ||
exports.hasAllFlags = hasAllFlags; | ||
function hasAnyFlag(flags, check) { | ||
return (flags & check) !== 0; | ||
} | ||
exports.hasAnyFlag = hasAnyFlag; | ||
function debugFlags(Enum, flags) { | ||
return getEnumKeys(Enum).filter((key) => (Enum[key] & flags) === Enum[key]); | ||
} | ||
exports.debugFlags = debugFlags; | ||
// Note: String enums are not handled. | ||
@@ -38,2 +38,1 @@ function getEnumKeys(Enum) { | ||
} | ||
exports.getEnumKeys = getEnumKeys; |
@@ -26,3 +26,17 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.findPackageForPath = exports.discoverPackageJson = exports.discoverInParentDirExactMatch = exports.discoverInParentDir = exports.hasTsExtension = exports.glob = exports.copySync = exports.copy = exports.writeFile = exports.writeFileSync = exports.readFile = exports.getCommonDirectory = exports.deriveRootDir = exports.isDir = exports.isFile = void 0; | ||
exports.isFile = isFile; | ||
exports.isDir = isDir; | ||
exports.deriveRootDir = deriveRootDir; | ||
exports.getCommonDirectory = getCommonDirectory; | ||
exports.readFile = readFile; | ||
exports.writeFileSync = writeFileSync; | ||
exports.writeFile = writeFile; | ||
exports.copy = copy; | ||
exports.copySync = copySync; | ||
exports.glob = glob; | ||
exports.hasTsExtension = hasTsExtension; | ||
exports.discoverInParentDir = discoverInParentDir; | ||
exports.discoverInParentDirExactMatch = discoverInParentDirExactMatch; | ||
exports.discoverPackageJson = discoverPackageJson; | ||
exports.findPackageForPath = findPackageForPath; | ||
const fs = __importStar(require("fs")); | ||
@@ -43,3 +57,2 @@ const fs_1 = require("fs"); | ||
} | ||
exports.isFile = isFile; | ||
function isDir(path) { | ||
@@ -53,3 +66,2 @@ try { | ||
} | ||
exports.isDir = isDir; | ||
function deriveRootDir(globPaths) { | ||
@@ -70,3 +82,2 @@ const normalized = globPaths.map(paths_1.normalizePath); | ||
} | ||
exports.deriveRootDir = deriveRootDir; | ||
/** | ||
@@ -90,3 +101,2 @@ * Get the longest directory path common to all files. | ||
} | ||
exports.getCommonDirectory = getCommonDirectory; | ||
/** | ||
@@ -125,3 +135,2 @@ * Load the given file and return its contents. | ||
} | ||
exports.readFile = readFile; | ||
/** | ||
@@ -139,3 +148,2 @@ * Write a file to disc. | ||
} | ||
exports.writeFileSync = writeFileSync; | ||
/** | ||
@@ -155,3 +163,2 @@ * Write a file to disc. | ||
} | ||
exports.writeFile = writeFile; | ||
/** | ||
@@ -174,3 +181,2 @@ * Copy a file or directory recursively. | ||
} | ||
exports.copy = copy; | ||
function copySync(src, dest) { | ||
@@ -190,3 +196,2 @@ const stat = fs.statSync(src); | ||
} | ||
exports.copySync = copySync; | ||
/** | ||
@@ -282,7 +287,5 @@ * Simpler version of `glob.sync` that only covers our use cases, always ignoring node_modules. | ||
} | ||
exports.glob = glob; | ||
function hasTsExtension(path) { | ||
return /\.[cm]?ts$|\.tsx$/.test(path); | ||
} | ||
exports.hasTsExtension = hasTsExtension; | ||
function discoverInParentDir(name, dir, read) { | ||
@@ -309,3 +312,2 @@ if (!isDir(dir)) | ||
} | ||
exports.discoverInParentDir = discoverInParentDir; | ||
function discoverInParentDirExactMatch(name, dir, read) { | ||
@@ -328,3 +330,2 @@ if (!isDir(dir)) | ||
} | ||
exports.discoverInParentDirExactMatch = discoverInParentDirExactMatch; | ||
function discoverPackageJson(dir) { | ||
@@ -338,3 +339,2 @@ return discoverInParentDirExactMatch("package.json", dir, (content) => { | ||
} | ||
exports.discoverPackageJson = discoverPackageJson; | ||
// dir -> package name according to package.json in this or some parent dir | ||
@@ -354,2 +354,1 @@ const packageCache = new Map(); | ||
} | ||
exports.findPackageForPath = findPackageForPath; |
@@ -9,3 +9,3 @@ /** | ||
/** | ||
* Helper type to convert `T` to `F` if strict mode is on. | ||
* Helper type to convert `T` to `F` if compiling TypeDoc with stricter types. | ||
* | ||
@@ -23,3 +23,4 @@ * Can be used in overloads to map a parameter type to `never`. For example, the | ||
* function over(flag: 'a' | 'b'): string | ||
* function over(flag: IfStrict<string, never>): string | ||
* // deprecated | ||
* function over(flag: IfInternal<never, string>): string | ||
* function over(flag: string): string { return flag } | ||
@@ -30,3 +31,3 @@ * ``` | ||
/** | ||
* Helper type to convert `T` to `never` if strict mode is on. | ||
* Helper type to convert `T` to `never` if compiling TypeDoc with stricter types. | ||
* | ||
@@ -33,0 +34,0 @@ * See {@link IfInternal} for the rationale. |
@@ -26,3 +26,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getLoadedPaths = exports.hasBeenLoadedMultipleTimes = exports.NonEnumerable = exports.assertNever = void 0; | ||
exports.assertNever = assertNever; | ||
exports.NonEnumerable = NonEnumerable; | ||
exports.hasBeenLoadedMultipleTimes = hasBeenLoadedMultipleTimes; | ||
exports.getLoadedPaths = getLoadedPaths; | ||
const path_1 = require("path"); | ||
@@ -36,3 +39,2 @@ const Util = __importStar(require("util")); | ||
} | ||
exports.assertNever = assertNever; | ||
function NonEnumerable(_cls, context) { | ||
@@ -47,3 +49,2 @@ context.addInitializer(function () { | ||
} | ||
exports.NonEnumerable = NonEnumerable; | ||
/** | ||
@@ -64,6 +65,4 @@ * This is a hack to make it possible to detect and warn about installation setups | ||
} | ||
exports.hasBeenLoadedMultipleTimes = hasBeenLoadedMultipleTimes; | ||
function getLoadedPaths() { | ||
return g[pathSymbol] || []; | ||
} | ||
exports.getLoadedPaths = getLoadedPaths; |
@@ -1,6 +0,8 @@ | ||
import { Theme } from "shiki"; | ||
export declare function loadHighlighter(lightTheme: Theme, darkTheme: Theme): Promise<void>; | ||
import type { BundledTheme } from "shiki" with { "resolution-mode": "import" }; | ||
export declare function loadShikiMetadata(): Promise<void>; | ||
export declare function loadHighlighter(lightTheme: BundledTheme, darkTheme: BundledTheme): Promise<void>; | ||
export declare function isSupportedLanguage(lang: string): boolean; | ||
export declare function getSupportedLanguages(): string[]; | ||
export declare function getSupportedThemes(): string[]; | ||
export declare function highlight(code: string, lang: string): string; | ||
export declare function getStyles(): string; |
@@ -26,14 +26,31 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getStyles = exports.highlight = exports.getSupportedLanguages = exports.isSupportedLanguage = exports.loadHighlighter = void 0; | ||
exports.loadShikiMetadata = loadShikiMetadata; | ||
exports.loadHighlighter = loadHighlighter; | ||
exports.isSupportedLanguage = isSupportedLanguage; | ||
exports.getSupportedLanguages = getSupportedLanguages; | ||
exports.getSupportedThemes = getSupportedThemes; | ||
exports.highlight = highlight; | ||
exports.getStyles = getStyles; | ||
const assert_1 = require("assert"); | ||
const shiki_1 = require("shiki"); | ||
const JSX = __importStar(require("./jsx")); | ||
const array_1 = require("./array"); | ||
const JSX = __importStar(require("./jsx")); | ||
const aliases = new Map(); | ||
for (const lang of shiki_1.BUNDLED_LANGUAGES) { | ||
for (const alias of lang.aliases || []) { | ||
aliases.set(alias, lang.id); | ||
let supportedLanguages = []; | ||
let supportedThemes = []; | ||
async function loadShikiMetadata() { | ||
if (aliases.size) | ||
return; | ||
const shiki = await import("shiki"); | ||
for (const lang of shiki.bundledLanguagesInfo) { | ||
for (const alias of lang.aliases || []) { | ||
aliases.set(alias, lang.id); | ||
} | ||
} | ||
supportedLanguages = (0, array_1.unique)([ | ||
"text", | ||
...aliases.keys(), | ||
...shiki.bundledLanguagesInfo.map((lang) => lang.id), | ||
]).sort(); | ||
supportedThemes = Object.keys(shiki.bundledThemes); | ||
} | ||
const supportedLanguages = (0, array_1.unique)(["text", ...aliases.keys(), ...shiki_1.BUNDLED_LANGUAGES.map((lang) => lang.id)]).sort(); | ||
class DoubleHighlighter { | ||
@@ -47,28 +64,10 @@ constructor(highlighter, light, dark) { | ||
highlight(code, lang) { | ||
const lightTokens = this.highlighter.codeToThemedTokens(code, lang, this.light, { includeExplanation: false }); | ||
const darkTokens = this.highlighter.codeToThemedTokens(code, lang, this.dark, { includeExplanation: false }); | ||
// If this fails... something went *very* wrong. | ||
(0, assert_1.ok)(lightTokens.length === darkTokens.length); | ||
const tokens = this.highlighter.codeToTokensWithThemes(code, { | ||
themes: { light: this.light, dark: this.dark }, | ||
lang: lang, | ||
}); | ||
const docEls = []; | ||
for (const [lightLine, darkLine] of (0, array_1.zip)(lightTokens, darkTokens)) { | ||
// Different themes can have different rules for when colors change... so unfortunately we have to deal with different | ||
// sets of tokens.Example: light_plus and dark_plus tokenize " = " differently in the `schemes` | ||
// declaration for this file. | ||
while (lightLine.length && darkLine.length) { | ||
// Simple case, same token. | ||
if (lightLine[0].content === darkLine[0].content) { | ||
docEls.push(JSX.createElement("span", { class: this.getClass(lightLine[0].color, darkLine[0].color) }, lightLine[0].content)); | ||
lightLine.shift(); | ||
darkLine.shift(); | ||
continue; | ||
} | ||
if (lightLine[0].content.length < darkLine[0].content.length) { | ||
docEls.push(JSX.createElement("span", { class: this.getClass(lightLine[0].color, darkLine[0].color) }, lightLine[0].content)); | ||
darkLine[0].content = darkLine[0].content.substring(lightLine[0].content.length); | ||
lightLine.shift(); | ||
continue; | ||
} | ||
docEls.push(JSX.createElement("span", { class: this.getClass(lightLine[0].color, darkLine[0].color) }, darkLine[0].content)); | ||
lightLine[0].content = lightLine[0].content.substring(darkLine[0].content.length); | ||
darkLine.shift(); | ||
for (const line of tokens) { | ||
for (const token of line) { | ||
docEls.push(JSX.createElement("span", { class: this.getClass(token.variants) }, token.content)); | ||
} | ||
@@ -78,2 +77,3 @@ docEls.push(JSX.createElement("br", null)); | ||
docEls.pop(); // Remove last <br> | ||
docEls.pop(); // Remove last <br> | ||
return JSX.renderElement(JSX.createElement(JSX.Fragment, null, docEls)); | ||
@@ -117,4 +117,4 @@ } | ||
} | ||
getClass(lightColor, darkColor) { | ||
const key = `${lightColor} | ${darkColor}`; | ||
getClass(variants) { | ||
const key = `${variants["light"].color} | ${variants["dark"].color}`; | ||
let scheme = this.schemes.get(key); | ||
@@ -132,14 +132,17 @@ if (scheme == null) { | ||
return; | ||
const hl = await (0, shiki_1.getHighlighter)({ themes: [lightTheme, darkTheme] }); | ||
const shiki = await import("shiki"); | ||
const hl = await shiki.getHighlighter({ themes: [lightTheme, darkTheme], langs: getSupportedLanguages() }); | ||
highlighter = new DoubleHighlighter(hl, lightTheme, darkTheme); | ||
} | ||
exports.loadHighlighter = loadHighlighter; | ||
function isSupportedLanguage(lang) { | ||
return getSupportedLanguages().includes(lang); | ||
} | ||
exports.isSupportedLanguage = isSupportedLanguage; | ||
function getSupportedLanguages() { | ||
(0, assert_1.ok)(supportedLanguages.length > 0, "loadShikiMetadata has not been called"); | ||
return supportedLanguages; | ||
} | ||
exports.getSupportedLanguages = getSupportedLanguages; | ||
function getSupportedThemes() { | ||
(0, assert_1.ok)(supportedThemes.length > 0, "loadShikiMetadata has not been called"); | ||
return supportedThemes; | ||
} | ||
function highlight(code, lang) { | ||
@@ -155,3 +158,2 @@ (0, assert_1.ok)(highlighter, "Tried to highlight with an uninitialized highlighter"); | ||
} | ||
exports.highlight = highlight; | ||
function getStyles() { | ||
@@ -161,2 +163,1 @@ (0, assert_1.ok)(highlighter, "Tried to highlight with an uninitialized highlighter"); | ||
} | ||
exports.getStyles = getStyles; |
@@ -6,3 +6,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.escapeHtml = exports.getTextContent = void 0; | ||
exports.getTextContent = getTextContent; | ||
exports.escapeHtml = escapeHtml; | ||
// There is a fixed list of named character references which will not be expanded in the future. | ||
@@ -29,3 +30,2 @@ // This json file is based on https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references | ||
} | ||
exports.getTextContent = getTextContent; | ||
const htmlEscapes = { | ||
@@ -41,2 +41,1 @@ "&": "&", | ||
} | ||
exports.escapeHtml = escapeHtml; |
@@ -11,3 +11,3 @@ export { filterMap, insertPrioritySorted, partition, removeIf, removeIfPresent, unique, } from "./array"; | ||
export { DefaultMap } from "./map"; | ||
export { ArgumentsReader, Option, BindOption, CommentStyle, Options, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, } from "./options"; | ||
export { ArgumentsReader, Option, CommentStyle, Options, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, } from "./options"; | ||
export type { ArrayDeclarationOption, BooleanDeclarationOption, DeclarationOption, DeclarationOptionBase, DeclarationOptionToOptionType, KeyToDeclaration, MapDeclarationOption, MixedDeclarationOption, NumberDeclarationOption, FlagsDeclarationOption, ObjectDeclarationOption, OptionsReader, StringDeclarationOption, TypeDocOptionMap, TypeDocOptions, ValidationOptions, TypeDocOptionValues, ParameterTypeToOptionTypeMap, ManuallyValidatedOption, JsDocCompatibility, } from "./options"; | ||
@@ -14,0 +14,0 @@ export { loadPlugins } from "./plugins"; |
@@ -29,3 +29,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MinimalSourceFile = exports.Validation = exports.renderElement = exports.Raw = exports.Fragment = exports.JSX = exports.EventHooks = exports.getSortFunction = exports.loadPlugins = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.CommentStyle = exports.BindOption = exports.Option = exports.ArgumentsReader = exports.DefaultMap = exports.LogLevel = exports.Logger = exports.ConsoleLogger = exports.assertNever = exports.normalizePath = exports.discoverPackageJson = exports.discoverInParentDir = exports.writeFileSync = exports.writeFile = exports.readFile = exports.getCommonDirectory = exports.copySync = exports.copy = exports.isFile = exports.EventDispatcher = exports.Event = exports.Component = exports.ChildableComponent = exports.AbstractComponent = exports.unique = exports.removeIfPresent = exports.removeIf = exports.partition = exports.insertPrioritySorted = exports.filterMap = void 0; | ||
exports.MinimalSourceFile = exports.Validation = exports.renderElement = exports.Raw = exports.Fragment = exports.JSX = exports.EventHooks = exports.getSortFunction = exports.loadPlugins = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.CommentStyle = exports.Option = exports.ArgumentsReader = exports.DefaultMap = exports.LogLevel = exports.Logger = exports.ConsoleLogger = exports.assertNever = exports.normalizePath = exports.discoverPackageJson = exports.discoverInParentDir = exports.writeFileSync = exports.writeFile = exports.readFile = exports.getCommonDirectory = exports.copySync = exports.copy = exports.isFile = exports.EventDispatcher = exports.Event = exports.Component = exports.ChildableComponent = exports.AbstractComponent = exports.unique = exports.removeIfPresent = exports.removeIf = exports.partition = exports.insertPrioritySorted = exports.filterMap = void 0; | ||
var array_1 = require("./array"); | ||
@@ -69,3 +69,2 @@ Object.defineProperty(exports, "filterMap", { enumerable: true, get: function () { return array_1.filterMap; } }); | ||
Object.defineProperty(exports, "Option", { enumerable: true, get: function () { return options_1.Option; } }); | ||
Object.defineProperty(exports, "BindOption", { enumerable: true, get: function () { return options_1.BindOption; } }); | ||
Object.defineProperty(exports, "CommentStyle", { enumerable: true, get: function () { return options_1.CommentStyle; } }); | ||
@@ -72,0 +71,0 @@ Object.defineProperty(exports, "Options", { enumerable: true, get: function () { return options_1.Options; } }); |
@@ -122,2 +122,3 @@ export interface IntrinsicElements { | ||
polyline: JsxPolylineElementProps; | ||
line: JsxLineElementProps; | ||
use: JsxUseElementProps; | ||
@@ -889,2 +890,13 @@ } | ||
} | ||
/** Properties permitted on the `<line>` element. | ||
* | ||
* Reference: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/line | ||
*/ | ||
export interface JsxLineElementProps extends JsxSvgCoreProps, JsxSvgStyleProps, JsxSvgConditionalProcessingProps, JsxSvgPresentationProps { | ||
x1?: string | number; | ||
y1?: string | number; | ||
x2?: string | number; | ||
y2?: string | number; | ||
pathLength?: number; | ||
} | ||
/** | ||
@@ -891,0 +903,0 @@ * Properties permitted on the `<use>` element. |
@@ -17,3 +17,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.renderElement = exports.setRenderSettings = exports.createElement = exports.Raw = exports.Fragment = void 0; | ||
exports.renderElement = exports.Fragment = void 0; | ||
exports.Raw = Raw; | ||
exports.createElement = createElement; | ||
exports.setRenderSettings = setRenderSettings; | ||
const html_1 = require("./html"); | ||
@@ -32,3 +35,2 @@ const jsx_elements_1 = require("./jsx.elements"); | ||
} | ||
exports.Raw = Raw; | ||
const voidElements = new Set([ | ||
@@ -75,3 +77,2 @@ "area", | ||
} | ||
exports.createElement = createElement; | ||
let renderPretty = true; | ||
@@ -81,3 +82,2 @@ function setRenderSettings(options) { | ||
} | ||
exports.setRenderSettings = setRenderSettings; | ||
const renderElement = function renderElement(element) { | ||
@@ -84,0 +84,0 @@ if (!element || typeof element === "boolean") { |
import ts from "typescript"; | ||
import type { MinimalSourceFile } from "./minimalSourceFile"; | ||
import type { TranslatedString, TranslationProxy } from "../internationalization/internationalization"; | ||
import type { IfInternal } from "."; | ||
/** | ||
@@ -21,2 +23,8 @@ * List of known log levels. Used to specify the urgency of a log message. | ||
/** | ||
* Translation utility for internationalization. | ||
* @privateRemarks | ||
* This is fully initialized by the application during bootstrapping. | ||
*/ | ||
i18n: TranslationProxy; | ||
/** | ||
* How many error messages have been logged? | ||
@@ -58,3 +66,3 @@ */ | ||
/** Log the given info message. */ | ||
info(text: string): void; | ||
info(text: IfInternal<TranslatedString, string>): void; | ||
/** | ||
@@ -65,4 +73,4 @@ * Log the given warning. | ||
*/ | ||
warn(text: string, node?: ts.Node): void; | ||
warn(text: string, pos: number, file: MinimalSourceFile): void; | ||
warn(text: IfInternal<TranslatedString, string>, node?: ts.Node): void; | ||
warn(text: IfInternal<TranslatedString, string>, pos: number, file: MinimalSourceFile): void; | ||
/** | ||
@@ -73,6 +81,4 @@ * Log the given error. | ||
*/ | ||
error(text: string, node?: ts.Node): void; | ||
error(text: string, pos: number, file: MinimalSourceFile): void; | ||
/** @internal */ | ||
deprecated(text: string, addStack?: boolean): void; | ||
error(text: IfInternal<TranslatedString, string>, node?: ts.Node): void; | ||
error(text: IfInternal<TranslatedString, string>, pos: number, file: MinimalSourceFile): void; | ||
/** | ||
@@ -79,0 +85,0 @@ * Print a log message. |
@@ -42,2 +42,9 @@ "use strict"; | ||
}; | ||
const dummyTranslationProxy = new Proxy({}, { | ||
get: (_target, key) => { | ||
return (...args) => String(key).replace(/\{(\d+)\}/g, (_, index) => { | ||
return args[+index] ?? "(no placeholder)"; | ||
}); | ||
}, | ||
}); | ||
/** | ||
@@ -52,2 +59,8 @@ * A logger that will not produce any output. | ||
/** | ||
* Translation utility for internationalization. | ||
* @privateRemarks | ||
* This is fully initialized by the application during bootstrapping. | ||
*/ | ||
this.i18n = dummyTranslationProxy; | ||
/** | ||
* How many error messages have been logged? | ||
@@ -119,12 +132,2 @@ */ | ||
} | ||
/** @internal */ | ||
deprecated(text, addStack = true) { | ||
if (addStack) { | ||
const stack = new Error().stack?.split("\n"); | ||
if (stack && stack.length >= 4) { | ||
text = text + "\n" + stack[3]; | ||
} | ||
} | ||
this.warn(text); | ||
} | ||
/** | ||
@@ -131,0 +134,0 @@ * Print a log message. |
export declare class DefaultMap<K, V> extends Map<K, V> { | ||
private creator; | ||
constructor(creator: () => V); | ||
constructor(creator: (key: K) => V); | ||
get(key: K): V; | ||
@@ -5,0 +5,0 @@ getNoInsert(key: K): V | undefined; |
@@ -15,3 +15,3 @@ "use strict"; | ||
} | ||
const created = this.creator(); | ||
const created = this.creator(key); | ||
this.set(key, created); | ||
@@ -18,0 +18,0 @@ return created; |
@@ -1,2 +0,2 @@ | ||
import type { Theme as ShikiTheme } from "shiki"; | ||
import type { BundledTheme as ShikiTheme } from "shiki" with { "resolution-mode": "import" }; | ||
import type { LogLevel } from "../loggers"; | ||
@@ -6,2 +6,4 @@ import type { SortStrategy } from "../sort"; | ||
import type { ReflectionKind } from "../../models/reflections/kind"; | ||
import type { NeverIfInternal } from ".."; | ||
import type { TranslationProxy } from "../../internationalization/internationalization"; | ||
/** @enum */ | ||
@@ -64,4 +66,7 @@ export declare const EmitStrategy: { | ||
plugin: string[]; | ||
lang: string; | ||
locales: ManuallyValidatedOption<Record<string, Record<string, string>>>; | ||
entryPoints: string[]; | ||
entryPointStrategy: typeof EntryPointStrategy; | ||
projectDocuments: string[]; | ||
exclude: string[]; | ||
@@ -87,3 +92,2 @@ externalPattern: string[]; | ||
readme: string; | ||
stripYamlFrontmatter: boolean; | ||
out: string; | ||
@@ -97,8 +101,25 @@ json: string; | ||
customCss: string; | ||
markedOptions: unknown; | ||
markdownItOptions: unknown; | ||
/** | ||
* Will be called when TypeDoc is setting up the markdown parser to use to render markdown. | ||
* Can be used to add markdown-it plugins to the parser with code like this: | ||
* | ||
* ```ts | ||
* // typedoc.config.mjs | ||
* import iterator from "markdown-it-for-inline"; | ||
* export default { | ||
* /** @type {MarkdownIt} *\/ | ||
* markdownItLoader(parser) { | ||
* parser.use(iterator, "foo_replace", "text", function(tokens, idx) { | ||
* tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar'); | ||
* }); | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
markdownItLoader: ManuallyValidatedOption<(parser: MarkdownIt) => void>; | ||
basePath: string; | ||
cname: string; | ||
htmlLang: string; | ||
githubPages: boolean; | ||
sitemapBaseUrl: string; | ||
hostedBaseUrl: string; | ||
cacheBust: boolean; | ||
@@ -109,2 +130,3 @@ gaID: string; | ||
searchInComments: boolean; | ||
searchInDocuments: boolean; | ||
cleanOutputDir: boolean; | ||
@@ -119,3 +141,2 @@ titleLink: string; | ||
includeFolders: boolean; | ||
fullTree: boolean; | ||
}; | ||
@@ -140,4 +161,2 @@ visibilityFilters: ManuallyValidatedOption<{ | ||
externalSymbolLinkMappings: ManuallyValidatedOption<Record<string, Record<string, string>>>; | ||
media: string; | ||
includes: string; | ||
categorizeByGroup: boolean; | ||
@@ -211,5 +230,5 @@ defaultCategory: string; | ||
export type KeyToDeclaration<K extends keyof TypeDocOptionMap> = TypeDocOptionMap[K] extends boolean ? BooleanDeclarationOption : TypeDocOptionMap[K] extends string ? StringDeclarationOption : TypeDocOptionMap[K] extends number ? NumberDeclarationOption : TypeDocOptionMap[K] extends string[] ? ArrayDeclarationOption : unknown extends TypeDocOptionMap[K] ? MixedDeclarationOption | ObjectDeclarationOption : TypeDocOptionMap[K] extends ManuallyValidatedOption<unknown> ? (MixedDeclarationOption & { | ||
validate(value: unknown): void; | ||
validate(value: unknown, i18n: TranslationProxy): void; | ||
}) | (ObjectDeclarationOption & { | ||
validate(value: unknown): void; | ||
validate(value: unknown, i18n: TranslationProxy): void; | ||
}) : TypeDocOptionMap[K] extends Record<string, boolean> ? FlagsDeclarationOption<TypeDocOptionMap[K]> : TypeDocOptionMap[K] extends Record<string | number, infer U> ? MapDeclarationOption<U> : never; | ||
@@ -259,4 +278,8 @@ export declare enum ParameterHint { | ||
* The help text to be displayed to the user when --help is passed. | ||
* | ||
* This may be a string, which will be presented directly, or a function, | ||
* which will be called with an {@link TranslationProxy} so that option help | ||
* can be translated into the user specified locale. | ||
*/ | ||
help: string; | ||
help: NeverIfInternal<string> | ((i18n: TranslationProxy) => string); | ||
/** | ||
@@ -291,3 +314,3 @@ * The parameter type, used to convert user configuration values into the expected type. | ||
*/ | ||
validate?: (value: string) => void; | ||
validate?: (value: string, i18n: TranslationProxy) => void; | ||
} | ||
@@ -312,3 +335,3 @@ export interface NumberDeclarationOption extends DeclarationOptionBase { | ||
*/ | ||
validate?: (value: number) => void; | ||
validate?: (value: number, i18n: TranslationProxy) => void; | ||
} | ||
@@ -332,3 +355,3 @@ export interface BooleanDeclarationOption extends DeclarationOptionBase { | ||
*/ | ||
validate?: (value: string[]) => void; | ||
validate?: (value: string[], i18n: TranslationProxy) => void; | ||
} | ||
@@ -345,3 +368,3 @@ export interface MixedDeclarationOption extends DeclarationOptionBase { | ||
*/ | ||
validate?: (value: unknown) => void; | ||
validate?: (value: unknown, i18n: TranslationProxy) => void; | ||
} | ||
@@ -358,3 +381,3 @@ export interface ObjectDeclarationOption extends DeclarationOptionBase { | ||
*/ | ||
validate?: (value: unknown) => void; | ||
validate?: (value: unknown, i18n: TranslationProxy) => void; | ||
} | ||
@@ -374,6 +397,2 @@ export interface MapDeclarationOption<T> extends DeclarationOptionBase { | ||
defaultValue: T; | ||
/** | ||
* Optional override for the error reported when an invalid key is provided. | ||
*/ | ||
mapError?: string; | ||
} | ||
@@ -411,3 +430,3 @@ export interface FlagsDeclarationOption<T extends Record<string, boolean>> extends DeclarationOptionBase { | ||
*/ | ||
export declare function convert(value: unknown, option: DeclarationOption, configPath: string, oldValue?: unknown): unknown; | ||
export declare function convert(value: unknown, option: DeclarationOption, i18n: TranslationProxy, configPath: string, oldValue?: unknown): unknown; | ||
export declare function getDefaultValue(option: DeclarationOption): unknown; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getDefaultValue = exports.convert = exports.ParameterType = exports.ParameterHint = exports.CommentStyle = exports.EmitStrategy = void 0; | ||
exports.ParameterType = exports.ParameterHint = exports.CommentStyle = exports.EmitStrategy = void 0; | ||
exports.convert = convert; | ||
exports.getDefaultValue = getDefaultValue; | ||
const path_1 = require("path"); | ||
@@ -60,18 +62,18 @@ /** @enum */ | ||
const converters = { | ||
[ParameterType.String](value, option) { | ||
[ParameterType.String](value, option, i18n) { | ||
const stringValue = value == null ? "" : String(value); | ||
option.validate?.(stringValue); | ||
option.validate?.(stringValue, i18n); | ||
return stringValue; | ||
}, | ||
[ParameterType.Path](value, option, configPath) { | ||
[ParameterType.Path](value, option, i18n, configPath) { | ||
const stringValue = value == null ? "" : (0, path_1.resolve)(configPath, String(value)); | ||
option.validate?.(stringValue); | ||
option.validate?.(stringValue, i18n); | ||
return stringValue; | ||
}, | ||
[ParameterType.Number](value, option) { | ||
[ParameterType.Number](value, option, i18n) { | ||
const numValue = parseInt(String(value), 10) || 0; | ||
if (!valueIsWithinBounds(numValue, option.minValue, option.maxValue)) { | ||
throw new Error(getBoundsError(option.name, option.minValue, option.maxValue)); | ||
throw new Error(getBoundsError(option.name, i18n, option.minValue, option.maxValue)); | ||
} | ||
option.validate?.(numValue); | ||
option.validate?.(numValue, i18n); | ||
return numValue; | ||
@@ -82,3 +84,3 @@ }, | ||
}, | ||
[ParameterType.Array](value, option) { | ||
[ParameterType.Array](value, option, i18n) { | ||
let strArrValue = new Array(); | ||
@@ -91,6 +93,6 @@ if (Array.isArray(value)) { | ||
} | ||
option.validate?.(strArrValue); | ||
option.validate?.(strArrValue, i18n); | ||
return strArrValue; | ||
}, | ||
[ParameterType.PathArray](value, option, configPath) { | ||
[ParameterType.PathArray](value, option, i18n, configPath) { | ||
let strArrValue = new Array(); | ||
@@ -104,6 +106,6 @@ if (Array.isArray(value)) { | ||
strArrValue = strArrValue.map((path) => (0, path_1.resolve)(configPath, path)); | ||
option.validate?.(strArrValue); | ||
option.validate?.(strArrValue, i18n); | ||
return strArrValue; | ||
}, | ||
[ParameterType.ModuleArray](value, option, configPath) { | ||
[ParameterType.ModuleArray](value, option, i18n, configPath) { | ||
let strArrValue = new Array(); | ||
@@ -117,6 +119,6 @@ if (Array.isArray(value)) { | ||
strArrValue = resolveModulePaths(strArrValue, configPath); | ||
option.validate?.(strArrValue); | ||
option.validate?.(strArrValue, i18n); | ||
return strArrValue; | ||
}, | ||
[ParameterType.GlobArray](value, option, configPath) { | ||
[ParameterType.GlobArray](value, option, i18n, configPath) { | ||
let strArrValue = new Array(); | ||
@@ -130,6 +132,6 @@ if (Array.isArray(value)) { | ||
strArrValue = resolveGlobPaths(strArrValue, configPath); | ||
option.validate?.(strArrValue); | ||
option.validate?.(strArrValue, i18n); | ||
return strArrValue; | ||
}, | ||
[ParameterType.Map](value, option) { | ||
[ParameterType.Map](value, option, i18n) { | ||
const key = String(value); | ||
@@ -153,10 +155,10 @@ if (option.map instanceof Map) { | ||
} | ||
throw new Error(option.mapError ?? getMapError(option.map, option.name)); | ||
throw new Error(getMapError(option.map, i18n, option.name)); | ||
}, | ||
[ParameterType.Mixed](value, option) { | ||
option.validate?.(value); | ||
[ParameterType.Mixed](value, option, i18n) { | ||
option.validate?.(value, i18n); | ||
return value; | ||
}, | ||
[ParameterType.Object](value, option, _configPath, oldValue) { | ||
option.validate?.(value); | ||
[ParameterType.Object](value, option, i18n, _configPath, oldValue) { | ||
option.validate?.(value, i18n); | ||
if (typeof oldValue !== "undefined") | ||
@@ -166,3 +168,3 @@ value = { ...oldValue, ...value }; | ||
}, | ||
[ParameterType.Flags](value, option) { | ||
[ParameterType.Flags](value, option, i18n) { | ||
if (typeof value === "boolean") { | ||
@@ -172,3 +174,3 @@ value = Object.fromEntries(Object.keys(option.defaults).map((key) => [key, value])); | ||
if (typeof value !== "object" || value == null) { | ||
throw new Error(`Expected an object with flag values for ${option.name} or true/false`); | ||
throw new Error(i18n.expected_object_with_flag_values_for_0(option.name)); | ||
} | ||
@@ -178,3 +180,3 @@ const obj = { ...value }; | ||
if (!Object.prototype.hasOwnProperty.call(option.defaults, key)) { | ||
throw new Error(`The flag '${key}' is not valid for ${option.name}, expected one of: ${Object.keys(option.defaults).join(", ")}`); | ||
throw new Error(i18n.flag_0_is_not_valid_for_1_expected_2(key, option.name, Object.keys(option.defaults).join(", "))); | ||
} | ||
@@ -187,3 +189,3 @@ if (typeof obj[key] !== "boolean") { | ||
else { | ||
throw new Error(`Flag values for ${option.name} must be a boolean.`); | ||
throw new Error(i18n.flag_values_for_0_must_be_booleans(option.name)); | ||
} | ||
@@ -203,7 +205,6 @@ } | ||
*/ | ||
function convert(value, option, configPath, oldValue) { | ||
function convert(value, option, i18n, configPath, oldValue) { | ||
const _converters = converters; | ||
return _converters[option.type ?? ParameterType.String](value, option, configPath, oldValue); | ||
return _converters[option.type ?? ParameterType.String](value, option, i18n, configPath, oldValue); | ||
} | ||
exports.convert = convert; | ||
const defaultGetters = { | ||
@@ -257,3 +258,2 @@ [ParameterType.String](option) { | ||
} | ||
exports.getDefaultValue = getDefaultValue; | ||
function resolveGlobPaths(globs, configPath) { | ||
@@ -286,3 +286,3 @@ return globs.map((path) => { | ||
*/ | ||
function getMapError(map, name) { | ||
function getMapError(map, i18n, name) { | ||
let keys = map instanceof Map ? [...map.keys()] : Object.keys(map); | ||
@@ -295,3 +295,3 @@ // If the map is a TS numeric enum we need to filter out the numeric keys. | ||
} | ||
return `${name} must be one of ${keys.join(", ")}`; | ||
return i18n.option_0_must_be_one_of_1(name, keys.join(", ")); | ||
} | ||
@@ -305,11 +305,11 @@ /** | ||
*/ | ||
function getBoundsError(name, minValue, maxValue) { | ||
function getBoundsError(name, i18n, minValue, maxValue) { | ||
if (isFiniteNumber(minValue) && isFiniteNumber(maxValue)) { | ||
return `${name} must be between ${minValue} and ${maxValue}`; | ||
return i18n.option_0_must_be_between_1_and_2(name, String(minValue), String(maxValue)); | ||
} | ||
else if (isFiniteNumber(minValue)) { | ||
return `${name} must be >= ${minValue}`; | ||
return i18n.option_0_must_be_equal_to_or_greater_than_1(name, String(minValue)); | ||
} | ||
else { | ||
return `${name} must be <= ${maxValue}`; | ||
return i18n.option_0_must_be_less_than_or_equal_to_1(name, String(maxValue)); | ||
} | ||
@@ -316,0 +316,0 @@ } |
import type { Options } from "./options"; | ||
import type { TranslationProxy } from "../../internationalization/internationalization"; | ||
export interface ParameterHelp { | ||
@@ -7,2 +8,2 @@ names: string[]; | ||
} | ||
export declare function getOptionsHelp(options: Options): string; | ||
export declare function getOptionsHelp(options: Options, i18n: TranslationProxy): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getOptionsHelp = void 0; | ||
exports.getOptionsHelp = getOptionsHelp; | ||
const declaration_1 = require("./declaration"); | ||
const highlighter_1 = require("../highlighter"); | ||
const shiki_1 = require("shiki"); | ||
function hasHint(parameter) { | ||
@@ -17,3 +16,3 @@ return ((parameter.type ?? declaration_1.ParameterType.String) === declaration_1.ParameterType.String && | ||
*/ | ||
function getParameterHelp(options) { | ||
function getParameterHelp(options, i18n) { | ||
const parameters = options.getDeclarations(); | ||
@@ -33,3 +32,5 @@ parameters.sort((a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: "base" })); | ||
names.push(name); | ||
helps.push(parameter.help); | ||
helps.push(typeof parameter.help === "string" | ||
? parameter.help | ||
: parameter.help(i18n)); | ||
margin = Math.max(name.length, margin); | ||
@@ -41,3 +42,3 @@ } | ||
const columnWidth = values.reduce((acc, val) => Math.max(acc, val.length), 0) + 2; | ||
const numColumns = Math.max(1, Math.min(maxLineWidth / columnWidth)); | ||
const numColumns = Math.max(1, Math.floor(maxLineWidth / columnWidth)); | ||
let line = ""; | ||
@@ -57,5 +58,5 @@ const out = []; | ||
} | ||
function getOptionsHelp(options) { | ||
const output = ["Usage:", " typedoc path/to/entry.ts", "", "Options:"]; | ||
const columns = getParameterHelp(options); | ||
function getOptionsHelp(options, i18n) { | ||
const output = ["typedoc path/to/entry.ts", "", "Options:"]; | ||
const columns = getParameterHelp(options, i18n); | ||
for (let i = 0; i < columns.names.length; i++) { | ||
@@ -67,5 +68,4 @@ const usage = columns.names[i]; | ||
output.push("", "Supported highlighting languages:", ...toEvenColumns((0, highlighter_1.getSupportedLanguages)(), 80)); | ||
output.push("", "Supported highlighting themes:", ...toEvenColumns(shiki_1.BUNDLED_THEMES, 80)); | ||
output.push("", "Supported highlighting themes:", ...toEvenColumns((0, highlighter_1.getSupportedThemes)(), 80)); | ||
return output.join("\n"); | ||
} | ||
exports.getOptionsHelp = getOptionsHelp; |
@@ -1,2 +0,2 @@ | ||
export { Options, Option, BindOption } from "./options"; | ||
export { Options, Option } from "./options"; | ||
export type { OptionsReader } from "./options"; | ||
@@ -3,0 +3,0 @@ export { ArgumentsReader, PackageJsonReader, TypeDocReader, TSConfigReader, } from "./readers"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ParameterHint = exports.ParameterType = exports.EmitStrategy = exports.CommentStyle = exports.TSConfigReader = exports.TypeDocReader = exports.PackageJsonReader = exports.ArgumentsReader = exports.BindOption = exports.Option = exports.Options = void 0; | ||
exports.ParameterHint = exports.ParameterType = exports.EmitStrategy = exports.CommentStyle = exports.TSConfigReader = exports.TypeDocReader = exports.PackageJsonReader = exports.ArgumentsReader = exports.Option = exports.Options = void 0; | ||
var options_1 = require("./options"); | ||
Object.defineProperty(exports, "Options", { enumerable: true, get: function () { return options_1.Options; } }); | ||
Object.defineProperty(exports, "Option", { enumerable: true, get: function () { return options_1.Option; } }); | ||
Object.defineProperty(exports, "BindOption", { enumerable: true, get: function () { return options_1.BindOption; } }); | ||
var readers_1 = require("./readers"); | ||
@@ -9,0 +8,0 @@ Object.defineProperty(exports, "ArgumentsReader", { enumerable: true, get: function () { return readers_1.ArgumentsReader; } }); |
@@ -5,3 +5,4 @@ import type * as ts from "typescript"; | ||
import type { Logger } from "../loggers"; | ||
import { DeclarationOption, KeyToDeclaration, TypeDocOptionMap, TypeDocOptions, TypeDocOptionValues } from "./declaration"; | ||
import { type DeclarationOption, type KeyToDeclaration, type TypeDocOptionMap, type TypeDocOptions, type TypeDocOptionValues } from "./declaration"; | ||
import type { TranslationProxy } from "../../internationalization/internationalization"; | ||
/** | ||
@@ -72,2 +73,3 @@ * Describes an option reader that discovers user configuration and converts it to the | ||
private _projectReferences; | ||
private _i18n; | ||
/** | ||
@@ -77,3 +79,3 @@ * In packages mode, the directory of the package being converted. | ||
packageDir?: string; | ||
constructor(); | ||
constructor(i18n: TranslationProxy); | ||
/** | ||
@@ -189,3 +191,3 @@ * Clones the options, intended for use in packages mode. | ||
*/ | ||
getHelp(): string; | ||
getHelp(i18n: TranslationProxy): string; | ||
} | ||
@@ -209,32 +211,1 @@ /** | ||
}; | ||
/** | ||
* Binds an option to the given property. Does not register the option. | ||
* | ||
* Note: This is a legacy experimental decorator, and will not work with TS 5.0 decorators | ||
* | ||
* @since v0.16.3 | ||
* @deprecated Will be removed in 0.26, use {@link Option | `@Option`} instead. | ||
*/ | ||
export declare function BindOption<K extends keyof TypeDocOptionMap>(name: K): <IK extends PropertyKey>(target: ({ | ||
application: Application; | ||
} | { | ||
options: Options; | ||
}) & { | ||
[K2 in IK]: TypeDocOptionValues[K]; | ||
}, key: IK) => void; | ||
/** | ||
* Binds an option to the given property. Does not register the option. | ||
* | ||
* Note: This is a legacy experimental decorator, and will not work with TS 5.0 decorators | ||
* | ||
* @since v0.16.3 | ||
* @deprecated Will be removed in 0.26, use {@link Option | `@Option`} instead | ||
* | ||
* @privateRemarks | ||
* This overload is intended for plugin use only with looser type checks. Do not use internally. | ||
*/ | ||
export declare function BindOption(name: NeverIfInternal<string>): (target: { | ||
application: Application; | ||
} | { | ||
options: Options; | ||
}, key: PropertyKey) => void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BindOption = exports.Option = exports.Options = void 0; | ||
exports.Options = void 0; | ||
exports.Option = Option; | ||
const declaration_1 = require("./declaration"); | ||
@@ -31,3 +32,3 @@ const array_1 = require("../array"); | ||
class Options { | ||
constructor() { | ||
constructor(i18n) { | ||
this._readers = []; | ||
@@ -40,2 +41,3 @@ this._declarations = new Map(); | ||
this._projectReferences = []; | ||
this._i18n = i18n; | ||
(0, sources_1.addTypeDocOptions)(this); | ||
@@ -47,3 +49,3 @@ } | ||
copyForPackage(packageDir) { | ||
const options = new Options(); | ||
const options = new Options(this._i18n); | ||
options.packageDir = packageDir; | ||
@@ -158,3 +160,3 @@ options._readers = this._readers.filter((reader) => reader.supportsPackages); | ||
const nearNames = this.getSimilarOptions(name); | ||
throw new Error(`Unknown option '${name}', you may have meant:\n\t${nearNames.join("\n\t")}`); | ||
throw new Error(this._i18n.unknown_option_0_you_may_have_meant_1(name, nearNames.join("\n\t"))); | ||
} | ||
@@ -170,3 +172,3 @@ return this._values[declaration.name]; | ||
const nearNames = this.getSimilarOptions(name); | ||
throw new Error(`Tried to set an option (${name}) that was not declared. You may have meant:\n\t${nearNames.join("\n\t")}`); | ||
throw new Error(this._i18n.unknown_option_0_you_may_have_meant_1(name, nearNames.join("\n\t"))); | ||
} | ||
@@ -176,3 +178,3 @@ let oldValue = this._values[declaration.name]; | ||
oldValue = (0, declaration_2.getDefaultValue)(declaration); | ||
const converted = (0, declaration_2.convert)(value, declaration, configPath ?? process.cwd(), oldValue); | ||
const converted = (0, declaration_2.convert)(value, declaration, this._i18n, configPath ?? process.cwd(), oldValue); | ||
if (declaration.type === declaration_1.ParameterType.Flags) { | ||
@@ -255,4 +257,4 @@ Object.assign(this._values[declaration.name], converted); | ||
*/ | ||
getHelp() { | ||
return (0, help_1.getOptionsHelp)(this); | ||
getHelp(i18n) { | ||
return (0, help_1.getOptionsHelp)(this, i18n); | ||
} | ||
@@ -280,17 +282,2 @@ } | ||
} | ||
exports.Option = Option; | ||
function BindOption(name) { | ||
return function (target, key) { | ||
Object.defineProperty(target, key, { | ||
get() { | ||
const options = "options" in this ? this.options : this.application.options; | ||
const value = options.getValue(name); | ||
return value; | ||
}, | ||
enumerable: true, | ||
configurable: true, | ||
}); | ||
}; | ||
} | ||
exports.BindOption = BindOption; | ||
// Based on https://en.wikipedia.org/wiki/Levenshtein_distance#Iterative_with_two_matrix_rows | ||
@@ -297,0 +284,0 @@ // Slightly modified for improved match results for options |
@@ -43,3 +43,3 @@ "use strict"; | ||
if (decl.configFileOnly) { | ||
logger.error(`The '${decl.name}' option can only be specified via a config file.`); | ||
logger.error(logger.i18n.option_0_can_only_be_specified_by_config_file(decl.name)); | ||
continue; | ||
@@ -65,3 +65,3 @@ } | ||
// Only boolean values have optional values. | ||
logger.warn(`--${decl.name} expected a value, but none was given as an argument`); | ||
logger.warn(logger.i18n.option_0_expected_a_value_but_none_provided(decl.name)); | ||
} | ||
@@ -92,5 +92,3 @@ trySet(decl.name, this.args[index]); | ||
} | ||
logger.error(`Unknown option: ${name}, you may have meant:\n\t${options | ||
.getSimilarOptions(name) | ||
.join("\n\t")}`); | ||
logger.error(logger.i18n.unknown_option_0_may_have_meant_1(name, options.getSimilarOptions(name).join("\n\t"))); | ||
index++; | ||
@@ -97,0 +95,0 @@ } |
@@ -23,3 +23,3 @@ "use strict"; | ||
if ("typedoc" in content) { | ||
logger.warn(`The 'typedoc' key in ${(0, paths_1.nicePath)(file)} was used by the legacy-packages entryPointStrategy and will be ignored.`); | ||
logger.warn(logger.i18n.typedoc_key_in_0_ignored((0, paths_1.nicePath)(file))); | ||
} | ||
@@ -32,3 +32,3 @@ const optsKey = "typedocOptions"; | ||
if (opts === null || typeof opts !== "object") { | ||
logger.error(`Failed to parse the "typedocOptions" field in ${(0, paths_1.nicePath)(file)}, ensure it exists and contains an object.`); | ||
logger.error(logger.i18n.typedoc_options_must_be_object_in_0((0, paths_1.nicePath)(file))); | ||
return; | ||
@@ -35,0 +35,0 @@ } |
@@ -59,3 +59,3 @@ "use strict"; | ||
if (container.isSet("tsconfig")) { | ||
logger.error(`The tsconfig file ${(0, paths_1.nicePath)(file)} does not exist`); | ||
logger.error(logger.i18n.tsconfig_file_0_does_not_exist((0, paths_1.nicePath)(file))); | ||
} | ||
@@ -77,10 +77,7 @@ return; | ||
if (typedocOptions.options) { | ||
logger.error([ | ||
"typedocOptions in tsconfig file specifies an option file to read but the option", | ||
"file has already been read. This is likely a misconfiguration.", | ||
].join(" ")); | ||
logger.error(logger.i18n.tsconfig_file_specifies_options_file()); | ||
delete typedocOptions.options; | ||
} | ||
if (typedocOptions.tsconfig) { | ||
logger.error("typedocOptions in tsconfig file may not specify a tsconfig file to read"); | ||
logger.error(logger.i18n.tsconfig_file_specifies_tsconfig_file()); | ||
delete typedocOptions.tsconfig; | ||
@@ -108,4 +105,3 @@ } | ||
if (overwritten.length) { | ||
logger.warn(`The ${overwritten.join(", ")} defined in typedoc.json will ` + | ||
"be overwritten by configuration in tsdoc.json."); | ||
logger.warn(logger.i18n.tags_0_defined_in_typedoc_json_overwritten_by_tsdoc_json(overwritten.join(", "))); | ||
} | ||
@@ -142,3 +138,3 @@ const config = this.readTsDoc(logger, tsdoc); | ||
if (this.seenTsdocPaths.has(path)) { | ||
logger.error(`Circular reference encountered for "extends" field of ${(0, paths_1.nicePath)(path)}`); | ||
logger.error(logger.i18n.circular_reference_extends_0((0, paths_1.nicePath)(path))); | ||
return; | ||
@@ -149,7 +145,7 @@ } | ||
if (error) { | ||
logger.error(`Failed to read tsdoc.json file at ${(0, paths_1.nicePath)(path)}.`); | ||
logger.error(logger.i18n.failed_read_tsdoc_json_0((0, paths_1.nicePath)(path))); | ||
return; | ||
} | ||
if (!(0, validation_1.validate)(tsDocSchema, config)) { | ||
logger.error(`The file ${(0, paths_1.nicePath)(path)} is not a valid tsdoc.json file.`); | ||
logger.error(logger.i18n.invalid_tsdoc_json_0((0, paths_1.nicePath)(path))); | ||
return; | ||
@@ -166,3 +162,3 @@ } | ||
catch { | ||
logger.error(`Failed to resolve ${extendedPath} to a file in ${(0, paths_1.nicePath)(path)}`); | ||
logger.error(logger.i18n.failed_resolve_0_to_file_in_1(extendedPath, (0, paths_1.nicePath)(path))); | ||
return; | ||
@@ -169,0 +165,0 @@ } |
@@ -61,3 +61,3 @@ "use strict"; | ||
if (container.isSet("options")) { | ||
logger.error(`The options file ${(0, paths_1.nicePath)(path)} does not exist.`); | ||
logger.error(logger.i18n.options_file_0_does_not_exist((0, paths_1.nicePath)(path))); | ||
} | ||
@@ -77,3 +77,3 @@ return; | ||
if (seen.has(file)) { | ||
logger.error(`Tried to load the options file ${(0, paths_1.nicePath)(file)} multiple times.`); | ||
logger.error(logger.i18n.circular_reference_extends_0((0, paths_1.nicePath)(file))); | ||
return; | ||
@@ -86,3 +86,3 @@ } | ||
if (readResult.error) { | ||
logger.error(`Failed to parse ${(0, paths_1.nicePath)(file)}, ensure it exists and contains an object.`); | ||
logger.error(logger.i18n.failed_read_options_file_0((0, paths_1.nicePath)(file))); | ||
return; | ||
@@ -113,3 +113,4 @@ } | ||
catch (error) { | ||
logger.error(`Failed to read ${(0, paths_1.nicePath)(file)}: ${error instanceof Error ? error.message : error}`); | ||
logger.error(logger.i18n.failed_read_options_file_0((0, paths_1.nicePath)(file))); | ||
logger.error(String(error instanceof Error ? error.message : error)); | ||
return; | ||
@@ -119,3 +120,3 @@ } | ||
if (typeof fileContent !== "object" || !fileContent) { | ||
logger.error(`The root value of ${(0, paths_1.nicePath)(file)} is not an object.`); | ||
logger.error(logger.i18n.failed_read_options_file_0((0, paths_1.nicePath)(file))); | ||
return; | ||
@@ -135,3 +136,3 @@ } | ||
catch { | ||
logger.error(`Failed to resolve ${extendedFile} to a file in ${(0, paths_1.nicePath)(file)}`); | ||
logger.error(logger.i18n.failed_resolve_0_to_file_in_1(extendedFile, (0, paths_1.nicePath)(file))); | ||
continue; | ||
@@ -138,0 +139,0 @@ } |
@@ -26,6 +26,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.addTypeDocOptions = void 0; | ||
exports.addTypeDocOptions = addTypeDocOptions; | ||
const loggers_1 = require("../../loggers"); | ||
const declaration_1 = require("../declaration"); | ||
const shiki_1 = require("shiki"); | ||
const sort_1 = require("../../sort"); | ||
@@ -37,2 +36,3 @@ const entry_point_1 = require("../../entry-point"); | ||
const enum_1 = require("../../enum"); | ||
const highlighter_1 = require("../../highlighter"); | ||
// For convenience, added in the same order as they are documented on the website. | ||
@@ -46,3 +46,3 @@ function addTypeDocOptions(options) { | ||
name: "options", | ||
help: "Specify a json option file that should be loaded. If not specified TypeDoc will look for 'typedoc.json' in the current directory.", | ||
help: (i18n) => i18n.help_options(), | ||
hint: declaration_1.ParameterHint.File, | ||
@@ -54,3 +54,3 @@ defaultValue: "", | ||
name: "tsconfig", | ||
help: "Specify a TypeScript config file that should be loaded. If not specified TypeDoc will look for 'tsconfig.json' in the current directory.", | ||
help: (i18n) => i18n.help_tsconfig(), | ||
hint: declaration_1.ParameterHint.File, | ||
@@ -61,11 +61,39 @@ defaultValue: "", | ||
name: "compilerOptions", | ||
help: "Selectively override the TypeScript compiler options used by TypeDoc.", | ||
help: (i18n) => i18n.help_compilerOptions(), | ||
type: declaration_1.ParameterType.Mixed, | ||
configFileOnly: true, | ||
validate(value) { | ||
validate(value, i18n) { | ||
if (!Validation.validate({}, value)) { | ||
throw new Error("The 'compilerOptions' option must be a non-array object."); | ||
throw new Error(i18n.option_0_must_be_an_object("compilerOptions")); | ||
} | ||
}, | ||
}); | ||
options.addDeclaration({ | ||
name: "lang", | ||
help: (i18n) => i18n.help_lang(), | ||
type: declaration_1.ParameterType.String, | ||
defaultValue: "en", | ||
}); | ||
options.addDeclaration({ | ||
name: "locales", | ||
help: (i18n) => i18n.help_locales(), | ||
type: declaration_1.ParameterType.Mixed, | ||
configFileOnly: true, | ||
defaultValue: {}, | ||
validate(value, i18n) { | ||
if (typeof value !== "object" || !value) { | ||
throw new Error(i18n.locales_must_be_an_object()); | ||
} | ||
for (const val of Object.values(value)) { | ||
if (typeof val !== "object" || !val) { | ||
throw new Error(i18n.locales_must_be_an_object()); | ||
} | ||
for (const val2 of Object.values(val)) { | ||
if (typeof val2 !== "string") { | ||
throw new Error(i18n.locales_must_be_an_object()); | ||
} | ||
} | ||
} | ||
}, | ||
}); | ||
/////////////////////////// | ||
@@ -76,3 +104,3 @@ ////// Input Options ////// | ||
name: "entryPoints", | ||
help: "The entry points of your documentation.", | ||
help: (i18n) => i18n.help_entryPoints(), | ||
type: declaration_1.ParameterType.GlobArray, | ||
@@ -82,3 +110,3 @@ }); | ||
name: "entryPointStrategy", | ||
help: "The strategy to be used to convert entry points into documentation modules.", | ||
help: (i18n) => i18n.help_entryPointStrategy(), | ||
type: declaration_1.ParameterType.Map, | ||
@@ -89,4 +117,9 @@ map: entry_point_1.EntryPointStrategy, | ||
options.addDeclaration({ | ||
name: "projectDocuments", | ||
help: (i18n) => i18n.help_projectDocuments(), | ||
type: declaration_1.ParameterType.GlobArray, | ||
}); | ||
options.addDeclaration({ | ||
name: "exclude", | ||
help: "Define patterns to be excluded when expanding a directory that was specified as an entry point.", | ||
help: (i18n) => i18n.help_exclude(), | ||
type: declaration_1.ParameterType.GlobArray, | ||
@@ -96,3 +129,3 @@ }); | ||
name: "externalPattern", | ||
help: "Define patterns for files that should be considered being external.", | ||
help: (i18n) => i18n.help_externalPattern(), | ||
type: declaration_1.ParameterType.GlobArray, | ||
@@ -103,3 +136,3 @@ defaultValue: ["**/node_modules/**"], | ||
name: "excludeExternals", | ||
help: "Prevent externally resolved symbols from being documented.", | ||
help: (i18n) => i18n.help_excludeExternals(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -109,3 +142,3 @@ }); | ||
name: "excludeNotDocumented", | ||
help: "Prevent symbols that are not explicitly documented from appearing in the results.", | ||
help: (i18n) => i18n.help_excludeNotDocumented(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -115,5 +148,5 @@ }); | ||
name: "excludeNotDocumentedKinds", | ||
help: "Specify the type of reflections that can be removed by excludeNotDocumented.", | ||
help: (i18n) => i18n.help_excludeNotDocumentedKinds(), | ||
type: declaration_1.ParameterType.Array, | ||
validate(value) { | ||
validate(value, i18n) { | ||
const invalid = new Set(value); | ||
@@ -133,3 +166,3 @@ const valid = new Set((0, enum_1.getEnumKeys)(kind_1.ReflectionKind)); | ||
if (invalid.size !== 0) { | ||
throw new Error(`excludeNotDocumentedKinds may only specify known values, and invalid values were provided (${Array.from(invalid).join(", ")}). The valid kinds are:\n${Array.from(valid).join(", ")}`); | ||
throw new Error(i18n.exclude_not_documented_specified_0_valid_values_are_1(Array.from(invalid).join(", "), Array.from(valid).join(", "))); | ||
} | ||
@@ -161,3 +194,3 @@ }, | ||
name: "excludeInternal", | ||
help: "Prevent symbols that are marked with @internal from being documented.", | ||
help: (i18n) => i18n.help_excludeInternal(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -167,3 +200,3 @@ }); | ||
name: "excludeCategories", | ||
help: "Exclude symbols within this category from the documentation.", | ||
help: (i18n) => i18n.help_excludeCategories(), | ||
type: declaration_1.ParameterType.Array, | ||
@@ -174,3 +207,3 @@ defaultValue: [], | ||
name: "excludePrivate", | ||
help: "Ignore private variables and methods.", | ||
help: (i18n) => i18n.help_excludePrivate(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -180,3 +213,3 @@ }); | ||
name: "excludeProtected", | ||
help: "Ignore protected variables and methods.", | ||
help: (i18n) => i18n.help_excludeProtected(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -186,3 +219,3 @@ }); | ||
name: "excludeReferences", | ||
help: "If a symbol is exported multiple times, ignore all but the first export.", | ||
help: (i18n) => i18n.help_excludeReferences(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -192,17 +225,16 @@ }); | ||
name: "externalSymbolLinkMappings", | ||
help: "Define custom links for symbols not included in the documentation.", | ||
help: (i18n) => i18n.help_externalSymbolLinkMappings(), | ||
type: declaration_1.ParameterType.Mixed, | ||
defaultValue: {}, | ||
validate(value) { | ||
const error = "externalSymbolLinkMappings must be a Record<package name, Record<symbol name, link>>"; | ||
validate(value, i18n) { | ||
if (!Validation.validate({}, value)) { | ||
throw new Error(error); | ||
throw new Error(i18n.external_symbol_link_mappings_must_be_object()); | ||
} | ||
for (const mappings of Object.values(value)) { | ||
if (!Validation.validate({}, mappings)) { | ||
throw new Error(error); | ||
throw new Error(i18n.external_symbol_link_mappings_must_be_object()); | ||
} | ||
for (const link of Object.values(mappings)) { | ||
if (typeof link !== "string") { | ||
throw new Error(error); | ||
throw new Error(i18n.external_symbol_link_mappings_must_be_object()); | ||
} | ||
@@ -213,14 +245,2 @@ } | ||
}); | ||
options.addDeclaration({ | ||
name: "media", | ||
help: "Specify the location with media files that should be copied to the output directory.", | ||
type: declaration_1.ParameterType.Path, | ||
hint: declaration_1.ParameterHint.Directory, | ||
}); | ||
options.addDeclaration({ | ||
name: "includes", | ||
help: "Specify the location to look for included documents (use [[include:FILENAME]] in comments).", | ||
type: declaration_1.ParameterType.Path, | ||
hint: declaration_1.ParameterHint.Directory, | ||
}); | ||
/////////////////////////// | ||
@@ -231,3 +251,3 @@ ///// Output Options ////// | ||
name: "out", | ||
help: "Specify the location the documentation should be written to.", | ||
help: (i18n) => i18n.help_out(), | ||
type: declaration_1.ParameterType.Path, | ||
@@ -239,3 +259,3 @@ hint: declaration_1.ParameterHint.Directory, | ||
name: "json", | ||
help: "Specify the location and filename a JSON file describing the project is written to.", | ||
help: (i18n) => i18n.help_json(), | ||
type: declaration_1.ParameterType.Path, | ||
@@ -246,3 +266,3 @@ hint: declaration_1.ParameterHint.File, | ||
name: "pretty", | ||
help: "Specify whether the output JSON should be formatted with tabs.", | ||
help: (i18n) => i18n.help_pretty(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -253,3 +273,3 @@ defaultValue: true, | ||
name: "emit", | ||
help: "Specify what TypeDoc should emit, 'docs', 'both', or 'none'.", | ||
help: (i18n) => i18n.help_emit(), | ||
type: declaration_1.ParameterType.Map, | ||
@@ -261,3 +281,3 @@ map: declaration_1.EmitStrategy, | ||
name: "theme", | ||
help: "Specify the theme name to render the documentation with", | ||
help: (i18n) => i18n.help_theme(), | ||
type: declaration_1.ParameterType.String, | ||
@@ -270,8 +290,8 @@ defaultValue: "default", | ||
name: "lightHighlightTheme", | ||
help: "Specify the code highlighting theme in light mode.", | ||
help: (i18n) => i18n.help_lightHighlightTheme(), | ||
type: declaration_1.ParameterType.String, | ||
defaultValue: defaultLightTheme, | ||
validate(value) { | ||
if (!shiki_1.BUNDLED_THEMES.includes(value)) { | ||
throw new Error(`lightHighlightTheme must be one of the following: ${shiki_1.BUNDLED_THEMES.join(", ")}`); | ||
validate(value, i18n) { | ||
if (!(0, highlighter_1.getSupportedThemes)().includes(value)) { | ||
throw new Error(i18n.highlight_theme_0_must_be_one_of_1("lightHighlightTheme", (0, highlighter_1.getSupportedThemes)().join(", "))); | ||
} | ||
@@ -282,8 +302,8 @@ }, | ||
name: "darkHighlightTheme", | ||
help: "Specify the code highlighting theme in dark mode.", | ||
help: (i18n) => i18n.help_darkHighlightTheme(), | ||
type: declaration_1.ParameterType.String, | ||
defaultValue: defaultDarkTheme, | ||
validate(value) { | ||
if (!shiki_1.BUNDLED_THEMES.includes(value)) { | ||
throw new Error(`darkHighlightTheme must be one of the following: ${shiki_1.BUNDLED_THEMES.join(", ")}`); | ||
validate(value, i18n) { | ||
if (!(0, highlighter_1.getSupportedThemes)().includes(value)) { | ||
throw new Error(i18n.highlight_theme_0_must_be_one_of_1("darkHighlightTheme", (0, highlighter_1.getSupportedThemes)().join(", "))); | ||
} | ||
@@ -294,13 +314,16 @@ }, | ||
name: "customCss", | ||
help: "Path to a custom CSS file to for the theme to import.", | ||
help: (i18n) => i18n.help_customCss(), | ||
type: declaration_1.ParameterType.Path, | ||
}); | ||
options.addDeclaration({ | ||
name: "markedOptions", | ||
help: "Specify the options passed to Marked, the Markdown parser used by TypeDoc.", | ||
name: "markdownItOptions", | ||
help: (i18n) => i18n.help_markdownItOptions(), | ||
type: declaration_1.ParameterType.Mixed, | ||
configFileOnly: true, | ||
validate(value) { | ||
defaultValue: { | ||
linkify: true, | ||
}, | ||
validate(value, i18n) { | ||
if (!Validation.validate({}, value)) { | ||
throw new Error("The 'markedOptions' option must be a non-array object."); | ||
throw new Error(i18n.option_0_must_be_an_object("markdownItOptions")); | ||
} | ||
@@ -310,4 +333,16 @@ }, | ||
options.addDeclaration({ | ||
name: "markdownItLoader", | ||
help: (i18n) => i18n.help_markdownItLoader(), | ||
type: declaration_1.ParameterType.Mixed, | ||
configFileOnly: true, | ||
defaultValue: () => { }, | ||
validate(value, i18n) { | ||
if (typeof value !== "function") { | ||
throw new Error(i18n.option_0_must_be_a_function("markdownItLoader")); | ||
} | ||
}, | ||
}); | ||
options.addDeclaration({ | ||
name: "maxTypeConversionDepth", | ||
help: "Set the maximum depth of types to be converted.", | ||
help: (i18n) => i18n.help_maxTypeConversionDepth(), | ||
defaultValue: 10, | ||
@@ -318,7 +353,7 @@ type: declaration_1.ParameterType.Number, | ||
name: "name", | ||
help: "Set the name of the project that will be used in the header of the template.", | ||
help: (i18n) => i18n.help_name(), | ||
}); | ||
options.addDeclaration({ | ||
name: "includeVersion", | ||
help: "Add the package version to the project name.", | ||
help: (i18n) => i18n.help_includeVersion(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -328,3 +363,3 @@ }); | ||
name: "disableSources", | ||
help: "Disable setting the source of a reflection when documenting it.", | ||
help: (i18n) => i18n.help_disableSources(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -334,11 +369,11 @@ }); | ||
name: "sourceLinkTemplate", | ||
help: "Specify a link template to be used when generating source urls. If not set, will be automatically created using the git remote. Supports {path}, {line}, {gitRevision} placeholders.", | ||
help: (i18n) => i18n.help_sourceLinkTemplate(), | ||
}); | ||
options.addDeclaration({ | ||
name: "gitRevision", | ||
help: "Use specified revision instead of the last revision for linking to GitHub/Bitbucket source files. Has no effect if disableSources is set.", | ||
help: (i18n) => i18n.help_gitRevision(), | ||
}); | ||
options.addDeclaration({ | ||
name: "gitRemote", | ||
help: "Use the specified remote for linking to GitHub/Bitbucket source files. Has no effect if disableGit or disableSources is set.", | ||
help: (i18n) => i18n.help_gitRemote(), | ||
defaultValue: "origin", | ||
@@ -348,3 +383,3 @@ }); | ||
name: "disableGit", | ||
help: "Assume that all can be linked to with the sourceLinkTemplate, sourceLinkTemplate must be set if this is enabled. {path} will be rooted at basePath", | ||
help: (i18n) => i18n.help_disableGit(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -354,3 +389,3 @@ }); | ||
name: "basePath", | ||
help: "Specifies the base path to be used when displaying file paths.", | ||
help: (i18n) => i18n.help_basePath(), | ||
type: declaration_1.ParameterType.Path, | ||
@@ -360,3 +395,3 @@ }); | ||
name: "excludeTags", | ||
help: "Remove the listed block/modifier tags from doc comments.", | ||
help: (i18n) => i18n.help_excludeTags(), | ||
type: declaration_1.ParameterType.Array, | ||
@@ -370,5 +405,5 @@ defaultValue: [ | ||
], | ||
validate(value) { | ||
validate(value, i18n) { | ||
if (!Validation.validate([Array, Validation.isTagString], value)) { | ||
throw new Error(`excludeTags must be an array of valid tag names.`); | ||
throw new Error(i18n.option_0_values_must_be_array_of_tags("excludeTags")); | ||
} | ||
@@ -379,17 +414,12 @@ }, | ||
name: "readme", | ||
help: "Path to the readme file that should be displayed on the index page. Pass `none` to disable the index page and start the documentation on the globals page.", | ||
help: (i18n) => i18n.help_readme(), | ||
type: declaration_1.ParameterType.Path, | ||
}); | ||
options.addDeclaration({ | ||
name: "stripYamlFrontmatter", | ||
help: "Strip YAML frontmatter from markdown files.", | ||
type: declaration_1.ParameterType.Boolean, | ||
}); | ||
options.addDeclaration({ | ||
name: "cname", | ||
help: "Set the CNAME file text, it's useful for custom domains on GitHub Pages.", | ||
help: (i18n) => i18n.help_cname(), | ||
}); | ||
options.addDeclaration({ | ||
name: "sourceLinkExternal", | ||
help: "Specifies that source links should be treated as external links to be opened in a new tab.", | ||
help: (i18n) => i18n.help_sourceLinkExternal(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -399,3 +429,3 @@ }); | ||
name: "githubPages", | ||
help: "Generate a .nojekyll file to prevent 404 errors in GitHub Pages. Defaults to `true`.", | ||
help: (i18n) => i18n.help_githubPages(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -405,7 +435,7 @@ defaultValue: true, | ||
options.addDeclaration({ | ||
name: "sitemapBaseUrl", | ||
help: "Specify a base URL to be used in generating a sitemap.xml in our output folder. If not specified, no sitemap will be generated.", | ||
validate(value) { | ||
name: "hostedBaseUrl", | ||
help: (i18n) => i18n.help_hostedBaseUrl(), | ||
validate(value, i18n) { | ||
if (!/https?:\/\//.test(value)) { | ||
throw new Error("sitemapBaseUrl must start with http:// or https://"); | ||
throw new Error(i18n.hostedBaseUrl_must_start_with_http()); | ||
} | ||
@@ -415,14 +445,8 @@ }, | ||
options.addDeclaration({ | ||
name: "htmlLang", | ||
help: "Sets the lang attribute in the generated html tag.", | ||
type: declaration_1.ParameterType.String, | ||
defaultValue: "en", | ||
}); | ||
options.addDeclaration({ | ||
name: "gaID", | ||
help: "Set the Google Analytics tracking ID and activate tracking code.", | ||
help: (i18n) => i18n.help_gaID(), | ||
}); | ||
options.addDeclaration({ | ||
name: "hideGenerator", | ||
help: "Do not print the TypeDoc link at the end of the page.", | ||
help: (i18n) => i18n.help_hideGenerator(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -432,3 +456,3 @@ }); | ||
name: "hideParameterTypesInTitle", | ||
help: "Hides parameter types in signature titles for easier scanning.", | ||
help: (i18n) => i18n.help_hideParameterTypesInTitle(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -439,3 +463,3 @@ defaultValue: true, | ||
name: "cacheBust", | ||
help: "Include the generation time in links to static assets.", | ||
help: (i18n) => i18n.help_cacheBust(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -445,8 +469,13 @@ }); | ||
name: "searchInComments", | ||
help: "If set, the search index will also include comments. This will greatly increase the size of the search index.", | ||
help: (i18n) => i18n.help_searchInComments(), | ||
type: declaration_1.ParameterType.Boolean, | ||
}); | ||
options.addDeclaration({ | ||
name: "searchInDocuments", | ||
help: (i18n) => i18n.help_searchInDocuments(), | ||
type: declaration_1.ParameterType.Boolean, | ||
}); | ||
options.addDeclaration({ | ||
name: "cleanOutputDir", | ||
help: "If set, TypeDoc will remove the output directory before writing output.", | ||
help: (i18n) => i18n.help_cleanOutputDir(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -457,3 +486,3 @@ defaultValue: true, | ||
name: "titleLink", | ||
help: "Set the link the title in the header points to. Defaults to the documentation homepage.", | ||
help: (i18n) => i18n.help_titleLink(), | ||
type: declaration_1.ParameterType.String, | ||
@@ -463,11 +492,11 @@ }); | ||
name: "navigationLinks", | ||
help: "Defines links to be included in the header.", | ||
help: (i18n) => i18n.help_navigationLinks(), | ||
type: declaration_1.ParameterType.Mixed, | ||
defaultValue: {}, | ||
validate(value) { | ||
validate(value, i18n) { | ||
if (!isObject(value)) { | ||
throw new Error(`navigationLinks must be an object with string labels as keys and URL values.`); | ||
throw new Error(i18n.option_0_must_be_object_with_urls("navigationLinks")); | ||
} | ||
if (Object.values(value).some((x) => typeof x !== "string")) { | ||
throw new Error(`All values of navigationLinks must be string URLs.`); | ||
throw new Error(i18n.option_0_must_be_object_with_urls("navigationLinks")); | ||
} | ||
@@ -478,11 +507,11 @@ }, | ||
name: "sidebarLinks", | ||
help: "Defines links to be included in the sidebar.", | ||
help: (i18n) => i18n.help_sidebarLinks(), | ||
type: declaration_1.ParameterType.Mixed, | ||
defaultValue: {}, | ||
validate(value) { | ||
validate(value, i18n) { | ||
if (!isObject(value)) { | ||
throw new Error(`sidebarLinks must be an object with string labels as keys and URL values.`); | ||
throw new Error(i18n.option_0_must_be_object_with_urls("sidebarLinks")); | ||
} | ||
if (Object.values(value).some((x) => typeof x !== "string")) { | ||
throw new Error(`All values of sidebarLinks must be string URLs.`); | ||
throw new Error(i18n.option_0_must_be_object_with_urls("sidebarLinks")); | ||
} | ||
@@ -493,3 +522,3 @@ }, | ||
name: "navigationLeaves", | ||
help: "Branches of the navigation tree which should not be expanded.", | ||
help: (i18n) => i18n.help_navigationLeaves(), | ||
type: declaration_1.ParameterType.Array, | ||
@@ -499,3 +528,3 @@ }); | ||
name: "navigation", | ||
help: "Determines how the navigation sidebar is organized.", | ||
help: (i18n) => i18n.help_navigation(), | ||
type: declaration_1.ParameterType.Flags, | ||
@@ -506,3 +535,2 @@ defaults: { | ||
includeFolders: true, | ||
fullTree: false, | ||
}, | ||
@@ -512,3 +540,3 @@ }); | ||
name: "visibilityFilters", | ||
help: "Specify the default visibility for builtin filters and additional filters according to modifier tags.", | ||
help: (i18n) => i18n.help_visibilityFilters(), | ||
type: declaration_1.ParameterType.Mixed, | ||
@@ -522,13 +550,13 @@ configFileOnly: true, | ||
}, | ||
validate(value) { | ||
validate(value, i18n) { | ||
const knownKeys = ["protected", "private", "inherited", "external"]; | ||
if (!value || typeof value !== "object") { | ||
throw new Error("visibilityFilters must be an object."); | ||
throw new Error(i18n.option_0_must_be_an_object("visibilityFilters")); | ||
} | ||
for (const [key, val] of Object.entries(value)) { | ||
if (!key.startsWith("@") && !knownKeys.includes(key)) { | ||
throw new Error(`visibilityFilters can only include the following non-@ keys: ${knownKeys.join(", ")}`); | ||
throw new Error(i18n.visibility_filters_only_include_0(knownKeys.join(", "))); | ||
} | ||
if (typeof val !== "boolean") { | ||
throw new Error(`All values of visibilityFilters must be booleans.`); | ||
throw new Error(i18n.visibility_filters_must_be_booleans()); | ||
} | ||
@@ -540,12 +568,12 @@ } | ||
name: "searchCategoryBoosts", | ||
help: "Configure search to give a relevance boost to selected categories", | ||
help: (i18n) => i18n.help_searchCategoryBoosts(), | ||
type: declaration_1.ParameterType.Mixed, | ||
configFileOnly: true, | ||
defaultValue: {}, | ||
validate(value) { | ||
validate(value, i18n) { | ||
if (!isObject(value)) { | ||
throw new Error("The 'searchCategoryBoosts' option must be a non-array object."); | ||
throw new Error(i18n.option_0_must_be_an_object("searchCategoryBoosts")); | ||
} | ||
if (Object.values(value).some((x) => typeof x !== "number")) { | ||
throw new Error("All values of 'searchCategoryBoosts' must be numbers."); | ||
throw new Error(i18n.option_0_values_must_be_numbers("searchCategoryBoosts")); | ||
} | ||
@@ -556,12 +584,12 @@ }, | ||
name: "searchGroupBoosts", | ||
help: 'Configure search to give a relevance boost to selected kinds (eg "class")', | ||
help: (i18n) => i18n.help_searchGroupBoosts(), | ||
type: declaration_1.ParameterType.Mixed, | ||
configFileOnly: true, | ||
defaultValue: {}, | ||
validate(value) { | ||
validate(value, i18n) { | ||
if (!isObject(value)) { | ||
throw new Error("The 'searchGroupBoosts' option must be a non-array object."); | ||
throw new Error(i18n.option_0_must_be_an_object("searchGroupBoosts")); | ||
} | ||
if (Object.values(value).some((x) => typeof x !== "number")) { | ||
throw new Error("All values of 'searchGroupBoosts' must be numbers."); | ||
throw new Error(i18n.option_0_values_must_be_numbers("searchGroupBoosts")); | ||
} | ||
@@ -575,3 +603,3 @@ }, | ||
name: "jsDocCompatibility", | ||
help: "Sets compatibility options for comment parsing that increase similarity with JSDoc comments.", | ||
help: (i18n) => i18n.help_jsDocCompatibility(), | ||
type: declaration_1.ParameterType.Flags, | ||
@@ -587,3 +615,3 @@ defaults: { | ||
name: "commentStyle", | ||
help: "Determines how TypeDoc searches for comments.", | ||
help: (i18n) => i18n.help_commentStyle(), | ||
type: declaration_1.ParameterType.Map, | ||
@@ -595,3 +623,3 @@ map: declaration_1.CommentStyle, | ||
name: "useTsLinkResolution", | ||
help: "Use TypeScript's link resolution when determining where @link tags point. This only applies to JSDoc style comments.", | ||
help: (i18n) => i18n.help_useTsLinkResolution(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -602,3 +630,3 @@ defaultValue: true, | ||
name: "preserveLinkText", | ||
help: "If set, @link tags without link text will use the text content as the link. If not set, will use the target reflection name.", | ||
help: (i18n) => i18n.help_preserveLinkText(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -609,8 +637,8 @@ defaultValue: true, | ||
name: "blockTags", | ||
help: "Block tags which TypeDoc should recognize when parsing comments.", | ||
help: (i18n) => i18n.help_blockTags(), | ||
type: declaration_1.ParameterType.Array, | ||
defaultValue: tsdoc_defaults_1.blockTags, | ||
validate(value) { | ||
validate(value, i18n) { | ||
if (!Validation.validate([Array, Validation.isTagString], value)) { | ||
throw new Error(`blockTags must be an array of valid tag names.`); | ||
throw new Error(i18n.option_0_values_must_be_array_of_tags("blockTags")); | ||
} | ||
@@ -621,8 +649,8 @@ }, | ||
name: "inlineTags", | ||
help: "Inline tags which TypeDoc should recognize when parsing comments.", | ||
help: (i18n) => i18n.help_inlineTags(), | ||
type: declaration_1.ParameterType.Array, | ||
defaultValue: tsdoc_defaults_1.inlineTags, | ||
validate(value) { | ||
validate(value, i18n) { | ||
if (!Validation.validate([Array, Validation.isTagString], value)) { | ||
throw new Error(`inlineTags must be an array of valid tag names.`); | ||
throw new Error(i18n.option_0_values_must_be_array_of_tags("inlineTags")); | ||
} | ||
@@ -633,8 +661,8 @@ }, | ||
name: "modifierTags", | ||
help: "Modifier tags which TypeDoc should recognize when parsing comments.", | ||
help: (i18n) => i18n.help_modifierTags(), | ||
type: declaration_1.ParameterType.Array, | ||
defaultValue: tsdoc_defaults_1.modifierTags, | ||
validate(value) { | ||
validate(value, i18n) { | ||
if (!Validation.validate([Array, Validation.isTagString], value)) { | ||
throw new Error(`modifierTags must be an array of valid tag names.`); | ||
throw new Error(i18n.option_0_values_must_be_array_of_tags("modifierTags")); | ||
} | ||
@@ -648,3 +676,3 @@ }, | ||
name: "categorizeByGroup", | ||
help: "Specify whether categorization will be done at the group level.", | ||
help: (i18n) => i18n.help_categorizeByGroup(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -655,3 +683,3 @@ defaultValue: false, | ||
name: "defaultCategory", | ||
help: "Specify the default category for reflections without a category.", | ||
help: (i18n) => i18n.help_defaultCategory(), | ||
defaultValue: "Other", | ||
@@ -661,3 +689,3 @@ }); | ||
name: "categoryOrder", | ||
help: "Specify the order in which categories appear. * indicates the relative order for categories not in the list.", | ||
help: (i18n) => i18n.help_categoryOrder(), | ||
type: declaration_1.ParameterType.Array, | ||
@@ -667,30 +695,12 @@ }); | ||
name: "groupOrder", | ||
help: "Specify the order in which groups appear. * indicates the relative order for groups not in the list.", | ||
help: (i18n) => i18n.help_groupOrder(), | ||
type: declaration_1.ParameterType.Array, | ||
// Defaults to the same as the defaultKindSortOrder in sort.ts | ||
defaultValue: [ | ||
kind_1.ReflectionKind.Reference, | ||
// project is never a child so never added to a group | ||
kind_1.ReflectionKind.Module, | ||
kind_1.ReflectionKind.Namespace, | ||
kind_1.ReflectionKind.Enum, | ||
kind_1.ReflectionKind.EnumMember, | ||
kind_1.ReflectionKind.Class, | ||
kind_1.ReflectionKind.Interface, | ||
kind_1.ReflectionKind.TypeAlias, | ||
kind_1.ReflectionKind.Constructor, | ||
kind_1.ReflectionKind.Property, | ||
kind_1.ReflectionKind.Variable, | ||
kind_1.ReflectionKind.Function, | ||
kind_1.ReflectionKind.Accessor, | ||
kind_1.ReflectionKind.Method, | ||
// others are never added to groups | ||
].map(kind_1.ReflectionKind.pluralString), | ||
// default order specified in GroupPlugin to correctly handle localization. | ||
}); | ||
options.addDeclaration({ | ||
name: "sort", | ||
help: "Specify the sort strategy for documented values.", | ||
help: (i18n) => i18n.help_sort(), | ||
type: declaration_1.ParameterType.Array, | ||
defaultValue: ["kind", "instance-first", "alphabetical"], | ||
validate(value) { | ||
validate(value, i18n) { | ||
const invalid = new Set(value); | ||
@@ -701,3 +711,3 @@ for (const v of sort_1.SORT_STRATEGIES) { | ||
if (invalid.size !== 0) { | ||
throw new Error(`sort may only specify known values, and invalid values were provided (${Array.from(invalid).join(", ")}). The valid sort strategies are:\n${sort_1.SORT_STRATEGIES.join(", ")}`); | ||
throw new Error(i18n.option_0_specified_1_but_only_2_is_valid("sort", Array.from(invalid).join(", "), sort_1.SORT_STRATEGIES.join(", "))); | ||
} | ||
@@ -708,3 +718,3 @@ }, | ||
name: "sortEntryPoints", | ||
help: "If set, entry points will be subject to the same sorting rules as other reflections.", | ||
help: (i18n) => i18n.help_sortEntryPoints(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -715,6 +725,6 @@ defaultValue: true, | ||
name: "kindSortOrder", | ||
help: "Specify the sort order for reflections when 'kind' is specified.", | ||
help: (i18n) => i18n.help_kindSortOrder(), | ||
type: declaration_1.ParameterType.Array, | ||
defaultValue: [], | ||
validate(value) { | ||
validate(value, i18n) { | ||
const invalid = new Set(value); | ||
@@ -726,3 +736,3 @@ const valid = (0, enum_1.getEnumKeys)(kind_1.ReflectionKind); | ||
if (invalid.size !== 0) { | ||
throw new Error(`kindSortOrder may only specify known values, and invalid values were provided (${Array.from(invalid).join(", ")}). The valid kinds are:\n${valid.join(", ")}`); | ||
throw new Error(i18n.option_0_specified_1_but_only_2_is_valid(`kindSortOrder`, Array.from(invalid).join(", "), valid.join(", "))); | ||
} | ||
@@ -736,3 +746,3 @@ }, | ||
name: "watch", | ||
help: "Watch files for changes and rebuild docs on change.", | ||
help: (i18n) => i18n.help_watch(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -742,3 +752,3 @@ }); | ||
name: "preserveWatchOutput", | ||
help: "If set, TypeDoc will not clear the screen between compilation runs.", | ||
help: (i18n) => i18n.help_preserveWatchOutput(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -748,3 +758,3 @@ }); | ||
name: "skipErrorChecking", | ||
help: "Do not run TypeScript's type checking before generating docs.", | ||
help: (i18n) => i18n.help_skipErrorChecking(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -755,3 +765,3 @@ defaultValue: false, | ||
name: "help", | ||
help: "Print this message.", | ||
help: (i18n) => i18n.help_help(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -761,3 +771,3 @@ }); | ||
name: "version", | ||
help: "Print TypeDoc's version.", | ||
help: (i18n) => i18n.help_version(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -767,3 +777,3 @@ }); | ||
name: "showConfig", | ||
help: "Print the resolved configuration and exit.", | ||
help: (i18n) => i18n.help_showConfig(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -773,3 +783,3 @@ }); | ||
name: "plugin", | ||
help: "Specify the npm plugins that should be loaded. Omit to load all installed plugins.", | ||
help: (i18n) => i18n.help_plugin(), | ||
type: declaration_1.ParameterType.ModuleArray, | ||
@@ -779,3 +789,3 @@ }); | ||
name: "logLevel", | ||
help: "Specify what level of logging should be used.", | ||
help: (i18n) => i18n.help_logLevel(), | ||
type: declaration_1.ParameterType.Map, | ||
@@ -787,3 +797,3 @@ map: loggers_1.LogLevel, | ||
name: "treatWarningsAsErrors", | ||
help: "If set, all warnings will be treated as errors.", | ||
help: (i18n) => i18n.help_treatWarningsAsErrors(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -793,3 +803,3 @@ }); | ||
name: "treatValidationWarningsAsErrors", | ||
help: "If set, warnings emitted during validation will be treated as errors. This option cannot be used to disable treatWarningsAsErrors for validation warnings.", | ||
help: (i18n) => i18n.help_treatValidationWarningsAsErrors(), | ||
type: declaration_1.ParameterType.Boolean, | ||
@@ -799,3 +809,3 @@ }); | ||
name: "intentionallyNotExported", | ||
help: "A list of types which should not produce 'referenced but not documented' warnings.", | ||
help: (i18n) => i18n.help_intentionallyNotExported(), | ||
type: declaration_1.ParameterType.Array, | ||
@@ -805,5 +815,5 @@ }); | ||
name: "requiredToBeDocumented", | ||
help: "A list of reflection kinds that must be documented", | ||
help: (i18n) => i18n.help_requiredToBeDocumented(), | ||
type: declaration_1.ParameterType.Array, | ||
validate(values) { | ||
validate(values, i18n) { | ||
// this is good enough because the values of the ReflectionKind enum are all numbers | ||
@@ -813,3 +823,3 @@ const validValues = (0, enum_1.getEnumKeys)(kind_1.ReflectionKind); | ||
if (!validValues.includes(kind)) { | ||
throw new Error(`'${kind}' is an invalid value for 'requiredToBeDocumented'. Must be one of: ${validValues.join(", ")}`); | ||
throw new Error(i18n.option_0_specified_1_but_only_2_is_valid("requiredToBeDocumented", kind, validValues.join(", "))); | ||
} | ||
@@ -833,3 +843,3 @@ } | ||
name: "validation", | ||
help: "Specify which validation steps TypeDoc should perform on your generated documentation.", | ||
help: (i18n) => i18n.help_validation(), | ||
type: declaration_1.ParameterType.Flags, | ||
@@ -843,5 +853,4 @@ defaults: { | ||
} | ||
exports.addTypeDocOptions = addTypeDocOptions; | ||
function isObject(x) { | ||
return !!x && typeof x === "object" && !Array.isArray(x); | ||
} |
export declare const tsdocBlockTags: readonly ["@deprecated", "@param", "@remarks", "@returns", "@throws", "@privateRemarks", "@defaultValue", "@typeParam"]; | ||
export declare const blockTags: readonly ["@deprecated", "@param", "@remarks", "@returns", "@throws", "@privateRemarks", "@defaultValue", "@typeParam", "@module", "@inheritDoc", "@group", "@groupDescription", "@category", "@categoryDescription", "@template", "@type", "@typedef", "@callback", "@prop", "@property", "@satisfies"]; | ||
export declare const blockTags: readonly ["@deprecated", "@param", "@remarks", "@returns", "@throws", "@privateRemarks", "@defaultValue", "@typeParam", "@module", "@inheritDoc", "@group", "@groupDescription", "@category", "@categoryDescription", "@template", "@type", "@typedef", "@callback", "@prop", "@property", "@satisfies", "@license", "@import"]; | ||
export declare const tsdocInlineTags: readonly ["@link", "@inheritDoc", "@label"]; | ||
@@ -4,0 +4,0 @@ export declare const inlineTags: string[]; |
@@ -32,2 +32,4 @@ "use strict"; | ||
"@satisfies", | ||
"@license", | ||
"@import", | ||
]; | ||
@@ -34,0 +36,0 @@ exports.tsdocInlineTags = ["@link", "@inheritDoc", "@label"]; |
@@ -8,5 +8,5 @@ import type { Logger } from "./loggers"; | ||
/** | ||
* Given a list of (potentially wildcarded) package paths, | ||
* Given a list of (potentially wildcard containing) package paths, | ||
* return all the actual package folders found. | ||
*/ | ||
export declare function expandPackages(logger: Logger, packageJsonDir: string, workspaces: string[], exclude: Minimatch[]): string[]; |
"use strict"; | ||
// Utilities to support the inspection of node package "manifests" | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.expandPackages = exports.loadPackageManifest = void 0; | ||
exports.loadPackageManifest = loadPackageManifest; | ||
exports.expandPackages = expandPackages; | ||
const path_1 = require("path"); | ||
@@ -23,3 +24,3 @@ const fs_1 = require("./fs"); | ||
if (typeof packageJson !== "object" || !packageJson) { | ||
logger.error(`The file ${packageJsonPath} is not an object.`); | ||
logger.error(logger.i18n.file_0_not_an_object((0, paths_1.nicePath)(packageJsonPath))); | ||
return undefined; | ||
@@ -29,3 +30,2 @@ } | ||
} | ||
exports.loadPackageManifest = loadPackageManifest; | ||
/** | ||
@@ -53,3 +53,3 @@ * Load the paths to packages specified in a Yarn workspace package JSON | ||
/** | ||
* Given a list of (potentially wildcarded) package paths, | ||
* Given a list of (potentially wildcard containing) package paths, | ||
* return all the actual package folders found. | ||
@@ -64,12 +64,12 @@ */ | ||
return workspaces.flatMap((workspace) => { | ||
const globbedPackageJsonPaths = (0, fs_1.glob)((0, path_1.resolve)(packageJsonDir, workspace, "package.json"), (0, path_1.resolve)(packageJsonDir)); | ||
if (globbedPackageJsonPaths.length === 0) { | ||
logger.warn(`The entrypoint glob ${(0, paths_1.nicePath)(workspace)} did not match any directories containing package.json.`); | ||
const expandedPackageJsonPaths = (0, fs_1.glob)((0, path_1.resolve)(packageJsonDir, workspace, "package.json"), (0, path_1.resolve)(packageJsonDir)); | ||
if (expandedPackageJsonPaths.length === 0) { | ||
logger.warn(logger.i18n.entry_point_0_did_not_match_any_packages((0, paths_1.nicePath)(workspace))); | ||
} | ||
else { | ||
logger.verbose(`Expanded ${(0, paths_1.nicePath)(workspace)} to:\n\t${globbedPackageJsonPaths | ||
logger.verbose(`Expanded ${(0, paths_1.nicePath)(workspace)} to:\n\t${expandedPackageJsonPaths | ||
.map(paths_1.nicePath) | ||
.join("\n\t")}`); | ||
} | ||
return globbedPackageJsonPaths.flatMap((packageJsonPath) => { | ||
return expandedPackageJsonPaths.flatMap((packageJsonPath) => { | ||
if ((0, paths_1.matchesAny)(exclude, (0, path_1.dirname)(packageJsonPath))) { | ||
@@ -80,3 +80,2 @@ return []; | ||
if (packageJson === undefined) { | ||
logger.error(`Failed to load ${packageJsonPath}`); | ||
return []; | ||
@@ -94,2 +93,1 @@ } | ||
} | ||
exports.expandPackages = expandPackages; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.normalizePath = exports.nicePath = exports.matchesAny = exports.createMinimatch = void 0; | ||
exports.createMinimatch = createMinimatch; | ||
exports.matchesAny = matchesAny; | ||
exports.nicePath = nicePath; | ||
exports.normalizePath = normalizePath; | ||
const minimatch_1 = require("minimatch"); | ||
@@ -16,3 +19,2 @@ const path_1 = require("path"); | ||
} | ||
exports.createMinimatch = createMinimatch; | ||
function matchesAny(patterns, path) { | ||
@@ -22,3 +24,2 @@ const normPath = normalizePath(path).replace(/^\w:\//, ""); | ||
} | ||
exports.matchesAny = matchesAny; | ||
function nicePath(absPath) { | ||
@@ -33,3 +34,2 @@ if (!(0, path_1.isAbsolute)(absPath)) | ||
} | ||
exports.nicePath = nicePath; | ||
/** | ||
@@ -44,2 +44,1 @@ * Normalize the given path. | ||
} | ||
exports.normalizePath = normalizePath; |
"use strict"; | ||
/* eslint-disable no-console */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.measure = exports.Bench = exports.bench = void 0; | ||
exports.bench = bench; | ||
exports.Bench = Bench; | ||
exports.measure = measure; | ||
const perf_hooks_1 = require("perf_hooks"); | ||
@@ -42,3 +44,2 @@ const benchmarks = []; | ||
} | ||
exports.bench = bench; | ||
function Bench(value, context) { | ||
@@ -54,7 +55,5 @@ let runner; | ||
} | ||
exports.Bench = Bench; | ||
function measure(cb) { | ||
return bench(cb, "measure()")(); | ||
} | ||
exports.measure = measure; | ||
process.on("exit", () => { | ||
@@ -61,0 +60,0 @@ if (!benchmarks.length) |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loadPlugins = void 0; | ||
exports.loadPlugins = loadPlugins; | ||
const path_1 = require("path"); | ||
@@ -32,10 +32,10 @@ const url_1 = require("url"); | ||
await initFunction(app); | ||
app.logger.info(`Loaded plugin ${pluginDisplay}`); | ||
app.logger.info(app.i18n.loaded_plugin_0(pluginDisplay)); | ||
} | ||
else { | ||
app.logger.error(`Invalid structure in plugin ${pluginDisplay}, no load function found.`); | ||
app.logger.error(app.i18n.invalid_plugin_0_missing_load_function(pluginDisplay)); | ||
} | ||
} | ||
catch (error) { | ||
app.logger.error(`The plugin ${pluginDisplay} could not be loaded.`); | ||
app.logger.error(app.i18n.plugin_0_could_not_be_loaded(pluginDisplay)); | ||
if (error instanceof Error && error.stack) { | ||
@@ -47,3 +47,2 @@ app.logger.error(error.stack); | ||
} | ||
exports.loadPlugins = loadPlugins; | ||
function getPluginDisplayName(plugin) { | ||
@@ -50,0 +49,0 @@ const path = (0, paths_1.nicePath)(plugin); |
@@ -1,2 +0,2 @@ | ||
import { ProjectReflection, ReferenceType, Reflection } from "../models"; | ||
import { type ProjectReflection, type ReferenceType, Reflection } from "../models"; | ||
export declare function discoverAllReferenceTypes(project: ProjectReflection, forExportValidation: boolean): { | ||
@@ -3,0 +3,0 @@ type: ReferenceType; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.discoverAllReferenceTypes = void 0; | ||
exports.discoverAllReferenceTypes = discoverAllReferenceTypes; | ||
const models_1 = require("../models"); | ||
@@ -35,3 +35,3 @@ function discoverAllReferenceTypes(project, forExportValidation) { | ||
add(current.signatures); | ||
add(current.indexSignature); | ||
add(current.indexSignatures); | ||
add(current.getSignature); | ||
@@ -69,2 +69,1 @@ add(current.setSignature); | ||
} | ||
exports.discoverAllReferenceTypes = discoverAllReferenceTypes; |
@@ -7,4 +7,5 @@ /** | ||
import type { Options } from "./options"; | ||
export declare const SORT_STRATEGIES: readonly ["source-order", "alphabetical", "enum-value-ascending", "enum-value-descending", "enum-member-source-order", "static-first", "instance-first", "visibility", "required-first", "kind", "external-last"]; | ||
import type { DocumentReflection } from "../models"; | ||
export declare const SORT_STRATEGIES: readonly ["source-order", "alphabetical", "alphabetical-ignoring-documents", "enum-value-ascending", "enum-value-descending", "enum-member-source-order", "static-first", "instance-first", "visibility", "required-first", "kind", "external-last", "documents-first", "documents-last"]; | ||
export type SortStrategy = (typeof SORT_STRATEGIES)[number]; | ||
export declare function getSortFunction(opts: Options): (reflections: DeclarationReflection[]) => void; | ||
export declare function getSortFunction(opts: Options): (reflections: (DeclarationReflection | DocumentReflection)[]) => void; |
@@ -7,3 +7,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getSortFunction = exports.SORT_STRATEGIES = void 0; | ||
exports.SORT_STRATEGIES = void 0; | ||
exports.getSortFunction = getSortFunction; | ||
const kind_1 = require("../models/reflections/kind"); | ||
@@ -14,2 +15,3 @@ const types_1 = require("../models/types"); | ||
"alphabetical", | ||
"alphabetical-ignoring-documents", | ||
"enum-value-ascending", | ||
@@ -24,4 +26,7 @@ "enum-value-descending", | ||
"external-last", | ||
"documents-first", | ||
"documents-last", | ||
]; | ||
const defaultKindSortOrder = [ | ||
kind_1.ReflectionKind.Document, | ||
kind_1.ReflectionKind.Reference, | ||
@@ -75,7 +80,20 @@ kind_1.ReflectionKind.Project, | ||
}, | ||
"alphabetical-ignoring-documents"(a, b) { | ||
if (a.kindOf(kind_1.ReflectionKind.Document) || | ||
b.kindOf(kind_1.ReflectionKind.Document)) { | ||
return false; | ||
} | ||
return a.name < b.name; | ||
}, | ||
"enum-value-ascending"(a, b) { | ||
if (a.kind == kind_1.ReflectionKind.EnumMember && | ||
b.kind == kind_1.ReflectionKind.EnumMember) { | ||
const aValue = a.type instanceof types_1.LiteralType ? a.type.value : -Infinity; | ||
const bValue = b.type instanceof types_1.LiteralType ? b.type.value : -Infinity; | ||
const aRefl = a; | ||
const bRefl = b; | ||
const aValue = aRefl.type instanceof types_1.LiteralType | ||
? aRefl.type.value | ||
: -Infinity; | ||
const bValue = bRefl.type instanceof types_1.LiteralType | ||
? bRefl.type.value | ||
: -Infinity; | ||
return aValue < bValue; | ||
@@ -88,4 +106,10 @@ } | ||
b.kind == kind_1.ReflectionKind.EnumMember) { | ||
const aValue = a.type instanceof types_1.LiteralType ? a.type.value : -Infinity; | ||
const bValue = b.type instanceof types_1.LiteralType ? b.type.value : -Infinity; | ||
const aRefl = a; | ||
const bRefl = b; | ||
const aValue = aRefl.type instanceof types_1.LiteralType | ||
? aRefl.type.value | ||
: -Infinity; | ||
const bValue = bRefl.type instanceof types_1.LiteralType | ||
? bRefl.type.value | ||
: -Infinity; | ||
return bValue < aValue; | ||
@@ -132,2 +156,10 @@ } | ||
}, | ||
"documents-first"(a, b) { | ||
return (a.kindOf(kind_1.ReflectionKind.Document) && | ||
!b.kindOf(kind_1.ReflectionKind.Document)); | ||
}, | ||
"documents-last"(a, b) { | ||
return (!a.kindOf(kind_1.ReflectionKind.Document) && | ||
b.kindOf(kind_1.ReflectionKind.Document)); | ||
}, | ||
}; | ||
@@ -159,2 +191,1 @@ function getSortFunction(opts) { | ||
} | ||
exports.getSortFunction = getSortFunction; |
@@ -6,3 +6,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.readTsConfig = exports.getTypeDocOptionsFromTsConfig = exports.findTsConfigFile = void 0; | ||
exports.findTsConfigFile = findTsConfigFile; | ||
exports.getTypeDocOptionsFromTsConfig = getTypeDocOptionsFromTsConfig; | ||
exports.readTsConfig = readTsConfig; | ||
const typescript_1 = __importDefault(require("typescript")); | ||
@@ -21,3 +23,2 @@ const fs_1 = require("./fs"); | ||
} | ||
exports.findTsConfigFile = findTsConfigFile; | ||
// We don't need recursive read checks because that would cause a diagnostic | ||
@@ -53,3 +54,2 @@ // when reading the tsconfig for compiler options, which happens first, and we bail before | ||
} | ||
exports.getTypeDocOptionsFromTsConfig = getTypeDocOptionsFromTsConfig; | ||
const tsConfigCache = {}; | ||
@@ -71,2 +71,1 @@ function readTsConfig(path, logger) { | ||
} | ||
exports.readTsConfig = readTsConfig; |
@@ -26,3 +26,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getHumanName = exports.getQualifiedName = void 0; | ||
exports.getQualifiedName = getQualifiedName; | ||
exports.getHumanName = getHumanName; | ||
const ts = __importStar(require("typescript")); | ||
@@ -43,3 +44,2 @@ function getQualifiedName(symbol, defaultName) { | ||
} | ||
exports.getQualifiedName = getQualifiedName; | ||
function getHumanName(name) { | ||
@@ -53,2 +53,1 @@ // Unique symbols get a name that will change between runs of the compiler. | ||
} | ||
exports.getHumanName = getHumanName; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isTagString = exports.optional = exports.validate = exports.additionalProperties = void 0; | ||
exports.additionalProperties = void 0; | ||
exports.validate = validate; | ||
exports.optional = optional; | ||
exports.isTagString = isTagString; | ||
const opt = Symbol(); | ||
@@ -48,10 +51,7 @@ /** | ||
} | ||
exports.validate = validate; | ||
function optional(x) { | ||
return { [opt]: x }; | ||
} | ||
exports.optional = optional; | ||
function isTagString(x) { | ||
return typeof x === "string" && /^@[a-zA-Z][a-zA-Z0-9]*$/.test(x); | ||
} | ||
exports.isTagString = isTagString; |
@@ -1,3 +0,3 @@ | ||
import { ProjectReflection, ReflectionKind } from "../models"; | ||
import { type ProjectReflection, ReflectionKind } from "../models"; | ||
import type { Logger } from "../utils"; | ||
export declare function validateDocumentation(project: ProjectReflection, logger: Logger, requiredToBeDocumented: readonly ReflectionKind.KindString[]): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateDocumentation = void 0; | ||
exports.validateDocumentation = validateDocumentation; | ||
const models_1 = require("../models"); | ||
@@ -31,3 +31,3 @@ const enum_1 = require("../utils/enum"); | ||
seen.add(ref); | ||
// If we're a non-parameter inside a parameter, we shouldn't care. Parameters don't get deeply documented | ||
// If inside a parameter, we shouldn't care. Callback parameter's values don't get deeply documented. | ||
let r = ref.parent; | ||
@@ -54,2 +54,8 @@ while (r) { | ||
} | ||
// Construct signatures are considered documented if they are directly within a documented type alias. | ||
if (ref.kindOf(models_1.ReflectionKind.ConstructorSignature) && | ||
ref.parent?.parent?.kindOf(models_1.ReflectionKind.TypeAlias)) { | ||
toProcess.push(ref.parent.parent); | ||
continue; | ||
} | ||
if (ref instanceof models_1.DeclarationReflection) { | ||
@@ -74,6 +80,5 @@ const signatures = ref.type instanceof models_1.ReflectionType | ||
} | ||
logger.warn(`${ref.getFriendlyFullName()} (${models_1.ReflectionKind[ref.kind]}), defined in ${(0, paths_1.nicePath)(symbolId.fileName)}, does not have any documentation.`); | ||
logger.warn(logger.i18n.reflection_0_kind_1_defined_in_2_does_not_have_any_documentation(ref.getFriendlyFullName(), models_1.ReflectionKind[ref.kind], (0, paths_1.nicePath)(symbolId.fileName))); | ||
} | ||
} | ||
} | ||
exports.validateDocumentation = validateDocumentation; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateExports = void 0; | ||
exports.validateExports = validateExports; | ||
const assert_1 = require("assert"); | ||
@@ -60,3 +60,3 @@ const paths_1 = require("../utils/paths"); | ||
warned.add(uniqueId); | ||
logger.warn(`${type.qualifiedName}, defined in ${(0, paths_1.nicePath)(type.symbolId.fileName)}, is referenced by ${owner.getFullName()} but not included in the documentation.`); | ||
logger.warn(logger.i18n.type_0_defined_in_1_is_referenced_by_2_but_not_included_in_docs(type.qualifiedName, (0, paths_1.nicePath)(type.symbolId.fileName), owner.getFriendlyFullName())); | ||
} | ||
@@ -66,6 +66,4 @@ } | ||
if (unusedIntentional.length) { | ||
logger.warn("The following symbols were marked as intentionally not exported, but were either not referenced in the documentation, or were exported:\n\t" + | ||
unusedIntentional.join("\n\t")); | ||
logger.warn(logger.i18n.invalid_intentionally_not_exported_symbols_0(unusedIntentional.join("\n\t"))); | ||
} | ||
} | ||
exports.validateExports = validateExports; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateLinks = void 0; | ||
exports.validateLinks = validateLinks; | ||
const linkTags = ["@link", "@linkcode", "@linkplain"]; | ||
@@ -29,6 +29,5 @@ function getBrokenLinks(comment) { | ||
} | ||
logger.warn(`Failed to resolve link to "${broken}" in comment for ${reflection.getFriendlyFullName()}.${extra}`); | ||
logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_comment_for_1(broken, `${reflection.getFriendlyFullName()}.${extra}`)); | ||
} | ||
} | ||
} | ||
exports.validateLinks = validateLinks; |
{ | ||
"name": "typedoc", | ||
"description": "Create api documentation for TypeScript projects.", | ||
"version": "0.25.13", | ||
"version": "0.26.0-beta.0", | ||
"homepage": "https://typedoc.org", | ||
@@ -24,20 +24,21 @@ "exports": { | ||
"engines": { | ||
"node": ">= 16" | ||
"node": ">= 18" | ||
}, | ||
"dependencies": { | ||
"lunr": "^2.3.9", | ||
"marked": "^4.3.0", | ||
"minimatch": "^9.0.3", | ||
"shiki": "^0.14.7" | ||
"markdown-it": "^14.1.0", | ||
"minimatch": "^9.0.4", | ||
"shiki": "^1.4.0", | ||
"yaml": "^2.4.2" | ||
}, | ||
"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": "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 || 5.5.x" | ||
}, | ||
"devDependencies": { | ||
"@types/lunr": "^2.3.7", | ||
"@types/marked": "^4.0.8", | ||
"@types/markdown-it": "^14.0.1", | ||
"@types/mocha": "^10.0.6", | ||
"@types/node": "16", | ||
"@typescript-eslint/eslint-plugin": "^7.4.0", | ||
"@typescript-eslint/parser": "^7.4.0", | ||
"@typescript-eslint/eslint-plugin": "^7.7.1", | ||
"@typescript-eslint/parser": "^7.7.1", | ||
"@typestrong/fs-fixture-builder": "github:TypeStrong/fs-fixture-builder#8abd1494280116ff5318dde2c50ad01e1663790c", | ||
@@ -48,6 +49,6 @@ "c8": "^9.1.0", | ||
"mocha": "^10.4.0", | ||
"prettier": "3.0.3", | ||
"prettier": "3.2.5", | ||
"puppeteer": "^13.5.2", | ||
"ts-node": "^10.9.2", | ||
"typescript": "5.4.3" | ||
"typescript": "5.5.0-beta" | ||
}, | ||
@@ -54,0 +55,0 @@ "files": [ |
"use strict"; | ||
"use strict";(()=>{var Ce=Object.create;var ne=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var _e=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var Me=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Fe=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Oe(e))!Re.call(t,i)&&i!==n&&ne(t,i,{get:()=>e[i],enumerable:!(r=Pe(e,i))||r.enumerable});return t};var De=(t,e,n)=>(n=t!=null?Ce(_e(t)):{},Fe(e||!t||!t.__esModule?ne(n,"default",{value:t,enumerable:!0}):n,t));var ae=Me((se,oe)=>{(function(){var t=function(e){var n=new t.Builder;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),n.searchPipeline.add(t.stemmer),e.call(n,n),n.build()};t.version="2.3.9";t.utils={},t.utils.warn=function(e){return function(n){e.console&&console.warn&&console.warn(n)}}(this),t.utils.asString=function(e){return e==null?"":e.toString()},t.utils.clone=function(e){if(e==null)return e;for(var n=Object.create(null),r=Object.keys(e),i=0;i<r.length;i++){var s=r[i],o=e[s];if(Array.isArray(o)){n[s]=o.slice();continue}if(typeof o=="string"||typeof o=="number"||typeof o=="boolean"){n[s]=o;continue}throw new TypeError("clone is not deep and does not support nested objects")}return n},t.FieldRef=function(e,n,r){this.docRef=e,this.fieldName=n,this._stringValue=r},t.FieldRef.joiner="/",t.FieldRef.fromString=function(e){var n=e.indexOf(t.FieldRef.joiner);if(n===-1)throw"malformed field ref string";var r=e.slice(0,n),i=e.slice(n+1);return new t.FieldRef(i,r,e)},t.FieldRef.prototype.toString=function(){return this._stringValue==null&&(this._stringValue=this.fieldName+t.FieldRef.joiner+this.docRef),this._stringValue};t.Set=function(e){if(this.elements=Object.create(null),e){this.length=e.length;for(var n=0;n<this.length;n++)this.elements[e[n]]=!0}else this.length=0},t.Set.complete={intersect:function(e){return e},union:function(){return this},contains:function(){return!0}},t.Set.empty={intersect:function(){return this},union:function(e){return e},contains:function(){return!1}},t.Set.prototype.contains=function(e){return!!this.elements[e]},t.Set.prototype.intersect=function(e){var n,r,i,s=[];if(e===t.Set.complete)return this;if(e===t.Set.empty)return e;this.length<e.length?(n=this,r=e):(n=e,r=this),i=Object.keys(n.elements);for(var o=0;o<i.length;o++){var a=i[o];a in r.elements&&s.push(a)}return new t.Set(s)},t.Set.prototype.union=function(e){return e===t.Set.complete?t.Set.complete:e===t.Set.empty?this:new t.Set(Object.keys(this.elements).concat(Object.keys(e.elements)))},t.idf=function(e,n){var r=0;for(var i in e)i!="_index"&&(r+=Object.keys(e[i]).length);var s=(n-r+.5)/(r+.5);return Math.log(1+Math.abs(s))},t.Token=function(e,n){this.str=e||"",this.metadata=n||{}},t.Token.prototype.toString=function(){return this.str},t.Token.prototype.update=function(e){return this.str=e(this.str,this.metadata),this},t.Token.prototype.clone=function(e){return e=e||function(n){return n},new t.Token(e(this.str,this.metadata),this.metadata)};t.tokenizer=function(e,n){if(e==null||e==null)return[];if(Array.isArray(e))return e.map(function(y){return new t.Token(t.utils.asString(y).toLowerCase(),t.utils.clone(n))});for(var r=e.toString().toLowerCase(),i=r.length,s=[],o=0,a=0;o<=i;o++){var l=r.charAt(o),u=o-a;if(l.match(t.tokenizer.separator)||o==i){if(u>0){var d=t.utils.clone(n)||{};d.position=[a,u],d.index=s.length,s.push(new t.Token(r.slice(a,o),d))}a=o+1}}return s},t.tokenizer.separator=/[\s\-]+/;t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions=Object.create(null),t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn(`Function is not registered with pipeline. This may cause problems when serialising the index. | ||
`,e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(r){var i=t.Pipeline.registeredFunctions[r];if(i)n.add(i);else throw new Error("Cannot load unregistered function: "+r)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(n){t.Pipeline.warnIfFunctionNotRegistered(n),this._stack.push(n)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");r=r+1,this._stack.splice(r,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");this._stack.splice(r,0,n)},t.Pipeline.prototype.remove=function(e){var n=this._stack.indexOf(e);n!=-1&&this._stack.splice(n,1)},t.Pipeline.prototype.run=function(e){for(var n=this._stack.length,r=0;r<n;r++){for(var i=this._stack[r],s=[],o=0;o<e.length;o++){var a=i(e[o],o,e);if(!(a==null||a===""))if(Array.isArray(a))for(var l=0;l<a.length;l++)s.push(a[l]);else s.push(a)}e=s}return e},t.Pipeline.prototype.runString=function(e,n){var r=new t.Token(e,n);return this.run([r]).map(function(i){return i.toString()})},t.Pipeline.prototype.reset=function(){this._stack=[]},t.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})};t.Vector=function(e){this._magnitude=0,this.elements=e||[]},t.Vector.prototype.positionForIndex=function(e){if(this.elements.length==0)return 0;for(var n=0,r=this.elements.length/2,i=r-n,s=Math.floor(i/2),o=this.elements[s*2];i>1&&(o<e&&(n=s),o>e&&(r=s),o!=e);)i=r-n,s=n+Math.floor(i/2),o=this.elements[s*2];if(o==e||o>e)return s*2;if(o<e)return(s+1)*2},t.Vector.prototype.insert=function(e,n){this.upsert(e,n,function(){throw"duplicate index"})},t.Vector.prototype.upsert=function(e,n,r){this._magnitude=0;var i=this.positionForIndex(e);this.elements[i]==e?this.elements[i+1]=r(this.elements[i+1],n):this.elements.splice(i,0,e,n)},t.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;for(var e=0,n=this.elements.length,r=1;r<n;r+=2){var i=this.elements[r];e+=i*i}return this._magnitude=Math.sqrt(e)},t.Vector.prototype.dot=function(e){for(var n=0,r=this.elements,i=e.elements,s=r.length,o=i.length,a=0,l=0,u=0,d=0;u<s&&d<o;)a=r[u],l=i[d],a<l?u+=2:a>l?d+=2:a==l&&(n+=r[u+1]*i[d+1],u+=2,d+=2);return n},t.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},t.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),n=1,r=0;n<this.elements.length;n+=2,r++)e[r]=this.elements[n];return e},t.Vector.prototype.toJSON=function(){return this.elements};t.stemmer=function(){var e={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},n={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},r="[^aeiou]",i="[aeiouy]",s=r+"[^aeiouy]*",o=i+"[aeiou]*",a="^("+s+")?"+o+s,l="^("+s+")?"+o+s+"("+o+")?$",u="^("+s+")?"+o+s+o+s,d="^("+s+")?"+i,y=new RegExp(a),p=new RegExp(u),b=new RegExp(l),g=new RegExp(d),L=/^(.+?)(ss|i)es$/,f=/^(.+?)([^s])s$/,m=/^(.+?)eed$/,S=/^(.+?)(ed|ing)$/,w=/.$/,k=/(at|bl|iz)$/,_=new RegExp("([^aeiouylsz])\\1$"),B=new RegExp("^"+s+i+"[^aeiouwxy]$"),A=/^(.+?[^aeiou])y$/,j=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,$=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,V=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,q=/^(.+?)(s|t)(ion)$/,C=/^(.+?)e$/,z=/ll$/,W=new RegExp("^"+s+i+"[^aeiouwxy]$"),N=function(c){var v,P,T,h,x,O,M;if(c.length<3)return c;if(T=c.substr(0,1),T=="y"&&(c=T.toUpperCase()+c.substr(1)),h=L,x=f,h.test(c)?c=c.replace(h,"$1$2"):x.test(c)&&(c=c.replace(x,"$1$2")),h=m,x=S,h.test(c)){var E=h.exec(c);h=y,h.test(E[1])&&(h=w,c=c.replace(h,""))}else if(x.test(c)){var E=x.exec(c);v=E[1],x=g,x.test(v)&&(c=v,x=k,O=_,M=B,x.test(c)?c=c+"e":O.test(c)?(h=w,c=c.replace(h,"")):M.test(c)&&(c=c+"e"))}if(h=A,h.test(c)){var E=h.exec(c);v=E[1],c=v+"i"}if(h=j,h.test(c)){var E=h.exec(c);v=E[1],P=E[2],h=y,h.test(v)&&(c=v+e[P])}if(h=$,h.test(c)){var E=h.exec(c);v=E[1],P=E[2],h=y,h.test(v)&&(c=v+n[P])}if(h=V,x=q,h.test(c)){var E=h.exec(c);v=E[1],h=p,h.test(v)&&(c=v)}else if(x.test(c)){var E=x.exec(c);v=E[1]+E[2],x=p,x.test(v)&&(c=v)}if(h=C,h.test(c)){var E=h.exec(c);v=E[1],h=p,x=b,O=W,(h.test(v)||x.test(v)&&!O.test(v))&&(c=v)}return h=z,x=p,h.test(c)&&x.test(c)&&(h=w,c=c.replace(h,"")),T=="y"&&(c=T.toLowerCase()+c.substr(1)),c};return function(R){return R.update(N)}}(),t.Pipeline.registerFunction(t.stemmer,"stemmer");t.generateStopWordFilter=function(e){var n=e.reduce(function(r,i){return r[i]=i,r},{});return function(r){if(r&&n[r.toString()]!==r.toString())return r}},t.stopWordFilter=t.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),t.Pipeline.registerFunction(t.stopWordFilter,"stopWordFilter");t.trimmer=function(e){return e.update(function(n){return n.replace(/^\W+/,"").replace(/\W+$/,"")})},t.Pipeline.registerFunction(t.trimmer,"trimmer");t.TokenSet=function(){this.final=!1,this.edges={},this.id=t.TokenSet._nextId,t.TokenSet._nextId+=1},t.TokenSet._nextId=1,t.TokenSet.fromArray=function(e){for(var n=new t.TokenSet.Builder,r=0,i=e.length;r<i;r++)n.insert(e[r]);return n.finish(),n.root},t.TokenSet.fromClause=function(e){return"editDistance"in e?t.TokenSet.fromFuzzyString(e.term,e.editDistance):t.TokenSet.fromString(e.term)},t.TokenSet.fromFuzzyString=function(e,n){for(var r=new t.TokenSet,i=[{node:r,editsRemaining:n,str:e}];i.length;){var s=i.pop();if(s.str.length>0){var o=s.str.charAt(0),a;o in s.node.edges?a=s.node.edges[o]:(a=new t.TokenSet,s.node.edges[o]=a),s.str.length==1&&(a.final=!0),i.push({node:a,editsRemaining:s.editsRemaining,str:s.str.slice(1)})}if(s.editsRemaining!=0){if("*"in s.node.edges)var l=s.node.edges["*"];else{var l=new t.TokenSet;s.node.edges["*"]=l}if(s.str.length==0&&(l.final=!0),i.push({node:l,editsRemaining:s.editsRemaining-1,str:s.str}),s.str.length>1&&i.push({node:s.node,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)}),s.str.length==1&&(s.node.final=!0),s.str.length>=1){if("*"in s.node.edges)var u=s.node.edges["*"];else{var u=new t.TokenSet;s.node.edges["*"]=u}s.str.length==1&&(u.final=!0),i.push({node:u,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)})}if(s.str.length>1){var d=s.str.charAt(0),y=s.str.charAt(1),p;y in s.node.edges?p=s.node.edges[y]:(p=new t.TokenSet,s.node.edges[y]=p),s.str.length==1&&(p.final=!0),i.push({node:p,editsRemaining:s.editsRemaining-1,str:d+s.str.slice(2)})}}}return r},t.TokenSet.fromString=function(e){for(var n=new t.TokenSet,r=n,i=0,s=e.length;i<s;i++){var o=e[i],a=i==s-1;if(o=="*")n.edges[o]=n,n.final=a;else{var l=new t.TokenSet;l.final=a,n.edges[o]=l,n=l}}return r},t.TokenSet.prototype.toArray=function(){for(var e=[],n=[{prefix:"",node:this}];n.length;){var r=n.pop(),i=Object.keys(r.node.edges),s=i.length;r.node.final&&(r.prefix.charAt(0),e.push(r.prefix));for(var o=0;o<s;o++){var a=i[o];n.push({prefix:r.prefix.concat(a),node:r.node.edges[a]})}}return e},t.TokenSet.prototype.toString=function(){if(this._str)return this._str;for(var e=this.final?"1":"0",n=Object.keys(this.edges).sort(),r=n.length,i=0;i<r;i++){var s=n[i],o=this.edges[s];e=e+s+o.id}return e},t.TokenSet.prototype.intersect=function(e){for(var n=new t.TokenSet,r=void 0,i=[{qNode:e,output:n,node:this}];i.length;){r=i.pop();for(var s=Object.keys(r.qNode.edges),o=s.length,a=Object.keys(r.node.edges),l=a.length,u=0;u<o;u++)for(var d=s[u],y=0;y<l;y++){var p=a[y];if(p==d||d=="*"){var b=r.node.edges[p],g=r.qNode.edges[d],L=b.final&&g.final,f=void 0;p in r.output.edges?(f=r.output.edges[p],f.final=f.final||L):(f=new t.TokenSet,f.final=L,r.output.edges[p]=f),i.push({qNode:g,output:f,node:b})}}}return n},t.TokenSet.Builder=function(){this.previousWord="",this.root=new t.TokenSet,this.uncheckedNodes=[],this.minimizedNodes={}},t.TokenSet.Builder.prototype.insert=function(e){var n,r=0;if(e<this.previousWord)throw new Error("Out of order word insertion");for(var i=0;i<e.length&&i<this.previousWord.length&&e[i]==this.previousWord[i];i++)r++;this.minimize(r),this.uncheckedNodes.length==0?n=this.root:n=this.uncheckedNodes[this.uncheckedNodes.length-1].child;for(var i=r;i<e.length;i++){var s=new t.TokenSet,o=e[i];n.edges[o]=s,this.uncheckedNodes.push({parent:n,char:o,child:s}),n=s}n.final=!0,this.previousWord=e},t.TokenSet.Builder.prototype.finish=function(){this.minimize(0)},t.TokenSet.Builder.prototype.minimize=function(e){for(var n=this.uncheckedNodes.length-1;n>=e;n--){var r=this.uncheckedNodes[n],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}};t.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},t.Index.prototype.search=function(e){return this.query(function(n){var r=new t.QueryParser(e,n);r.parse()})},t.Index.prototype.query=function(e){for(var n=new t.Query(this.fields),r=Object.create(null),i=Object.create(null),s=Object.create(null),o=Object.create(null),a=Object.create(null),l=0;l<this.fields.length;l++)i[this.fields[l]]=new t.Vector;e.call(n,n);for(var l=0;l<n.clauses.length;l++){var u=n.clauses[l],d=null,y=t.Set.empty;u.usePipeline?d=this.pipeline.runString(u.term,{fields:u.fields}):d=[u.term];for(var p=0;p<d.length;p++){var b=d[p];u.term=b;var g=t.TokenSet.fromClause(u),L=this.tokenSet.intersect(g).toArray();if(L.length===0&&u.presence===t.Query.presence.REQUIRED){for(var f=0;f<u.fields.length;f++){var m=u.fields[f];o[m]=t.Set.empty}break}for(var S=0;S<L.length;S++)for(var w=L[S],k=this.invertedIndex[w],_=k._index,f=0;f<u.fields.length;f++){var m=u.fields[f],B=k[m],A=Object.keys(B),j=w+"/"+m,$=new t.Set(A);if(u.presence==t.Query.presence.REQUIRED&&(y=y.union($),o[m]===void 0&&(o[m]=t.Set.complete)),u.presence==t.Query.presence.PROHIBITED){a[m]===void 0&&(a[m]=t.Set.empty),a[m]=a[m].union($);continue}if(i[m].upsert(_,u.boost,function(Qe,Ie){return Qe+Ie}),!s[j]){for(var V=0;V<A.length;V++){var q=A[V],C=new t.FieldRef(q,m),z=B[q],W;(W=r[C])===void 0?r[C]=new t.MatchData(w,m,z):W.add(w,m,z)}s[j]=!0}}}if(u.presence===t.Query.presence.REQUIRED)for(var f=0;f<u.fields.length;f++){var m=u.fields[f];o[m]=o[m].intersect(y)}}for(var N=t.Set.complete,R=t.Set.empty,l=0;l<this.fields.length;l++){var m=this.fields[l];o[m]&&(N=N.intersect(o[m])),a[m]&&(R=R.union(a[m]))}var c=Object.keys(r),v=[],P=Object.create(null);if(n.isNegated()){c=Object.keys(this.fieldVectors);for(var l=0;l<c.length;l++){var C=c[l],T=t.FieldRef.fromString(C);r[C]=new t.MatchData}}for(var l=0;l<c.length;l++){var T=t.FieldRef.fromString(c[l]),h=T.docRef;if(N.contains(h)&&!R.contains(h)){var x=this.fieldVectors[T],O=i[T.fieldName].similarity(x),M;if((M=P[h])!==void 0)M.score+=O,M.matchData.combine(r[T]);else{var E={ref:h,score:O,matchData:r[T]};P[h]=E,v.push(E)}}}return v.sort(function(Te,ke){return ke.score-Te.score})},t.Index.prototype.toJSON=function(){var e=Object.keys(this.invertedIndex).sort().map(function(r){return[r,this.invertedIndex[r]]},this),n=Object.keys(this.fieldVectors).map(function(r){return[r,this.fieldVectors[r].toJSON()]},this);return{version:t.version,fields:this.fields,fieldVectors:n,invertedIndex:e,pipeline:this.pipeline.toJSON()}},t.Index.load=function(e){var n={},r={},i=e.fieldVectors,s=Object.create(null),o=e.invertedIndex,a=new t.TokenSet.Builder,l=t.Pipeline.load(e.pipeline);e.version!=t.version&&t.utils.warn("Version mismatch when loading serialised index. Current version of lunr '"+t.version+"' does not match serialized index '"+e.version+"'");for(var u=0;u<i.length;u++){var d=i[u],y=d[0],p=d[1];r[y]=new t.Vector(p)}for(var u=0;u<o.length;u++){var d=o[u],b=d[0],g=d[1];a.insert(b),s[b]=g}return a.finish(),n.fields=e.fields,n.fieldVectors=r,n.invertedIndex=s,n.tokenSet=a.root,n.pipeline=l,new t.Index(n)};t.Builder=function(){this._ref="id",this._fields=Object.create(null),this._documents=Object.create(null),this.invertedIndex=Object.create(null),this.fieldTermFrequencies={},this.fieldLengths={},this.tokenizer=t.tokenizer,this.pipeline=new t.Pipeline,this.searchPipeline=new t.Pipeline,this.documentCount=0,this._b=.75,this._k1=1.2,this.termIndex=0,this.metadataWhitelist=[]},t.Builder.prototype.ref=function(e){this._ref=e},t.Builder.prototype.field=function(e,n){if(/\//.test(e))throw new RangeError("Field '"+e+"' contains illegal character '/'");this._fields[e]=n||{}},t.Builder.prototype.b=function(e){e<0?this._b=0:e>1?this._b=1:this._b=e},t.Builder.prototype.k1=function(e){this._k1=e},t.Builder.prototype.add=function(e,n){var r=e[this._ref],i=Object.keys(this._fields);this._documents[r]=n||{},this.documentCount+=1;for(var s=0;s<i.length;s++){var o=i[s],a=this._fields[o].extractor,l=a?a(e):e[o],u=this.tokenizer(l,{fields:[o]}),d=this.pipeline.run(u),y=new t.FieldRef(r,o),p=Object.create(null);this.fieldTermFrequencies[y]=p,this.fieldLengths[y]=0,this.fieldLengths[y]+=d.length;for(var b=0;b<d.length;b++){var g=d[b];if(p[g]==null&&(p[g]=0),p[g]+=1,this.invertedIndex[g]==null){var L=Object.create(null);L._index=this.termIndex,this.termIndex+=1;for(var f=0;f<i.length;f++)L[i[f]]=Object.create(null);this.invertedIndex[g]=L}this.invertedIndex[g][o][r]==null&&(this.invertedIndex[g][o][r]=Object.create(null));for(var m=0;m<this.metadataWhitelist.length;m++){var S=this.metadataWhitelist[m],w=g.metadata[S];this.invertedIndex[g][o][r][S]==null&&(this.invertedIndex[g][o][r][S]=[]),this.invertedIndex[g][o][r][S].push(w)}}}},t.Builder.prototype.calculateAverageFieldLengths=function(){for(var e=Object.keys(this.fieldLengths),n=e.length,r={},i={},s=0;s<n;s++){var o=t.FieldRef.fromString(e[s]),a=o.fieldName;i[a]||(i[a]=0),i[a]+=1,r[a]||(r[a]=0),r[a]+=this.fieldLengths[o]}for(var l=Object.keys(this._fields),s=0;s<l.length;s++){var u=l[s];r[u]=r[u]/i[u]}this.averageFieldLength=r},t.Builder.prototype.createFieldVectors=function(){for(var e={},n=Object.keys(this.fieldTermFrequencies),r=n.length,i=Object.create(null),s=0;s<r;s++){for(var o=t.FieldRef.fromString(n[s]),a=o.fieldName,l=this.fieldLengths[o],u=new t.Vector,d=this.fieldTermFrequencies[o],y=Object.keys(d),p=y.length,b=this._fields[a].boost||1,g=this._documents[o.docRef].boost||1,L=0;L<p;L++){var f=y[L],m=d[f],S=this.invertedIndex[f]._index,w,k,_;i[f]===void 0?(w=t.idf(this.invertedIndex[f],this.documentCount),i[f]=w):w=i[f],k=w*((this._k1+1)*m)/(this._k1*(1-this._b+this._b*(l/this.averageFieldLength[a]))+m),k*=b,k*=g,_=Math.round(k*1e3)/1e3,u.insert(S,_)}e[o]=u}this.fieldVectors=e},t.Builder.prototype.createTokenSet=function(){this.tokenSet=t.TokenSet.fromArray(Object.keys(this.invertedIndex).sort())},t.Builder.prototype.build=function(){return this.calculateAverageFieldLengths(),this.createFieldVectors(),this.createTokenSet(),new t.Index({invertedIndex:this.invertedIndex,fieldVectors:this.fieldVectors,tokenSet:this.tokenSet,fields:Object.keys(this._fields),pipeline:this.searchPipeline})},t.Builder.prototype.use=function(e){var n=Array.prototype.slice.call(arguments,1);n.unshift(this),e.apply(this,n)},t.MatchData=function(e,n,r){for(var i=Object.create(null),s=Object.keys(r||{}),o=0;o<s.length;o++){var a=s[o];i[a]=r[a].slice()}this.metadata=Object.create(null),e!==void 0&&(this.metadata[e]=Object.create(null),this.metadata[e][n]=i)},t.MatchData.prototype.combine=function(e){for(var n=Object.keys(e.metadata),r=0;r<n.length;r++){var i=n[r],s=Object.keys(e.metadata[i]);this.metadata[i]==null&&(this.metadata[i]=Object.create(null));for(var o=0;o<s.length;o++){var a=s[o],l=Object.keys(e.metadata[i][a]);this.metadata[i][a]==null&&(this.metadata[i][a]=Object.create(null));for(var u=0;u<l.length;u++){var d=l[u];this.metadata[i][a][d]==null?this.metadata[i][a][d]=e.metadata[i][a][d]:this.metadata[i][a][d]=this.metadata[i][a][d].concat(e.metadata[i][a][d])}}}},t.MatchData.prototype.add=function(e,n,r){if(!(e in this.metadata)){this.metadata[e]=Object.create(null),this.metadata[e][n]=r;return}if(!(n in this.metadata[e])){this.metadata[e][n]=r;return}for(var i=Object.keys(r),s=0;s<i.length;s++){var o=i[s];o in this.metadata[e][n]?this.metadata[e][n][o]=this.metadata[e][n][o].concat(r[o]):this.metadata[e][n][o]=r[o]}},t.Query=function(e){this.clauses=[],this.allFields=e},t.Query.wildcard=new String("*"),t.Query.wildcard.NONE=0,t.Query.wildcard.LEADING=1,t.Query.wildcard.TRAILING=2,t.Query.presence={OPTIONAL:1,REQUIRED:2,PROHIBITED:3},t.Query.prototype.clause=function(e){return"fields"in e||(e.fields=this.allFields),"boost"in e||(e.boost=1),"usePipeline"in e||(e.usePipeline=!0),"wildcard"in e||(e.wildcard=t.Query.wildcard.NONE),e.wildcard&t.Query.wildcard.LEADING&&e.term.charAt(0)!=t.Query.wildcard&&(e.term="*"+e.term),e.wildcard&t.Query.wildcard.TRAILING&&e.term.slice(-1)!=t.Query.wildcard&&(e.term=""+e.term+"*"),"presence"in e||(e.presence=t.Query.presence.OPTIONAL),this.clauses.push(e),this},t.Query.prototype.isNegated=function(){for(var e=0;e<this.clauses.length;e++)if(this.clauses[e].presence!=t.Query.presence.PROHIBITED)return!1;return!0},t.Query.prototype.term=function(e,n){if(Array.isArray(e))return e.forEach(function(i){this.term(i,t.utils.clone(n))},this),this;var r=n||{};return r.term=e.toString(),this.clause(r),this},t.QueryParseError=function(e,n,r){this.name="QueryParseError",this.message=e,this.start=n,this.end=r},t.QueryParseError.prototype=new Error,t.QueryLexer=function(e){this.lexemes=[],this.str=e,this.length=e.length,this.pos=0,this.start=0,this.escapeCharPositions=[]},t.QueryLexer.prototype.run=function(){for(var e=t.QueryLexer.lexText;e;)e=e(this)},t.QueryLexer.prototype.sliceString=function(){for(var e=[],n=this.start,r=this.pos,i=0;i<this.escapeCharPositions.length;i++)r=this.escapeCharPositions[i],e.push(this.str.slice(n,r)),n=r+1;return e.push(this.str.slice(n,this.pos)),this.escapeCharPositions.length=0,e.join("")},t.QueryLexer.prototype.emit=function(e){this.lexemes.push({type:e,str:this.sliceString(),start:this.start,end:this.pos}),this.start=this.pos},t.QueryLexer.prototype.escapeCharacter=function(){this.escapeCharPositions.push(this.pos-1),this.pos+=1},t.QueryLexer.prototype.next=function(){if(this.pos>=this.length)return t.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},t.QueryLexer.prototype.width=function(){return this.pos-this.start},t.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},t.QueryLexer.prototype.backup=function(){this.pos-=1},t.QueryLexer.prototype.acceptDigitRun=function(){var e,n;do e=this.next(),n=e.charCodeAt(0);while(n>47&&n<58);e!=t.QueryLexer.EOS&&this.backup()},t.QueryLexer.prototype.more=function(){return this.pos<this.length},t.QueryLexer.EOS="EOS",t.QueryLexer.FIELD="FIELD",t.QueryLexer.TERM="TERM",t.QueryLexer.EDIT_DISTANCE="EDIT_DISTANCE",t.QueryLexer.BOOST="BOOST",t.QueryLexer.PRESENCE="PRESENCE",t.QueryLexer.lexField=function(e){return e.backup(),e.emit(t.QueryLexer.FIELD),e.ignore(),t.QueryLexer.lexText},t.QueryLexer.lexTerm=function(e){if(e.width()>1&&(e.backup(),e.emit(t.QueryLexer.TERM)),e.ignore(),e.more())return t.QueryLexer.lexText},t.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.EDIT_DISTANCE),t.QueryLexer.lexText},t.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.BOOST),t.QueryLexer.lexText},t.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit(t.QueryLexer.TERM)},t.QueryLexer.termSeparator=t.tokenizer.separator,t.QueryLexer.lexText=function(e){for(;;){var n=e.next();if(n==t.QueryLexer.EOS)return t.QueryLexer.lexEOS;if(n.charCodeAt(0)==92){e.escapeCharacter();continue}if(n==":")return t.QueryLexer.lexField;if(n=="~")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexEditDistance;if(n=="^")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexBoost;if(n=="+"&&e.width()===1||n=="-"&&e.width()===1)return e.emit(t.QueryLexer.PRESENCE),t.QueryLexer.lexText;if(n.match(t.QueryLexer.termSeparator))return t.QueryLexer.lexTerm}},t.QueryParser=function(e,n){this.lexer=new t.QueryLexer(e),this.query=n,this.currentClause={},this.lexemeIdx=0},t.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=t.QueryParser.parseClause;e;)e=e(this);return this.query},t.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},t.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},t.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},t.QueryParser.parseClause=function(e){var n=e.peekLexeme();if(n!=null)switch(n.type){case t.QueryLexer.PRESENCE:return t.QueryParser.parsePresence;case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expected either a field or a term, found "+n.type;throw n.str.length>=1&&(r+=" with value '"+n.str+"'"),new t.QueryParseError(r,n.start,n.end)}},t.QueryParser.parsePresence=function(e){var n=e.consumeLexeme();if(n!=null){switch(n.str){case"-":e.currentClause.presence=t.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=t.Query.presence.REQUIRED;break;default:var r="unrecognised presence operator'"+n.str+"'";throw new t.QueryParseError(r,n.start,n.end)}var i=e.peekLexeme();if(i==null){var r="expecting term or field, found nothing";throw new t.QueryParseError(r,n.start,n.end)}switch(i.type){case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expecting term or field, found '"+i.type+"'";throw new t.QueryParseError(r,i.start,i.end)}}},t.QueryParser.parseField=function(e){var n=e.consumeLexeme();if(n!=null){if(e.query.allFields.indexOf(n.str)==-1){var r=e.query.allFields.map(function(o){return"'"+o+"'"}).join(", "),i="unrecognised field '"+n.str+"', possible fields: "+r;throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.fields=[n.str];var s=e.peekLexeme();if(s==null){var i="expecting term, found nothing";throw new t.QueryParseError(i,n.start,n.end)}switch(s.type){case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var i="expecting term, found '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseTerm=function(e){var n=e.consumeLexeme();if(n!=null){e.currentClause.term=n.str.toLowerCase(),n.str.indexOf("*")!=-1&&(e.currentClause.usePipeline=!1);var r=e.peekLexeme();if(r==null){e.nextClause();return}switch(r.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+r.type+"'";throw new t.QueryParseError(i,r.start,r.end)}}},t.QueryParser.parseEditDistance=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="edit distance must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.editDistance=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseBoost=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="boost must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.boost=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},function(e,n){typeof define=="function"&&define.amd?define(n):typeof se=="object"?oe.exports=n():e.lunr=n()}(this,function(){return t})})()});var re=[];function G(t,e){re.push({selector:e,constructor:t})}var U=class{constructor(){this.alwaysVisibleMember=null;this.createComponents(document.body),this.ensureFocusedElementVisible(),this.listenForCodeCopies(),window.addEventListener("hashchange",()=>this.ensureFocusedElementVisible()),document.body.style.display||(this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}createComponents(e){re.forEach(n=>{e.querySelectorAll(n.selector).forEach(r=>{r.dataset.hasInstance||(new n.constructor({el:r,app:this}),r.dataset.hasInstance=String(!0))})})}filterChanged(){this.ensureFocusedElementVisible()}showPage(){document.body.style.display&&(console.log("Show page"),document.body.style.removeProperty("display"),this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}scrollToHash(){if(location.hash){console.log("Scorlling");let e=document.getElementById(location.hash.substring(1));if(!e)return;e.scrollIntoView({behavior:"instant",block:"start"})}}ensureActivePageVisible(){let e=document.querySelector(".tsd-navigation .current"),n=e?.parentElement;for(;n&&!n.classList.contains(".tsd-navigation");)n instanceof HTMLDetailsElement&&(n.open=!0),n=n.parentElement;if(e&&!e.checkVisibility()){let r=e.getBoundingClientRect().top-document.documentElement.clientHeight/4;document.querySelector(".site-menu").scrollTop=r}}updateIndexVisibility(){let e=document.querySelector(".tsd-index-content"),n=e?.open;e&&(e.open=!0),document.querySelectorAll(".tsd-index-section").forEach(r=>{r.style.display="block";let i=Array.from(r.querySelectorAll(".tsd-index-link")).every(s=>s.offsetParent==null);r.style.display=i?"none":"block"}),e&&(e.open=n)}ensureFocusedElementVisible(){if(this.alwaysVisibleMember&&(this.alwaysVisibleMember.classList.remove("always-visible"),this.alwaysVisibleMember.firstElementChild.remove(),this.alwaysVisibleMember=null),!location.hash)return;let e=document.getElementById(location.hash.substring(1));if(!e)return;let n=e.parentElement;for(;n&&n.tagName!=="SECTION";)n=n.parentElement;if(n&&n.offsetParent==null){this.alwaysVisibleMember=n,n.classList.add("always-visible");let r=document.createElement("p");r.classList.add("warning"),r.textContent="This member is normally hidden due to your filter settings.",n.prepend(r)}}listenForCodeCopies(){document.querySelectorAll("pre > button").forEach(e=>{let n;e.addEventListener("click",()=>{e.previousElementSibling instanceof HTMLElement&&navigator.clipboard.writeText(e.previousElementSibling.innerText.trim()),e.textContent="Copied!",e.classList.add("visible"),clearTimeout(n),n=setTimeout(()=>{e.classList.remove("visible"),n=setTimeout(()=>{e.textContent="Copy"},100)},1e3)})})}};var ie=(t,e=100)=>{let n;return()=>{clearTimeout(n),n=setTimeout(()=>t(),e)}};var de=De(ae());async function le(t,e){if(!window.searchData)return;let n=await fetch(window.searchData),r=new Blob([await n.arrayBuffer()]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();t.data=i,t.index=de.Index.load(i.index),e.classList.remove("loading"),e.classList.add("ready")}function he(){let t=document.getElementById("tsd-search");if(!t)return;let e={base:t.dataset.base+"/"},n=document.getElementById("tsd-search-script");t.classList.add("loading"),n&&(n.addEventListener("error",()=>{t.classList.remove("loading"),t.classList.add("failure")}),n.addEventListener("load",()=>{le(e,t)}),le(e,t));let r=document.querySelector("#tsd-search input"),i=document.querySelector("#tsd-search .results");if(!r||!i)throw new Error("The input field or the result list wrapper was not found");let s=!1;i.addEventListener("mousedown",()=>s=!0),i.addEventListener("mouseup",()=>{s=!1,t.classList.remove("has-focus")}),r.addEventListener("focus",()=>t.classList.add("has-focus")),r.addEventListener("blur",()=>{s||(s=!1,t.classList.remove("has-focus"))}),Ae(t,i,r,e)}function Ae(t,e,n,r){n.addEventListener("input",ie(()=>{Ve(t,e,n,r)},200));let i=!1;n.addEventListener("keydown",s=>{i=!0,s.key=="Enter"?Ne(e,n):s.key=="Escape"?n.blur():s.key=="ArrowUp"?ue(e,-1):s.key==="ArrowDown"?ue(e,1):i=!1}),n.addEventListener("keypress",s=>{i&&s.preventDefault()}),document.body.addEventListener("keydown",s=>{s.altKey||s.ctrlKey||s.metaKey||!n.matches(":focus")&&s.key==="/"&&(n.focus(),s.preventDefault())})}function Ve(t,e,n,r){if(!r.index||!r.data)return;e.textContent="";let i=n.value.trim(),s;if(i){let o=i.split(" ").map(a=>a.length?`*${a}*`:"").join(" ");s=r.index.search(o)}else s=[];for(let o=0;o<s.length;o++){let a=s[o],l=r.data.rows[Number(a.ref)],u=1;l.name.toLowerCase().startsWith(i.toLowerCase())&&(u*=1+1/(1+Math.abs(l.name.length-i.length))),a.score*=u}if(s.length===0){let o=document.createElement("li");o.classList.add("no-results");let a=document.createElement("span");a.textContent="No results found",o.appendChild(a),e.appendChild(o)}s.sort((o,a)=>a.score-o.score);for(let o=0,a=Math.min(10,s.length);o<a;o++){let l=r.data.rows[Number(s[o].ref)],u=`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" class="tsd-kind-icon"><use href="#icon-${l.kind}"></use></svg>`,d=ce(l.name,i);globalThis.DEBUG_SEARCH_WEIGHTS&&(d+=` (score: ${s[o].score.toFixed(2)})`),l.parent&&(d=`<span class="parent"> | ||
${ce(l.parent,i)}.</span>${d}`);let y=document.createElement("li");y.classList.value=l.classes??"";let p=document.createElement("a");p.href=r.base+l.url,p.innerHTML=u+d,y.append(p),e.appendChild(y)}}function ue(t,e){let n=t.querySelector(".current");if(!n)n=t.querySelector(e==1?"li:first-child":"li:last-child"),n&&n.classList.add("current");else{let r=n;if(e===1)do r=r.nextElementSibling??void 0;while(r instanceof HTMLElement&&r.offsetParent==null);else do r=r.previousElementSibling??void 0;while(r instanceof HTMLElement&&r.offsetParent==null);r&&(n.classList.remove("current"),r.classList.add("current"))}}function Ne(t,e){let n=t.querySelector(".current");if(n||(n=t.querySelector("li:first-child")),n){let r=n.querySelector("a");r&&(window.location.href=r.href),e.blur()}}function ce(t,e){if(e==="")return t;let n=t.toLocaleLowerCase(),r=e.toLocaleLowerCase(),i=[],s=0,o=n.indexOf(r);for(;o!=-1;)i.push(K(t.substring(s,o)),`<b>${K(t.substring(o,o+r.length))}</b>`),s=o+r.length,o=n.indexOf(r,s);return i.push(K(t.substring(s))),i.join("")}var He={"&":"&","<":"<",">":">","'":"'",'"':"""};function K(t){return t.replace(/[&<>"'"]/g,e=>He[e])}var I=class{constructor(e){this.el=e.el,this.app=e.app}};var F="mousedown",fe="mousemove",H="mouseup",J={x:0,y:0},pe=!1,ee=!1,Be=!1,D=!1,me=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);document.documentElement.classList.add(me?"is-mobile":"not-mobile");me&&"ontouchstart"in document.documentElement&&(Be=!0,F="touchstart",fe="touchmove",H="touchend");document.addEventListener(F,t=>{ee=!0,D=!1;let e=F=="touchstart"?t.targetTouches[0]:t;J.y=e.pageY||0,J.x=e.pageX||0});document.addEventListener(fe,t=>{if(ee&&!D){let e=F=="touchstart"?t.targetTouches[0]:t,n=J.x-(e.pageX||0),r=J.y-(e.pageY||0);D=Math.sqrt(n*n+r*r)>10}});document.addEventListener(H,()=>{ee=!1});document.addEventListener("click",t=>{pe&&(t.preventDefault(),t.stopImmediatePropagation(),pe=!1)});var X=class extends I{constructor(e){super(e),this.className=this.el.dataset.toggle||"",this.el.addEventListener(H,n=>this.onPointerUp(n)),this.el.addEventListener("click",n=>n.preventDefault()),document.addEventListener(F,n=>this.onDocumentPointerDown(n)),document.addEventListener(H,n=>this.onDocumentPointerUp(n))}setActive(e){if(this.active==e)return;this.active=e,document.documentElement.classList.toggle("has-"+this.className,e),this.el.classList.toggle("active",e);let n=(this.active?"to-has-":"from-has-")+this.className;document.documentElement.classList.add(n),setTimeout(()=>document.documentElement.classList.remove(n),500)}onPointerUp(e){D||(this.setActive(!0),e.preventDefault())}onDocumentPointerDown(e){if(this.active){if(e.target.closest(".col-sidebar, .tsd-filter-group"))return;this.setActive(!1)}}onDocumentPointerUp(e){if(!D&&this.active&&e.target.closest(".col-sidebar")){let n=e.target.closest("a");if(n){let r=window.location.href;r.indexOf("#")!=-1&&(r=r.substring(0,r.indexOf("#"))),n.href.substring(0,r.length)==r&&setTimeout(()=>this.setActive(!1),250)}}}};var te;try{te=localStorage}catch{te={getItem(){return null},setItem(){}}}var Q=te;var ye=document.head.appendChild(document.createElement("style"));ye.dataset.for="filters";var Y=class extends I{constructor(e){super(e),this.key=`filter-${this.el.name}`,this.value=this.el.checked,this.el.addEventListener("change",()=>{this.setLocalStorage(this.el.checked)}),this.setLocalStorage(this.fromLocalStorage()),ye.innerHTML+=`html:not(.${this.key}) .tsd-is-${this.el.name} { display: none; } | ||
`,this.app.updateIndexVisibility()}fromLocalStorage(){let e=Q.getItem(this.key);return e?e==="true":this.el.checked}setLocalStorage(e){Q.setItem(this.key,e.toString()),this.value=e,this.handleValueChange()}handleValueChange(){this.el.checked=this.value,document.documentElement.classList.toggle(this.key,this.value),this.app.filterChanged(),this.app.updateIndexVisibility()}};var Z=class extends I{constructor(e){super(e),this.summary=this.el.querySelector(".tsd-accordion-summary"),this.icon=this.summary.querySelector("svg"),this.key=`tsd-accordion-${this.summary.dataset.key??this.summary.textContent.trim().replace(/\s+/g,"-").toLowerCase()}`;let n=Q.getItem(this.key);this.el.open=n?n==="true":this.el.open,this.el.addEventListener("toggle",()=>this.update());let r=this.summary.querySelector("a");r&&r.addEventListener("click",()=>{location.assign(r.href)}),this.update()}update(){this.icon.style.transform=`rotate(${this.el.open?0:-90}deg)`,Q.setItem(this.key,this.el.open.toString())}};function ge(t){let e=Q.getItem("tsd-theme")||"os";t.value=e,ve(e),t.addEventListener("change",()=>{Q.setItem("tsd-theme",t.value),ve(t.value)})}function ve(t){document.documentElement.dataset.theme=t}var Le;function be(){let t=document.getElementById("tsd-nav-script");t&&(t.addEventListener("load",xe),xe())}async function xe(){let t=document.getElementById("tsd-nav-container");if(!t||!window.navigationData)return;let n=await(await fetch(window.navigationData)).arrayBuffer(),r=new Blob([n]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();Le=t.dataset.base+"/",t.innerHTML="";for(let s of i)we(s,t,[]);window.app.createComponents(t),window.app.showPage(),window.app.ensureActivePageVisible()}function we(t,e,n){let r=e.appendChild(document.createElement("li"));if(t.children){let i=[...n,t.text],s=r.appendChild(document.createElement("details"));s.className=t.class?`${t.class} tsd-index-accordion`:"tsd-index-accordion",s.dataset.key=i.join("$");let o=s.appendChild(document.createElement("summary"));o.className="tsd-accordion-summary",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="#icon-chevronDown"></use></svg>',Ee(t,o);let a=s.appendChild(document.createElement("div"));a.className="tsd-accordion-details";let l=a.appendChild(document.createElement("ul"));l.className="tsd-nested-navigation";for(let u of t.children)we(u,l,i)}else Ee(t,r,t.class)}function Ee(t,e,n){if(t.path){let r=e.appendChild(document.createElement("a"));r.href=Le+t.path,n&&(r.className=n),location.pathname===r.pathname&&r.classList.add("current"),t.kind&&(r.innerHTML=`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" class="tsd-kind-icon"><use href="#icon-${t.kind}"></use></svg>`),r.appendChild(document.createElement("span")).textContent=t.text}else e.appendChild(document.createElement("span")).textContent=t.text}G(X,"a[data-toggle]");G(Z,".tsd-index-accordion");G(Y,".tsd-filter-item input[type=checkbox]");var Se=document.getElementById("tsd-theme");Se&&ge(Se);var je=new U;Object.defineProperty(window,"app",{value:je});he();be();})(); | ||
"use strict";(()=>{var Pe=Object.create;var re=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,Me=Object.prototype.hasOwnProperty;var Fe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var De=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _e(e))!Me.call(t,i)&&i!==n&&re(t,i,{get:()=>e[i],enumerable:!(r=Oe(e,i))||r.enumerable});return t};var Ae=(t,e,n)=>(n=t!=null?Pe(Re(t)):{},De(e||!t||!t.__esModule?re(n,"default",{value:t,enumerable:!0}):n,t));var le=Fe((oe,ae)=>{(function(){var t=function(e){var n=new t.Builder;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),n.searchPipeline.add(t.stemmer),e.call(n,n),n.build()};t.version="2.3.9";t.utils={},t.utils.warn=function(e){return function(n){e.console&&console.warn&&console.warn(n)}}(this),t.utils.asString=function(e){return e==null?"":e.toString()},t.utils.clone=function(e){if(e==null)return e;for(var n=Object.create(null),r=Object.keys(e),i=0;i<r.length;i++){var s=r[i],o=e[s];if(Array.isArray(o)){n[s]=o.slice();continue}if(typeof o=="string"||typeof o=="number"||typeof o=="boolean"){n[s]=o;continue}throw new TypeError("clone is not deep and does not support nested objects")}return n},t.FieldRef=function(e,n,r){this.docRef=e,this.fieldName=n,this._stringValue=r},t.FieldRef.joiner="/",t.FieldRef.fromString=function(e){var n=e.indexOf(t.FieldRef.joiner);if(n===-1)throw"malformed field ref string";var r=e.slice(0,n),i=e.slice(n+1);return new t.FieldRef(i,r,e)},t.FieldRef.prototype.toString=function(){return this._stringValue==null&&(this._stringValue=this.fieldName+t.FieldRef.joiner+this.docRef),this._stringValue};t.Set=function(e){if(this.elements=Object.create(null),e){this.length=e.length;for(var n=0;n<this.length;n++)this.elements[e[n]]=!0}else this.length=0},t.Set.complete={intersect:function(e){return e},union:function(){return this},contains:function(){return!0}},t.Set.empty={intersect:function(){return this},union:function(e){return e},contains:function(){return!1}},t.Set.prototype.contains=function(e){return!!this.elements[e]},t.Set.prototype.intersect=function(e){var n,r,i,s=[];if(e===t.Set.complete)return this;if(e===t.Set.empty)return e;this.length<e.length?(n=this,r=e):(n=e,r=this),i=Object.keys(n.elements);for(var o=0;o<i.length;o++){var a=i[o];a in r.elements&&s.push(a)}return new t.Set(s)},t.Set.prototype.union=function(e){return e===t.Set.complete?t.Set.complete:e===t.Set.empty?this:new t.Set(Object.keys(this.elements).concat(Object.keys(e.elements)))},t.idf=function(e,n){var r=0;for(var i in e)i!="_index"&&(r+=Object.keys(e[i]).length);var s=(n-r+.5)/(r+.5);return Math.log(1+Math.abs(s))},t.Token=function(e,n){this.str=e||"",this.metadata=n||{}},t.Token.prototype.toString=function(){return this.str},t.Token.prototype.update=function(e){return this.str=e(this.str,this.metadata),this},t.Token.prototype.clone=function(e){return e=e||function(n){return n},new t.Token(e(this.str,this.metadata),this.metadata)};t.tokenizer=function(e,n){if(e==null||e==null)return[];if(Array.isArray(e))return e.map(function(m){return new t.Token(t.utils.asString(m).toLowerCase(),t.utils.clone(n))});for(var r=e.toString().toLowerCase(),i=r.length,s=[],o=0,a=0;o<=i;o++){var l=r.charAt(o),u=o-a;if(l.match(t.tokenizer.separator)||o==i){if(u>0){var d=t.utils.clone(n)||{};d.position=[a,u],d.index=s.length,s.push(new t.Token(r.slice(a,o),d))}a=o+1}}return s},t.tokenizer.separator=/[\s\-]+/;t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions=Object.create(null),t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn(`Function is not registered with pipeline. This may cause problems when serialising the index. | ||
`,e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(r){var i=t.Pipeline.registeredFunctions[r];if(i)n.add(i);else throw new Error("Cannot load unregistered function: "+r)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(n){t.Pipeline.warnIfFunctionNotRegistered(n),this._stack.push(n)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");r=r+1,this._stack.splice(r,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");this._stack.splice(r,0,n)},t.Pipeline.prototype.remove=function(e){var n=this._stack.indexOf(e);n!=-1&&this._stack.splice(n,1)},t.Pipeline.prototype.run=function(e){for(var n=this._stack.length,r=0;r<n;r++){for(var i=this._stack[r],s=[],o=0;o<e.length;o++){var a=i(e[o],o,e);if(!(a==null||a===""))if(Array.isArray(a))for(var l=0;l<a.length;l++)s.push(a[l]);else s.push(a)}e=s}return e},t.Pipeline.prototype.runString=function(e,n){var r=new t.Token(e,n);return this.run([r]).map(function(i){return i.toString()})},t.Pipeline.prototype.reset=function(){this._stack=[]},t.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})};t.Vector=function(e){this._magnitude=0,this.elements=e||[]},t.Vector.prototype.positionForIndex=function(e){if(this.elements.length==0)return 0;for(var n=0,r=this.elements.length/2,i=r-n,s=Math.floor(i/2),o=this.elements[s*2];i>1&&(o<e&&(n=s),o>e&&(r=s),o!=e);)i=r-n,s=n+Math.floor(i/2),o=this.elements[s*2];if(o==e||o>e)return s*2;if(o<e)return(s+1)*2},t.Vector.prototype.insert=function(e,n){this.upsert(e,n,function(){throw"duplicate index"})},t.Vector.prototype.upsert=function(e,n,r){this._magnitude=0;var i=this.positionForIndex(e);this.elements[i]==e?this.elements[i+1]=r(this.elements[i+1],n):this.elements.splice(i,0,e,n)},t.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;for(var e=0,n=this.elements.length,r=1;r<n;r+=2){var i=this.elements[r];e+=i*i}return this._magnitude=Math.sqrt(e)},t.Vector.prototype.dot=function(e){for(var n=0,r=this.elements,i=e.elements,s=r.length,o=i.length,a=0,l=0,u=0,d=0;u<s&&d<o;)a=r[u],l=i[d],a<l?u+=2:a>l?d+=2:a==l&&(n+=r[u+1]*i[d+1],u+=2,d+=2);return n},t.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},t.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),n=1,r=0;n<this.elements.length;n+=2,r++)e[r]=this.elements[n];return e},t.Vector.prototype.toJSON=function(){return this.elements};t.stemmer=function(){var e={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},n={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},r="[^aeiou]",i="[aeiouy]",s=r+"[^aeiouy]*",o=i+"[aeiou]*",a="^("+s+")?"+o+s,l="^("+s+")?"+o+s+"("+o+")?$",u="^("+s+")?"+o+s+o+s,d="^("+s+")?"+i,m=new RegExp(a),p=new RegExp(u),b=new RegExp(l),g=new RegExp(d),L=/^(.+?)(ss|i)es$/,f=/^(.+?)([^s])s$/,y=/^(.+?)eed$/,S=/^(.+?)(ed|ing)$/,w=/.$/,k=/(at|bl|iz)$/,_=new RegExp("([^aeiouylsz])\\1$"),B=new RegExp("^"+s+i+"[^aeiouwxy]$"),A=/^(.+?[^aeiou])y$/,j=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,q=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,V=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,$=/^(.+?)(s|t)(ion)$/,C=/^(.+?)e$/,z=/ll$/,W=new RegExp("^"+s+i+"[^aeiouwxy]$"),N=function(c){var v,P,T,h,x,O,M;if(c.length<3)return c;if(T=c.substr(0,1),T=="y"&&(c=T.toUpperCase()+c.substr(1)),h=L,x=f,h.test(c)?c=c.replace(h,"$1$2"):x.test(c)&&(c=c.replace(x,"$1$2")),h=y,x=S,h.test(c)){var E=h.exec(c);h=m,h.test(E[1])&&(h=w,c=c.replace(h,""))}else if(x.test(c)){var E=x.exec(c);v=E[1],x=g,x.test(v)&&(c=v,x=k,O=_,M=B,x.test(c)?c=c+"e":O.test(c)?(h=w,c=c.replace(h,"")):M.test(c)&&(c=c+"e"))}if(h=A,h.test(c)){var E=h.exec(c);v=E[1],c=v+"i"}if(h=j,h.test(c)){var E=h.exec(c);v=E[1],P=E[2],h=m,h.test(v)&&(c=v+e[P])}if(h=q,h.test(c)){var E=h.exec(c);v=E[1],P=E[2],h=m,h.test(v)&&(c=v+n[P])}if(h=V,x=$,h.test(c)){var E=h.exec(c);v=E[1],h=p,h.test(v)&&(c=v)}else if(x.test(c)){var E=x.exec(c);v=E[1]+E[2],x=p,x.test(v)&&(c=v)}if(h=C,h.test(c)){var E=h.exec(c);v=E[1],h=p,x=b,O=W,(h.test(v)||x.test(v)&&!O.test(v))&&(c=v)}return h=z,x=p,h.test(c)&&x.test(c)&&(h=w,c=c.replace(h,"")),T=="y"&&(c=T.toLowerCase()+c.substr(1)),c};return function(R){return R.update(N)}}(),t.Pipeline.registerFunction(t.stemmer,"stemmer");t.generateStopWordFilter=function(e){var n=e.reduce(function(r,i){return r[i]=i,r},{});return function(r){if(r&&n[r.toString()]!==r.toString())return r}},t.stopWordFilter=t.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),t.Pipeline.registerFunction(t.stopWordFilter,"stopWordFilter");t.trimmer=function(e){return e.update(function(n){return n.replace(/^\W+/,"").replace(/\W+$/,"")})},t.Pipeline.registerFunction(t.trimmer,"trimmer");t.TokenSet=function(){this.final=!1,this.edges={},this.id=t.TokenSet._nextId,t.TokenSet._nextId+=1},t.TokenSet._nextId=1,t.TokenSet.fromArray=function(e){for(var n=new t.TokenSet.Builder,r=0,i=e.length;r<i;r++)n.insert(e[r]);return n.finish(),n.root},t.TokenSet.fromClause=function(e){return"editDistance"in e?t.TokenSet.fromFuzzyString(e.term,e.editDistance):t.TokenSet.fromString(e.term)},t.TokenSet.fromFuzzyString=function(e,n){for(var r=new t.TokenSet,i=[{node:r,editsRemaining:n,str:e}];i.length;){var s=i.pop();if(s.str.length>0){var o=s.str.charAt(0),a;o in s.node.edges?a=s.node.edges[o]:(a=new t.TokenSet,s.node.edges[o]=a),s.str.length==1&&(a.final=!0),i.push({node:a,editsRemaining:s.editsRemaining,str:s.str.slice(1)})}if(s.editsRemaining!=0){if("*"in s.node.edges)var l=s.node.edges["*"];else{var l=new t.TokenSet;s.node.edges["*"]=l}if(s.str.length==0&&(l.final=!0),i.push({node:l,editsRemaining:s.editsRemaining-1,str:s.str}),s.str.length>1&&i.push({node:s.node,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)}),s.str.length==1&&(s.node.final=!0),s.str.length>=1){if("*"in s.node.edges)var u=s.node.edges["*"];else{var u=new t.TokenSet;s.node.edges["*"]=u}s.str.length==1&&(u.final=!0),i.push({node:u,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)})}if(s.str.length>1){var d=s.str.charAt(0),m=s.str.charAt(1),p;m in s.node.edges?p=s.node.edges[m]:(p=new t.TokenSet,s.node.edges[m]=p),s.str.length==1&&(p.final=!0),i.push({node:p,editsRemaining:s.editsRemaining-1,str:d+s.str.slice(2)})}}}return r},t.TokenSet.fromString=function(e){for(var n=new t.TokenSet,r=n,i=0,s=e.length;i<s;i++){var o=e[i],a=i==s-1;if(o=="*")n.edges[o]=n,n.final=a;else{var l=new t.TokenSet;l.final=a,n.edges[o]=l,n=l}}return r},t.TokenSet.prototype.toArray=function(){for(var e=[],n=[{prefix:"",node:this}];n.length;){var r=n.pop(),i=Object.keys(r.node.edges),s=i.length;r.node.final&&(r.prefix.charAt(0),e.push(r.prefix));for(var o=0;o<s;o++){var a=i[o];n.push({prefix:r.prefix.concat(a),node:r.node.edges[a]})}}return e},t.TokenSet.prototype.toString=function(){if(this._str)return this._str;for(var e=this.final?"1":"0",n=Object.keys(this.edges).sort(),r=n.length,i=0;i<r;i++){var s=n[i],o=this.edges[s];e=e+s+o.id}return e},t.TokenSet.prototype.intersect=function(e){for(var n=new t.TokenSet,r=void 0,i=[{qNode:e,output:n,node:this}];i.length;){r=i.pop();for(var s=Object.keys(r.qNode.edges),o=s.length,a=Object.keys(r.node.edges),l=a.length,u=0;u<o;u++)for(var d=s[u],m=0;m<l;m++){var p=a[m];if(p==d||d=="*"){var b=r.node.edges[p],g=r.qNode.edges[d],L=b.final&&g.final,f=void 0;p in r.output.edges?(f=r.output.edges[p],f.final=f.final||L):(f=new t.TokenSet,f.final=L,r.output.edges[p]=f),i.push({qNode:g,output:f,node:b})}}}return n},t.TokenSet.Builder=function(){this.previousWord="",this.root=new t.TokenSet,this.uncheckedNodes=[],this.minimizedNodes={}},t.TokenSet.Builder.prototype.insert=function(e){var n,r=0;if(e<this.previousWord)throw new Error("Out of order word insertion");for(var i=0;i<e.length&&i<this.previousWord.length&&e[i]==this.previousWord[i];i++)r++;this.minimize(r),this.uncheckedNodes.length==0?n=this.root:n=this.uncheckedNodes[this.uncheckedNodes.length-1].child;for(var i=r;i<e.length;i++){var s=new t.TokenSet,o=e[i];n.edges[o]=s,this.uncheckedNodes.push({parent:n,char:o,child:s}),n=s}n.final=!0,this.previousWord=e},t.TokenSet.Builder.prototype.finish=function(){this.minimize(0)},t.TokenSet.Builder.prototype.minimize=function(e){for(var n=this.uncheckedNodes.length-1;n>=e;n--){var r=this.uncheckedNodes[n],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}};t.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},t.Index.prototype.search=function(e){return this.query(function(n){var r=new t.QueryParser(e,n);r.parse()})},t.Index.prototype.query=function(e){for(var n=new t.Query(this.fields),r=Object.create(null),i=Object.create(null),s=Object.create(null),o=Object.create(null),a=Object.create(null),l=0;l<this.fields.length;l++)i[this.fields[l]]=new t.Vector;e.call(n,n);for(var l=0;l<n.clauses.length;l++){var u=n.clauses[l],d=null,m=t.Set.empty;u.usePipeline?d=this.pipeline.runString(u.term,{fields:u.fields}):d=[u.term];for(var p=0;p<d.length;p++){var b=d[p];u.term=b;var g=t.TokenSet.fromClause(u),L=this.tokenSet.intersect(g).toArray();if(L.length===0&&u.presence===t.Query.presence.REQUIRED){for(var f=0;f<u.fields.length;f++){var y=u.fields[f];o[y]=t.Set.empty}break}for(var S=0;S<L.length;S++)for(var w=L[S],k=this.invertedIndex[w],_=k._index,f=0;f<u.fields.length;f++){var y=u.fields[f],B=k[y],A=Object.keys(B),j=w+"/"+y,q=new t.Set(A);if(u.presence==t.Query.presence.REQUIRED&&(m=m.union(q),o[y]===void 0&&(o[y]=t.Set.complete)),u.presence==t.Query.presence.PROHIBITED){a[y]===void 0&&(a[y]=t.Set.empty),a[y]=a[y].union(q);continue}if(i[y].upsert(_,u.boost,function(Ie,Ce){return Ie+Ce}),!s[j]){for(var V=0;V<A.length;V++){var $=A[V],C=new t.FieldRef($,y),z=B[$],W;(W=r[C])===void 0?r[C]=new t.MatchData(w,y,z):W.add(w,y,z)}s[j]=!0}}}if(u.presence===t.Query.presence.REQUIRED)for(var f=0;f<u.fields.length;f++){var y=u.fields[f];o[y]=o[y].intersect(m)}}for(var N=t.Set.complete,R=t.Set.empty,l=0;l<this.fields.length;l++){var y=this.fields[l];o[y]&&(N=N.intersect(o[y])),a[y]&&(R=R.union(a[y]))}var c=Object.keys(r),v=[],P=Object.create(null);if(n.isNegated()){c=Object.keys(this.fieldVectors);for(var l=0;l<c.length;l++){var C=c[l],T=t.FieldRef.fromString(C);r[C]=new t.MatchData}}for(var l=0;l<c.length;l++){var T=t.FieldRef.fromString(c[l]),h=T.docRef;if(N.contains(h)&&!R.contains(h)){var x=this.fieldVectors[T],O=i[T.fieldName].similarity(x),M;if((M=P[h])!==void 0)M.score+=O,M.matchData.combine(r[T]);else{var E={ref:h,score:O,matchData:r[T]};P[h]=E,v.push(E)}}}return v.sort(function(ke,Qe){return Qe.score-ke.score})},t.Index.prototype.toJSON=function(){var e=Object.keys(this.invertedIndex).sort().map(function(r){return[r,this.invertedIndex[r]]},this),n=Object.keys(this.fieldVectors).map(function(r){return[r,this.fieldVectors[r].toJSON()]},this);return{version:t.version,fields:this.fields,fieldVectors:n,invertedIndex:e,pipeline:this.pipeline.toJSON()}},t.Index.load=function(e){var n={},r={},i=e.fieldVectors,s=Object.create(null),o=e.invertedIndex,a=new t.TokenSet.Builder,l=t.Pipeline.load(e.pipeline);e.version!=t.version&&t.utils.warn("Version mismatch when loading serialised index. Current version of lunr '"+t.version+"' does not match serialized index '"+e.version+"'");for(var u=0;u<i.length;u++){var d=i[u],m=d[0],p=d[1];r[m]=new t.Vector(p)}for(var u=0;u<o.length;u++){var d=o[u],b=d[0],g=d[1];a.insert(b),s[b]=g}return a.finish(),n.fields=e.fields,n.fieldVectors=r,n.invertedIndex=s,n.tokenSet=a.root,n.pipeline=l,new t.Index(n)};t.Builder=function(){this._ref="id",this._fields=Object.create(null),this._documents=Object.create(null),this.invertedIndex=Object.create(null),this.fieldTermFrequencies={},this.fieldLengths={},this.tokenizer=t.tokenizer,this.pipeline=new t.Pipeline,this.searchPipeline=new t.Pipeline,this.documentCount=0,this._b=.75,this._k1=1.2,this.termIndex=0,this.metadataWhitelist=[]},t.Builder.prototype.ref=function(e){this._ref=e},t.Builder.prototype.field=function(e,n){if(/\//.test(e))throw new RangeError("Field '"+e+"' contains illegal character '/'");this._fields[e]=n||{}},t.Builder.prototype.b=function(e){e<0?this._b=0:e>1?this._b=1:this._b=e},t.Builder.prototype.k1=function(e){this._k1=e},t.Builder.prototype.add=function(e,n){var r=e[this._ref],i=Object.keys(this._fields);this._documents[r]=n||{},this.documentCount+=1;for(var s=0;s<i.length;s++){var o=i[s],a=this._fields[o].extractor,l=a?a(e):e[o],u=this.tokenizer(l,{fields:[o]}),d=this.pipeline.run(u),m=new t.FieldRef(r,o),p=Object.create(null);this.fieldTermFrequencies[m]=p,this.fieldLengths[m]=0,this.fieldLengths[m]+=d.length;for(var b=0;b<d.length;b++){var g=d[b];if(p[g]==null&&(p[g]=0),p[g]+=1,this.invertedIndex[g]==null){var L=Object.create(null);L._index=this.termIndex,this.termIndex+=1;for(var f=0;f<i.length;f++)L[i[f]]=Object.create(null);this.invertedIndex[g]=L}this.invertedIndex[g][o][r]==null&&(this.invertedIndex[g][o][r]=Object.create(null));for(var y=0;y<this.metadataWhitelist.length;y++){var S=this.metadataWhitelist[y],w=g.metadata[S];this.invertedIndex[g][o][r][S]==null&&(this.invertedIndex[g][o][r][S]=[]),this.invertedIndex[g][o][r][S].push(w)}}}},t.Builder.prototype.calculateAverageFieldLengths=function(){for(var e=Object.keys(this.fieldLengths),n=e.length,r={},i={},s=0;s<n;s++){var o=t.FieldRef.fromString(e[s]),a=o.fieldName;i[a]||(i[a]=0),i[a]+=1,r[a]||(r[a]=0),r[a]+=this.fieldLengths[o]}for(var l=Object.keys(this._fields),s=0;s<l.length;s++){var u=l[s];r[u]=r[u]/i[u]}this.averageFieldLength=r},t.Builder.prototype.createFieldVectors=function(){for(var e={},n=Object.keys(this.fieldTermFrequencies),r=n.length,i=Object.create(null),s=0;s<r;s++){for(var o=t.FieldRef.fromString(n[s]),a=o.fieldName,l=this.fieldLengths[o],u=new t.Vector,d=this.fieldTermFrequencies[o],m=Object.keys(d),p=m.length,b=this._fields[a].boost||1,g=this._documents[o.docRef].boost||1,L=0;L<p;L++){var f=m[L],y=d[f],S=this.invertedIndex[f]._index,w,k,_;i[f]===void 0?(w=t.idf(this.invertedIndex[f],this.documentCount),i[f]=w):w=i[f],k=w*((this._k1+1)*y)/(this._k1*(1-this._b+this._b*(l/this.averageFieldLength[a]))+y),k*=b,k*=g,_=Math.round(k*1e3)/1e3,u.insert(S,_)}e[o]=u}this.fieldVectors=e},t.Builder.prototype.createTokenSet=function(){this.tokenSet=t.TokenSet.fromArray(Object.keys(this.invertedIndex).sort())},t.Builder.prototype.build=function(){return this.calculateAverageFieldLengths(),this.createFieldVectors(),this.createTokenSet(),new t.Index({invertedIndex:this.invertedIndex,fieldVectors:this.fieldVectors,tokenSet:this.tokenSet,fields:Object.keys(this._fields),pipeline:this.searchPipeline})},t.Builder.prototype.use=function(e){var n=Array.prototype.slice.call(arguments,1);n.unshift(this),e.apply(this,n)},t.MatchData=function(e,n,r){for(var i=Object.create(null),s=Object.keys(r||{}),o=0;o<s.length;o++){var a=s[o];i[a]=r[a].slice()}this.metadata=Object.create(null),e!==void 0&&(this.metadata[e]=Object.create(null),this.metadata[e][n]=i)},t.MatchData.prototype.combine=function(e){for(var n=Object.keys(e.metadata),r=0;r<n.length;r++){var i=n[r],s=Object.keys(e.metadata[i]);this.metadata[i]==null&&(this.metadata[i]=Object.create(null));for(var o=0;o<s.length;o++){var a=s[o],l=Object.keys(e.metadata[i][a]);this.metadata[i][a]==null&&(this.metadata[i][a]=Object.create(null));for(var u=0;u<l.length;u++){var d=l[u];this.metadata[i][a][d]==null?this.metadata[i][a][d]=e.metadata[i][a][d]:this.metadata[i][a][d]=this.metadata[i][a][d].concat(e.metadata[i][a][d])}}}},t.MatchData.prototype.add=function(e,n,r){if(!(e in this.metadata)){this.metadata[e]=Object.create(null),this.metadata[e][n]=r;return}if(!(n in this.metadata[e])){this.metadata[e][n]=r;return}for(var i=Object.keys(r),s=0;s<i.length;s++){var o=i[s];o in this.metadata[e][n]?this.metadata[e][n][o]=this.metadata[e][n][o].concat(r[o]):this.metadata[e][n][o]=r[o]}},t.Query=function(e){this.clauses=[],this.allFields=e},t.Query.wildcard=new String("*"),t.Query.wildcard.NONE=0,t.Query.wildcard.LEADING=1,t.Query.wildcard.TRAILING=2,t.Query.presence={OPTIONAL:1,REQUIRED:2,PROHIBITED:3},t.Query.prototype.clause=function(e){return"fields"in e||(e.fields=this.allFields),"boost"in e||(e.boost=1),"usePipeline"in e||(e.usePipeline=!0),"wildcard"in e||(e.wildcard=t.Query.wildcard.NONE),e.wildcard&t.Query.wildcard.LEADING&&e.term.charAt(0)!=t.Query.wildcard&&(e.term="*"+e.term),e.wildcard&t.Query.wildcard.TRAILING&&e.term.slice(-1)!=t.Query.wildcard&&(e.term=""+e.term+"*"),"presence"in e||(e.presence=t.Query.presence.OPTIONAL),this.clauses.push(e),this},t.Query.prototype.isNegated=function(){for(var e=0;e<this.clauses.length;e++)if(this.clauses[e].presence!=t.Query.presence.PROHIBITED)return!1;return!0},t.Query.prototype.term=function(e,n){if(Array.isArray(e))return e.forEach(function(i){this.term(i,t.utils.clone(n))},this),this;var r=n||{};return r.term=e.toString(),this.clause(r),this},t.QueryParseError=function(e,n,r){this.name="QueryParseError",this.message=e,this.start=n,this.end=r},t.QueryParseError.prototype=new Error,t.QueryLexer=function(e){this.lexemes=[],this.str=e,this.length=e.length,this.pos=0,this.start=0,this.escapeCharPositions=[]},t.QueryLexer.prototype.run=function(){for(var e=t.QueryLexer.lexText;e;)e=e(this)},t.QueryLexer.prototype.sliceString=function(){for(var e=[],n=this.start,r=this.pos,i=0;i<this.escapeCharPositions.length;i++)r=this.escapeCharPositions[i],e.push(this.str.slice(n,r)),n=r+1;return e.push(this.str.slice(n,this.pos)),this.escapeCharPositions.length=0,e.join("")},t.QueryLexer.prototype.emit=function(e){this.lexemes.push({type:e,str:this.sliceString(),start:this.start,end:this.pos}),this.start=this.pos},t.QueryLexer.prototype.escapeCharacter=function(){this.escapeCharPositions.push(this.pos-1),this.pos+=1},t.QueryLexer.prototype.next=function(){if(this.pos>=this.length)return t.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},t.QueryLexer.prototype.width=function(){return this.pos-this.start},t.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},t.QueryLexer.prototype.backup=function(){this.pos-=1},t.QueryLexer.prototype.acceptDigitRun=function(){var e,n;do e=this.next(),n=e.charCodeAt(0);while(n>47&&n<58);e!=t.QueryLexer.EOS&&this.backup()},t.QueryLexer.prototype.more=function(){return this.pos<this.length},t.QueryLexer.EOS="EOS",t.QueryLexer.FIELD="FIELD",t.QueryLexer.TERM="TERM",t.QueryLexer.EDIT_DISTANCE="EDIT_DISTANCE",t.QueryLexer.BOOST="BOOST",t.QueryLexer.PRESENCE="PRESENCE",t.QueryLexer.lexField=function(e){return e.backup(),e.emit(t.QueryLexer.FIELD),e.ignore(),t.QueryLexer.lexText},t.QueryLexer.lexTerm=function(e){if(e.width()>1&&(e.backup(),e.emit(t.QueryLexer.TERM)),e.ignore(),e.more())return t.QueryLexer.lexText},t.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.EDIT_DISTANCE),t.QueryLexer.lexText},t.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.BOOST),t.QueryLexer.lexText},t.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit(t.QueryLexer.TERM)},t.QueryLexer.termSeparator=t.tokenizer.separator,t.QueryLexer.lexText=function(e){for(;;){var n=e.next();if(n==t.QueryLexer.EOS)return t.QueryLexer.lexEOS;if(n.charCodeAt(0)==92){e.escapeCharacter();continue}if(n==":")return t.QueryLexer.lexField;if(n=="~")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexEditDistance;if(n=="^")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexBoost;if(n=="+"&&e.width()===1||n=="-"&&e.width()===1)return e.emit(t.QueryLexer.PRESENCE),t.QueryLexer.lexText;if(n.match(t.QueryLexer.termSeparator))return t.QueryLexer.lexTerm}},t.QueryParser=function(e,n){this.lexer=new t.QueryLexer(e),this.query=n,this.currentClause={},this.lexemeIdx=0},t.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=t.QueryParser.parseClause;e;)e=e(this);return this.query},t.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},t.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},t.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},t.QueryParser.parseClause=function(e){var n=e.peekLexeme();if(n!=null)switch(n.type){case t.QueryLexer.PRESENCE:return t.QueryParser.parsePresence;case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expected either a field or a term, found "+n.type;throw n.str.length>=1&&(r+=" with value '"+n.str+"'"),new t.QueryParseError(r,n.start,n.end)}},t.QueryParser.parsePresence=function(e){var n=e.consumeLexeme();if(n!=null){switch(n.str){case"-":e.currentClause.presence=t.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=t.Query.presence.REQUIRED;break;default:var r="unrecognised presence operator'"+n.str+"'";throw new t.QueryParseError(r,n.start,n.end)}var i=e.peekLexeme();if(i==null){var r="expecting term or field, found nothing";throw new t.QueryParseError(r,n.start,n.end)}switch(i.type){case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expecting term or field, found '"+i.type+"'";throw new t.QueryParseError(r,i.start,i.end)}}},t.QueryParser.parseField=function(e){var n=e.consumeLexeme();if(n!=null){if(e.query.allFields.indexOf(n.str)==-1){var r=e.query.allFields.map(function(o){return"'"+o+"'"}).join(", "),i="unrecognised field '"+n.str+"', possible fields: "+r;throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.fields=[n.str];var s=e.peekLexeme();if(s==null){var i="expecting term, found nothing";throw new t.QueryParseError(i,n.start,n.end)}switch(s.type){case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var i="expecting term, found '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseTerm=function(e){var n=e.consumeLexeme();if(n!=null){e.currentClause.term=n.str.toLowerCase(),n.str.indexOf("*")!=-1&&(e.currentClause.usePipeline=!1);var r=e.peekLexeme();if(r==null){e.nextClause();return}switch(r.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+r.type+"'";throw new t.QueryParseError(i,r.start,r.end)}}},t.QueryParser.parseEditDistance=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="edit distance must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.editDistance=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseBoost=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="boost must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.boost=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},function(e,n){typeof define=="function"&&define.amd?define(n):typeof oe=="object"?ae.exports=n():e.lunr=n()}(this,function(){return t})})()});var ie=[];function G(t,e){ie.push({selector:e,constructor:t})}var U=class{constructor(){this.alwaysVisibleMember=null;this.createComponents(document.body),this.ensureFocusedElementVisible(),this.listenForCodeCopies(),window.addEventListener("hashchange",()=>this.ensureFocusedElementVisible()),document.body.style.display||(this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}createComponents(e){ie.forEach(n=>{e.querySelectorAll(n.selector).forEach(r=>{r.dataset.hasInstance||(new n.constructor({el:r,app:this}),r.dataset.hasInstance=String(!0))})})}filterChanged(){this.ensureFocusedElementVisible()}showPage(){document.body.style.display&&(document.body.style.removeProperty("display"),this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}scrollToHash(){if(location.hash){console.log("Scorlling");let e=document.getElementById(location.hash.substring(1));if(!e)return;e.scrollIntoView({behavior:"instant",block:"start"})}}ensureActivePageVisible(){let e=document.querySelector(".tsd-navigation .current"),n=e?.parentElement;for(;n&&!n.classList.contains(".tsd-navigation");)n instanceof HTMLDetailsElement&&(n.open=!0),n=n.parentElement;if(e&&!e.checkVisibility()){let r=e.getBoundingClientRect().top-document.documentElement.clientHeight/4;document.querySelector(".site-menu").scrollTop=r}}updateIndexVisibility(){let e=document.querySelector(".tsd-index-content"),n=e?.open;e&&(e.open=!0),document.querySelectorAll(".tsd-index-section").forEach(r=>{r.style.display="block";let i=Array.from(r.querySelectorAll(".tsd-index-link")).every(s=>s.offsetParent==null);r.style.display=i?"none":"block"}),e&&(e.open=n)}ensureFocusedElementVisible(){if(this.alwaysVisibleMember&&(this.alwaysVisibleMember.classList.remove("always-visible"),this.alwaysVisibleMember.firstElementChild.remove(),this.alwaysVisibleMember=null),!location.hash)return;let e=document.getElementById(location.hash.substring(1));if(!e)return;let n=e.parentElement;for(;n&&n.tagName!=="SECTION";)n=n.parentElement;if(n&&n.offsetParent==null){this.alwaysVisibleMember=n,n.classList.add("always-visible");let r=document.createElement("p");r.classList.add("warning"),r.textContent="This member is normally hidden due to your filter settings.",n.prepend(r)}}listenForCodeCopies(){document.querySelectorAll("pre > button").forEach(e=>{let n;e.addEventListener("click",()=>{e.previousElementSibling instanceof HTMLElement&&navigator.clipboard.writeText(e.previousElementSibling.innerText.trim()),e.textContent="Copied!",e.classList.add("visible"),clearTimeout(n),n=setTimeout(()=>{e.classList.remove("visible"),n=setTimeout(()=>{e.textContent="Copy"},100)},1e3)})})}};var se=(t,e=100)=>{let n;return()=>{clearTimeout(n),n=setTimeout(()=>t(),e)}};var he=Ae(le());async function ue(t,e){if(!window.searchData)return;let n=await fetch(window.searchData),r=new Blob([await n.arrayBuffer()]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();t.data=i,t.index=he.Index.load(i.index),e.classList.remove("loading"),e.classList.add("ready")}function pe(){let t=document.getElementById("tsd-search");if(!t)return;let e={base:t.dataset.base+"/"},n=document.getElementById("tsd-search-script");t.classList.add("loading"),n&&(n.addEventListener("error",()=>{t.classList.remove("loading"),t.classList.add("failure")}),n.addEventListener("load",()=>{ue(e,t)}),ue(e,t));let r=document.querySelector("#tsd-search input"),i=document.querySelector("#tsd-search .results");if(!r||!i)throw new Error("The input field or the result list wrapper was not found");i.addEventListener("mouseup",()=>{ee(t)}),r.addEventListener("focus",()=>t.classList.add("has-focus")),Ve(t,i,r,e)}function Ve(t,e,n,r){n.addEventListener("input",se(()=>{Ne(t,e,n,r)},200)),n.addEventListener("keydown",i=>{i.key=="Enter"?He(e,t):i.key=="ArrowUp"?(ce(e,n,-1),i.preventDefault()):i.key==="ArrowDown"&&(ce(e,n,1),i.preventDefault())}),document.body.addEventListener("keypress",i=>{i.altKey||i.ctrlKey||i.metaKey||!n.matches(":focus")&&i.key==="/"&&(i.preventDefault(),n.focus())}),document.body.addEventListener("keyup",i=>{t.classList.contains("has-focus")&&(i.key==="Escape"||!e.matches(":focus-within")&&!n.matches(":focus"))&&(n.blur(),ee(t))})}function ee(t){t.classList.remove("has-focus")}function Ne(t,e,n,r){if(!r.index||!r.data)return;e.textContent="";let i=n.value.trim(),s;if(i){let o=i.split(" ").map(a=>a.length?`*${a}*`:"").join(" ");s=r.index.search(o)}else s=[];for(let o=0;o<s.length;o++){let a=s[o],l=r.data.rows[Number(a.ref)],u=1;l.name.toLowerCase().startsWith(i.toLowerCase())&&(u*=1+1/(1+Math.abs(l.name.length-i.length))),a.score*=u}if(s.length===0){let o=document.createElement("li");o.classList.add("no-results");let a=document.createElement("span");a.textContent="No results found",o.appendChild(a),e.appendChild(o)}s.sort((o,a)=>a.score-o.score);for(let o=0,a=Math.min(10,s.length);o<a;o++){let l=r.data.rows[Number(s[o].ref)],u=`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" class="tsd-kind-icon"><use href="#icon-${l.kind}"></use></svg>`,d=de(l.name,i);globalThis.DEBUG_SEARCH_WEIGHTS&&(d+=` (score: ${s[o].score.toFixed(2)})`),l.parent&&(d=`<span class="parent"> | ||
${de(l.parent,i)}.</span>${d}`);let m=document.createElement("li");m.classList.value=l.classes??"";let p=document.createElement("a");p.href=r.base+l.url,p.innerHTML=u+d,m.append(p),p.addEventListener("focus",()=>{e.querySelector(".current")?.classList.remove("current"),m.classList.add("current")}),e.appendChild(m)}}function ce(t,e,n){let r=t.querySelector(".current");if(!r)r=t.querySelector(n==1?"li:first-child":"li:last-child"),r&&r.classList.add("current");else{let i=r;if(n===1)do i=i.nextElementSibling??void 0;while(i instanceof HTMLElement&&i.offsetParent==null);else do i=i.previousElementSibling??void 0;while(i instanceof HTMLElement&&i.offsetParent==null);i?(r.classList.remove("current"),i.classList.add("current")):n===-1&&(r.classList.remove("current"),e.focus())}}function He(t,e){let n=t.querySelector(".current");if(n||(n=t.querySelector("li:first-child")),n){let r=n.querySelector("a");r&&(window.location.href=r.href),ee(e)}}function de(t,e){if(e==="")return t;let n=t.toLocaleLowerCase(),r=e.toLocaleLowerCase(),i=[],s=0,o=n.indexOf(r);for(;o!=-1;)i.push(K(t.substring(s,o)),`<b>${K(t.substring(o,o+r.length))}</b>`),s=o+r.length,o=n.indexOf(r,s);return i.push(K(t.substring(s))),i.join("")}var Be={"&":"&","<":"<",">":">","'":"'",'"':"""};function K(t){return t.replace(/[&<>"'"]/g,e=>Be[e])}var I=class{constructor(e){this.el=e.el,this.app=e.app}};var F="mousedown",me="mousemove",H="mouseup",J={x:0,y:0},fe=!1,te=!1,je=!1,D=!1,ye=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);document.documentElement.classList.add(ye?"is-mobile":"not-mobile");ye&&"ontouchstart"in document.documentElement&&(je=!0,F="touchstart",me="touchmove",H="touchend");document.addEventListener(F,t=>{te=!0,D=!1;let e=F=="touchstart"?t.targetTouches[0]:t;J.y=e.pageY||0,J.x=e.pageX||0});document.addEventListener(me,t=>{if(te&&!D){let e=F=="touchstart"?t.targetTouches[0]:t,n=J.x-(e.pageX||0),r=J.y-(e.pageY||0);D=Math.sqrt(n*n+r*r)>10}});document.addEventListener(H,()=>{te=!1});document.addEventListener("click",t=>{fe&&(t.preventDefault(),t.stopImmediatePropagation(),fe=!1)});var X=class extends I{constructor(e){super(e),this.className=this.el.dataset.toggle||"",this.el.addEventListener(H,n=>this.onPointerUp(n)),this.el.addEventListener("click",n=>n.preventDefault()),document.addEventListener(F,n=>this.onDocumentPointerDown(n)),document.addEventListener(H,n=>this.onDocumentPointerUp(n))}setActive(e){if(this.active==e)return;this.active=e,document.documentElement.classList.toggle("has-"+this.className,e),this.el.classList.toggle("active",e);let n=(this.active?"to-has-":"from-has-")+this.className;document.documentElement.classList.add(n),setTimeout(()=>document.documentElement.classList.remove(n),500)}onPointerUp(e){D||(this.setActive(!0),e.preventDefault())}onDocumentPointerDown(e){if(this.active){if(e.target.closest(".col-sidebar, .tsd-filter-group"))return;this.setActive(!1)}}onDocumentPointerUp(e){if(!D&&this.active&&e.target.closest(".col-sidebar")){let n=e.target.closest("a");if(n){let r=window.location.href;r.indexOf("#")!=-1&&(r=r.substring(0,r.indexOf("#"))),n.href.substring(0,r.length)==r&&setTimeout(()=>this.setActive(!1),250)}}}};var ne;try{ne=localStorage}catch{ne={getItem(){return null},setItem(){}}}var Q=ne;var ve=document.head.appendChild(document.createElement("style"));ve.dataset.for="filters";var Y=class extends I{constructor(e){super(e),this.key=`filter-${this.el.name}`,this.value=this.el.checked,this.el.addEventListener("change",()=>{this.setLocalStorage(this.el.checked)}),this.setLocalStorage(this.fromLocalStorage()),ve.innerHTML+=`html:not(.${this.key}) .tsd-is-${this.el.name} { display: none; } | ||
`,this.app.updateIndexVisibility()}fromLocalStorage(){let e=Q.getItem(this.key);return e?e==="true":this.el.checked}setLocalStorage(e){Q.setItem(this.key,e.toString()),this.value=e,this.handleValueChange()}handleValueChange(){this.el.checked=this.value,document.documentElement.classList.toggle(this.key,this.value),this.app.filterChanged(),this.app.updateIndexVisibility()}};var Z=class extends I{constructor(e){super(e),this.summary=this.el.querySelector(".tsd-accordion-summary"),this.icon=this.summary.querySelector("svg"),this.key=`tsd-accordion-${this.summary.dataset.key??this.summary.textContent.trim().replace(/\s+/g,"-").toLowerCase()}`;let n=Q.getItem(this.key);this.el.open=n?n==="true":this.el.open,this.el.addEventListener("toggle",()=>this.update());let r=this.summary.querySelector("a");r&&r.addEventListener("click",()=>{location.assign(r.href)}),this.update()}update(){this.icon.style.transform=`rotate(${this.el.open?0:-90}deg)`,Q.setItem(this.key,this.el.open.toString())}};function xe(t){let e=Q.getItem("tsd-theme")||"os";t.value=e,ge(e),t.addEventListener("change",()=>{Q.setItem("tsd-theme",t.value),ge(t.value)})}function ge(t){document.documentElement.dataset.theme=t}var be;function we(){let t=document.getElementById("tsd-nav-script");t&&(t.addEventListener("load",Ee),Ee())}async function Ee(){let t=document.getElementById("tsd-nav-container");if(!t||!window.navigationData)return;let n=await(await fetch(window.navigationData)).arrayBuffer(),r=new Blob([n]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();be=t.dataset.base+"/",t.innerHTML="";for(let s of i)Se(s,t,[]);window.app.createComponents(t),window.app.showPage(),window.app.ensureActivePageVisible()}function Se(t,e,n){let r=e.appendChild(document.createElement("li"));if(t.children){let i=[...n,t.text],s=r.appendChild(document.createElement("details"));s.className=t.class?`${t.class} tsd-index-accordion`:"tsd-index-accordion",s.dataset.key=i.join("$");let o=s.appendChild(document.createElement("summary"));o.className="tsd-accordion-summary",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="#icon-chevronDown"></use></svg>',Le(t,o);let a=s.appendChild(document.createElement("div"));a.className="tsd-accordion-details";let l=a.appendChild(document.createElement("ul"));l.className="tsd-nested-navigation";for(let u of t.children)Se(u,l,i)}else Le(t,r,t.class)}function Le(t,e,n){if(t.path){let r=e.appendChild(document.createElement("a"));r.href=be+t.path,n&&(r.className=n),location.pathname===r.pathname&&r.classList.add("current"),t.kind&&(r.innerHTML=`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" class="tsd-kind-icon"><use href="#icon-${t.kind}"></use></svg>`),r.appendChild(document.createElement("span")).textContent=t.text}else e.appendChild(document.createElement("span")).textContent=t.text}G(X,"a[data-toggle]");G(Z,".tsd-index-accordion");G(Y,".tsd-filter-item input[type=checkbox]");var Te=document.getElementById("tsd-theme");Te&&xe(Te);var qe=new U;Object.defineProperty(window,"app",{value:qe});pe();we();})(); | ||
/*! Bundled license information: | ||
@@ -7,0 +7,0 @@ |
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", | ||
// If updating this, also update tsdoc-defaults.ts | ||
"noStandardTags": false, | ||
@@ -97,2 +98,10 @@ "tagDefinitions": [ | ||
{ | ||
"tagName": "@license", | ||
"syntaxKind": "block" | ||
}, | ||
{ | ||
"tagName": "@import", | ||
"syntaxKind": "block" | ||
}, | ||
{ | ||
"tagName": "@overload", | ||
@@ -99,0 +108,0 @@ "syntaxKind": "modifier" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1531539
330
34110
6
17
+ Addedmarkdown-it@^14.1.0
+ Addedyaml@^2.4.2
+ Added@shikijs/core@1.18.0(transitive)
+ Added@shikijs/engine-javascript@1.18.0(transitive)
+ Added@shikijs/engine-oniguruma@1.18.0(transitive)
+ Added@shikijs/types@1.18.0(transitive)
+ Added@shikijs/vscode-textmate@9.2.2(transitive)
+ Added@types/hast@3.0.4(transitive)
+ Added@types/mdast@4.0.4(transitive)
+ Added@types/unist@3.0.3(transitive)
+ Added@ungap/structured-clone@1.2.0(transitive)
+ Addedargparse@2.0.1(transitive)
+ Addedccount@2.0.1(transitive)
+ Addedcharacter-entities-html4@2.1.0(transitive)
+ Addedcharacter-entities-legacy@3.0.0(transitive)
+ Addedcomma-separated-tokens@2.0.3(transitive)
+ Addeddequal@2.0.3(transitive)
+ Addeddevlop@1.1.0(transitive)
+ Addedentities@4.5.0(transitive)
+ Addedhast-util-to-html@9.0.3(transitive)
+ Addedhast-util-whitespace@3.0.0(transitive)
+ Addedhtml-void-elements@3.0.0(transitive)
+ Addedlinkify-it@5.0.0(transitive)
+ Addedmarkdown-it@14.1.0(transitive)
+ Addedmdast-util-to-hast@13.2.0(transitive)
+ Addedmdurl@2.0.0(transitive)
+ Addedmicromark-util-character@2.1.0(transitive)
+ Addedmicromark-util-encode@2.0.0(transitive)
+ Addedmicromark-util-sanitize-uri@2.0.0(transitive)
+ Addedmicromark-util-symbol@2.0.0(transitive)
+ Addedmicromark-util-types@2.0.0(transitive)
+ Addedoniguruma-to-js@0.4.3(transitive)
+ Addedproperty-information@6.5.0(transitive)
+ Addedpunycode.js@2.3.1(transitive)
+ Addedregex@4.3.2(transitive)
+ Addedshiki@1.18.0(transitive)
+ Addedspace-separated-tokens@2.0.2(transitive)
+ Addedstringify-entities@4.0.4(transitive)
+ Addedtrim-lines@3.0.1(transitive)
+ Addedtypescript@5.5.4(transitive)
+ Addeduc.micro@2.1.0(transitive)
+ Addedunist-util-is@6.0.0(transitive)
+ Addedunist-util-position@5.0.0(transitive)
+ Addedunist-util-stringify-position@4.0.0(transitive)
+ Addedunist-util-visit@5.0.0(transitive)
+ Addedunist-util-visit-parents@6.0.1(transitive)
+ Addedvfile@6.0.3(transitive)
+ Addedvfile-message@4.0.2(transitive)
+ Addedyaml@2.5.1(transitive)
+ Addedzwitch@2.0.4(transitive)
- Removedmarked@^4.3.0
- Removedansi-sequence-parser@1.1.1(transitive)
- Removedjsonc-parser@3.3.1(transitive)
- Removedmarked@4.3.0(transitive)
- Removedshiki@0.14.7(transitive)
- Removedtypescript@5.4.5(transitive)
- Removedvscode-oniguruma@1.7.0(transitive)
- Removedvscode-textmate@8.0.0(transitive)
Updatedminimatch@^9.0.4
Updatedshiki@^1.4.0