Comparing version 0.25.3 to 0.25.4
@@ -12,16 +12,16 @@ "use strict"; | ||
exports.MeaningKeywords = [ | ||
"class", | ||
"interface", | ||
"type", | ||
"enum", | ||
"namespace", | ||
"function", | ||
"var", | ||
"constructor", | ||
"member", | ||
"event", | ||
"call", | ||
"new", | ||
"index", | ||
"complex", | ||
"class", // SymbolFlags.Class | ||
"interface", // SymbolFlags.Interface | ||
"type", // SymbolFlags.TypeAlias | ||
"enum", // SymbolFlags.Enum | ||
"namespace", // SymbolFlags.Module | ||
"function", // SymbolFlags.Function | ||
"var", // SymbolFlags.Variable | ||
"constructor", // SymbolFlags.Constructor | ||
"member", // SymbolFlags.ClassMember | SymbolFlags.EnumMember | ||
"event", // | ||
"call", // SymbolFlags.Signature (for __call) | ||
"new", // SymbolFlags.Signature (for __new) | ||
"index", // SymbolFlags.Signature (for __index) | ||
"complex", // Any complex type | ||
// TypeDoc specific | ||
@@ -28,0 +28,0 @@ "getter", |
@@ -124,2 +124,3 @@ "use strict"; | ||
const discovered = []; | ||
const seen = new Set(); | ||
for (const decl of symbol.declarations || []) { | ||
@@ -129,5 +130,6 @@ const text = decl.getSourceFile().text; | ||
const node = declarationToCommentNode(decl); | ||
if (!node) { | ||
if (!node || seen.has(node)) { | ||
continue; | ||
} | ||
seen.add(node); | ||
// Special behavior here! We temporarily put the implementation comment | ||
@@ -134,0 +136,0 @@ // on the reflection which contains all the signatures. This lets us pull |
@@ -129,4 +129,4 @@ "use strict"; | ||
let content; | ||
if (tagName === "@example" && config.jsDocCompatibility.exampleTag) { | ||
content = exampleBlockContent(comment, lexer, config, warning); | ||
if (tagName === "@example") { | ||
return exampleBlock(comment, lexer, config, warning); | ||
} | ||
@@ -172,4 +172,6 @@ else if (["@default", "@defaultValue"].includes(tagName) && | ||
* about unescaped/mismatched/missing braces in legacy JSDoc comments. | ||
* | ||
* In TSDoc, we also want to treat the first line of the block as the example name. | ||
*/ | ||
function exampleBlockContent(comment, lexer, config, warning) { | ||
function exampleBlock(comment, lexer, config, warning) { | ||
lexer.mark(); | ||
@@ -179,4 +181,47 @@ const content = blockContent(comment, lexer, config, () => { }); | ||
lexer.release(); | ||
if (content.some((part) => part.kind === "code" && part.text.startsWith("```"))) { | ||
return blockContent(comment, lexer, config, warning); | ||
if (!config.jsDocCompatibility.exampleTag || | ||
content.some((part) => part.kind === "code" && part.text.startsWith("```"))) { | ||
let exampleName = ""; | ||
// First line of @example block is the example name. | ||
let warnedAboutRichNameContent = false; | ||
outer: while ((lexer.done() || lexer.peek()) !== end) { | ||
const next = lexer.peek(); | ||
switch (next.kind) { | ||
case lexer_1.TokenSyntaxKind.NewLine: | ||
lexer.take(); | ||
break outer; | ||
case lexer_1.TokenSyntaxKind.Text: { | ||
const newline = next.text.indexOf("\n"); | ||
if (newline !== -1) { | ||
exampleName += next.text.substring(0, newline); | ||
next.pos += newline + 1; | ||
break outer; | ||
} | ||
else { | ||
exampleName += lexer.take().text; | ||
} | ||
break; | ||
} | ||
case lexer_1.TokenSyntaxKind.Code: | ||
case lexer_1.TokenSyntaxKind.Tag: | ||
case lexer_1.TokenSyntaxKind.TypeAnnotation: | ||
case lexer_1.TokenSyntaxKind.CloseBrace: | ||
case lexer_1.TokenSyntaxKind.OpenBrace: | ||
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()); | ||
warnedAboutRichNameContent = true; | ||
} | ||
exampleName += lexer.take().text; | ||
break; | ||
default: | ||
(0, utils_1.assertNever)(next.kind); | ||
} | ||
} | ||
const content = blockContent(comment, lexer, config, warning); | ||
const tag = new models_1.CommentTag("@example", content); | ||
if (exampleName.trim()) { | ||
tag.name = exampleName.trim(); | ||
} | ||
return tag; | ||
} | ||
@@ -193,15 +238,13 @@ const tokens = []; | ||
if (caption) { | ||
return [ | ||
const tag = new models_1.CommentTag("@example", [ | ||
{ | ||
kind: "text", | ||
text: caption[1] + "\n", | ||
}, | ||
{ | ||
kind: "code", | ||
text: makeCodeBlock(blockText.slice(caption[0].length)), | ||
}, | ||
]; | ||
]); | ||
tag.name = caption[1]; | ||
return tag; | ||
} | ||
else { | ||
return [ | ||
return new models_1.CommentTag("@example", [ | ||
{ | ||
@@ -211,3 +254,3 @@ kind: "code", | ||
}, | ||
]; | ||
]); | ||
} | ||
@@ -214,0 +257,0 @@ } |
@@ -159,3 +159,6 @@ "use strict"; | ||
} | ||
reflection.typeHierarchy = root; | ||
// No point setting up a hierarchy if there is no hierarchy to display | ||
if (root.next) { | ||
reflection.typeHierarchy = root; | ||
} | ||
}); | ||
@@ -162,0 +165,0 @@ } |
@@ -113,11 +113,2 @@ "use strict"; | ||
} | ||
// A default exported function with no associated variable is a property, but | ||
// we should really convert it as a variable for documentation purposes | ||
// export default () => {} | ||
// export default 123 | ||
if (flags === typescript_1.default.SymbolFlags.Property && | ||
symbol.name === "default" && | ||
context.scope.kindOf(models_1.ReflectionKind.Module | models_1.ReflectionKind.Project)) { | ||
flags = typescript_1.default.SymbolFlags.BlockScopedVariable; | ||
} | ||
for (const flag of (0, enum_1.getEnumFlags)(flags ^ allConverterFlags)) { | ||
@@ -363,4 +354,11 @@ if (!(flag & allConverterFlags)) { | ||
(0, index_signature_1.convertIndexSignature)(reflectionContext, symbol); | ||
// Normally this shouldn't matter, unless someone did something with skipLibCheck off. | ||
return typescript_1.default.SymbolFlags.Alias; | ||
} | ||
function convertProperty(context, symbol, exportSymbol) { | ||
// This might happen if we're converting a function-module created with Object.assign | ||
// or `export default () => {}` | ||
if (context.scope.kindOf(models_1.ReflectionKind.SomeModule | models_1.ReflectionKind.Project)) { | ||
return convertVariable(context, symbol, exportSymbol); | ||
} | ||
const declarations = symbol.getDeclarations() ?? []; | ||
@@ -471,5 +469,6 @@ // Don't do anything if we inherited this property and it is private. | ||
const declaration = symbol.getDeclarations()?.[0]; | ||
(0, assert_1.default)(declaration); | ||
const comment = context.getComment(symbol, models_1.ReflectionKind.Variable); | ||
const type = context.checker.getTypeOfSymbolAtLocation(symbol, declaration); | ||
const type = declaration | ||
? context.checker.getTypeOfSymbolAtLocation(symbol, declaration) | ||
: context.checker.getTypeOfSymbol(symbol); | ||
if (isEnumLike(context.checker, type, declaration) && | ||
@@ -487,3 +486,3 @@ comment?.hasModifier("@enum")) { | ||
let typeNode; | ||
if (typescript_1.default.isVariableDeclaration(declaration)) { | ||
if (declaration && typescript_1.default.isVariableDeclaration(declaration)) { | ||
// Otherwise we might have destructuring | ||
@@ -499,3 +498,3 @@ typeNode = declaration.type; | ||
function isEnumLike(checker, type, location) { | ||
if (!(0, enum_1.hasAllFlags)(type.flags, typescript_1.default.TypeFlags.Object)) { | ||
if (!location || !(0, enum_1.hasAllFlags)(type.flags, typescript_1.default.TypeFlags.Object)) { | ||
return false; | ||
@@ -553,2 +552,10 @@ } | ||
} | ||
// #2436: Functions created with Object.assign on a function won't have a namespace flag | ||
// but likely have properties that we should put into a namespace. | ||
if (type.getProperties().length && | ||
!(0, enum_1.hasAnyFlag)(symbol.flags, typescript_1.default.SymbolFlags.NamespaceModule | typescript_1.default.SymbolFlags.ValueModule)) { | ||
const ns = context.createDeclarationReflection(models_1.ReflectionKind.Namespace, symbol, exportSymbol); | ||
context.finalizeDeclarationReflection(ns); | ||
convertSymbols(context.withScope(ns), type.getProperties()); | ||
} | ||
return typescript_1.default.SymbolFlags.Property; | ||
@@ -555,0 +562,0 @@ } |
@@ -32,3 +32,3 @@ "use strict"; | ||
}; | ||
return this.sourceLinkTemplate.replace(/\{(path|line)\}/g, (_, key) => replacements[key]); | ||
return this.sourceLinkTemplate.replace(/\{(gitRevision|path|line)\}/g, (_, key) => replacements[key]); | ||
} | ||
@@ -121,5 +121,5 @@ } | ||
/(github(?!.us)(?:\.[a-z]+)*\.[a-z]{2,})[:/]([^/]+)\/(.*)/, | ||
/(\w+\.githubprivate.com)[:/]([^/]+)\/(.*)/, | ||
/(\w+\.ghe.com)[:/]([^/]+)\/(.*)/, | ||
/(\w+\.github.us)[:/]([^/]+)\/(.*)/, | ||
/(\w+\.githubprivate.com)[:/]([^/]+)\/(.*)/, // GitHub enterprise | ||
/(\w+\.ghe.com)[:/]([^/]+)\/(.*)/, // GitHub enterprise | ||
/(\w+\.github.us)[:/]([^/]+)\/(.*)/, // GitHub enterprise | ||
/(bitbucket.org)[:/]([^/]+)\/(.*)/, | ||
@@ -126,0 +126,0 @@ /(gitlab.com)[:/]([^/]+)\/(.*)/, |
@@ -9,4 +9,9 @@ "use strict"; | ||
function resolveAliasedSymbol(symbol, checker) { | ||
const seen = new Set(); | ||
while (typescript_1.default.SymbolFlags.Alias & symbol.flags) { | ||
symbol = checker.getAliasedSymbol(symbol); | ||
// #2438, with declaration files, we might have an aliased symbol which eventually points to itself. | ||
if (seen.has(symbol)) | ||
return symbol; | ||
seen.add(symbol); | ||
} | ||
@@ -13,0 +18,0 @@ return symbol; |
@@ -20,4 +20,12 @@ import ts from "typescript"; | ||
* should not be needed when deserializing from JSON. | ||
* Will be set to `Infinity` if the ID was deserialized from JSON. | ||
*/ | ||
pos: number; | ||
/** | ||
* Note: This is **not** serialized. It exists to support detection of the differences between | ||
* symbols which share declarations, but are instantiated with different type parameters. | ||
* This will be `NaN` if the symbol reference is not transient. | ||
* Note: This can only be non-NaN if {@link pos} is finite. | ||
*/ | ||
transientId: number; | ||
constructor(symbol: ts.Symbol, declaration?: ts.Declaration); | ||
@@ -24,0 +32,0 @@ constructor(json: JSONOutput.ReflectionSymbolId); |
@@ -11,5 +11,7 @@ "use strict"; | ||
const fs_2 = require("../../utils/fs"); | ||
const paths_1 = require("../../utils/paths"); | ||
const tsutils_1 = require("../../utils/tsutils"); | ||
const validation_1 = require("../../utils/validation"); | ||
const paths_1 = require("../../utils/paths"); | ||
let transientCount = 0; | ||
const transientIds = new WeakMap(); | ||
/** | ||
@@ -32,2 +34,9 @@ * This exists so that TypeDoc can store a unique identifier for a `ts.Symbol` without | ||
this.pos = declaration?.pos ?? Infinity; | ||
if (symbol.flags & typescript_1.default.SymbolFlags.Transient) { | ||
this.transientId = transientIds.get(symbol) ?? ++transientCount; | ||
transientIds.set(symbol, this.transientId); | ||
} | ||
else { | ||
this.transientId = NaN; | ||
} | ||
} | ||
@@ -38,2 +47,3 @@ else { | ||
this.pos = Infinity; | ||
this.transientId = NaN; | ||
} | ||
@@ -43,3 +53,3 @@ } | ||
if (Number.isFinite(this.pos)) { | ||
return `${this.fileName}\0${this.qualifiedName}\0${this.pos}`; | ||
return `${this.fileName}\0${this.qualifiedName}\0${this.pos}\0${this.transientId}`; | ||
} | ||
@@ -102,3 +112,3 @@ else { | ||
for (const file of files) { | ||
const mapFile = (0, path_1.resolve)(declDir, (0, path_1.relative)(rootDir, file)).replace(/\.([cm]?[tj]s)x?$/, ".d.$1"); | ||
const mapFile = (0, paths_1.normalizePath)((0, path_1.resolve)(declDir, (0, path_1.relative)(rootDir, file)).replace(/\.([cm]?[tj]s)x?$/, ".d.$1")); | ||
declarationMapCache.set(mapFile, file); | ||
@@ -105,0 +115,0 @@ } |
@@ -154,23 +154,23 @@ "use strict"; | ||
none: "none", | ||
templateLiteralElement: "templateLiteralElement", | ||
arrayElement: "arrayElement", | ||
indexedAccessElement: "indexedAccessElement", | ||
conditionalCheck: "conditionalCheck", | ||
conditionalExtends: "conditionalExtends", | ||
conditionalTrue: "conditionalTrue", | ||
conditionalFalse: "conditionalFalse", | ||
indexedIndex: "indexedIndex", | ||
indexedObject: "indexedObject", | ||
inferredConstraint: "inferredConstraint", | ||
intersectionElement: "intersectionElement", | ||
mappedName: "mappedName", | ||
mappedParameter: "mappedParameter", | ||
mappedTemplate: "mappedTemplate", | ||
optionalElement: "optionalElement", | ||
predicateTarget: "predicateTarget", | ||
queryTypeTarget: "queryTypeTarget", | ||
typeOperatorTarget: "typeOperatorTarget", | ||
referenceTypeArgument: "referenceTypeArgument", | ||
restElement: "restElement", | ||
tupleElement: "tupleElement", | ||
templateLiteralElement: "templateLiteralElement", // `${here}` | ||
arrayElement: "arrayElement", // here[] | ||
indexedAccessElement: "indexedAccessElement", // {}[here] | ||
conditionalCheck: "conditionalCheck", // here extends 1 ? 2 : 3 | ||
conditionalExtends: "conditionalExtends", // 1 extends here ? 2 : 3 | ||
conditionalTrue: "conditionalTrue", // 1 extends 2 ? here : 3 | ||
conditionalFalse: "conditionalFalse", // 1 extends 2 ? 3 : here | ||
indexedIndex: "indexedIndex", // {}[here] | ||
indexedObject: "indexedObject", // here[1] | ||
inferredConstraint: "inferredConstraint", // 1 extends infer X extends here ? 1 : 2 | ||
intersectionElement: "intersectionElement", // here & 1 | ||
mappedName: "mappedName", // { [k in string as here]: 1 } | ||
mappedParameter: "mappedParameter", // { [k in here]: 1 } | ||
mappedTemplate: "mappedTemplate", // { [k in string]: here } | ||
optionalElement: "optionalElement", // [here?] | ||
predicateTarget: "predicateTarget", // (): X is here | ||
queryTypeTarget: "queryTypeTarget", // typeof here, can only ever be a ReferenceType | ||
typeOperatorTarget: "typeOperatorTarget", // keyof here | ||
referenceTypeArgument: "referenceTypeArgument", // X<here> | ||
restElement: "restElement", // [...here] | ||
tupleElement: "tupleElement", // [here] | ||
unionElement: "unionElement", // here | 1 | ||
@@ -177,0 +177,0 @@ }; |
@@ -26,2 +26,11 @@ import type { PageEvent, RendererHooks } from "../.."; | ||
defaultLayout: (template: import("../..").RenderTemplate<PageEvent<Reflection>>, props: PageEvent<Reflection>) => JSX.Element; | ||
/** | ||
* Rendered just after the description for a reflection. | ||
* This can be used to render a shortened type display of a reflection that the | ||
* rest of the page expands on. | ||
* | ||
* Note: Will not be called for variables/type aliases, as they are summarized | ||
* by their type declaration, which is already rendered by {@link DefaultThemeRenderContext.memberDeclaration} | ||
*/ | ||
reflectionPreview: (props: Reflection) => JSX.Element | undefined; | ||
analytics: () => JSX.Element | undefined; | ||
@@ -40,6 +49,6 @@ breadcrumb: (props: Reflection) => JSX.Element | undefined; | ||
memberReference: (props: import("../../../models").ReferenceReflection) => JSX.Element; | ||
memberSignatureBody: (r_0: import("../../../models").SignatureReflection, r_1?: { | ||
memberSignatureBody: (props: import("../../../models").SignatureReflection, r_1?: { | ||
hideSources?: boolean | undefined; | ||
} | undefined) => JSX.Element; | ||
memberSignatureTitle: (r_0: import("../../../models").SignatureReflection, r_1?: { | ||
memberSignatureTitle: (props: import("../../../models").SignatureReflection, r_1?: { | ||
hideName?: boolean | undefined; | ||
@@ -60,5 +69,7 @@ arrowStyle?: boolean | undefined; | ||
toolbar: (props: PageEvent<Reflection>) => JSX.Element; | ||
type: (type: import("../../../models").Type | undefined) => JSX.Element; | ||
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; | ||
} |
@@ -26,2 +26,3 @@ "use strict"; | ||
const parameter_1 = require("./partials/parameter"); | ||
const reflectionPreview_1 = require("./partials/reflectionPreview"); | ||
const toolbar_1 = require("./partials/toolbar"); | ||
@@ -63,2 +64,11 @@ const type_1 = require("./partials/type"); | ||
this.defaultLayout = bind(default_1.defaultLayout, this); | ||
/** | ||
* Rendered just after the description for a reflection. | ||
* This can be used to render a shortened type display of a reflection that the | ||
* rest of the page expands on. | ||
* | ||
* Note: Will not be called for variables/type aliases, as they are summarized | ||
* by their type declaration, which is already rendered by {@link DefaultThemeRenderContext.memberDeclaration} | ||
*/ | ||
this.reflectionPreview = bind(reflectionPreview_1.reflectionPreview, this); | ||
this.analytics = bind(analytics_1.analytics, this); | ||
@@ -65,0 +75,0 @@ this.breadcrumb = bind(breadcrumb_1.breadcrumb, this); |
@@ -21,5 +21,10 @@ "use strict"; | ||
: props.comment.blockTags; | ||
return (utils_1.JSX.createElement("div", { class: "tsd-comment tsd-typography" }, tags.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("h4", null, (0, lib_1.camelToTitleCase)(item.tag.substring(1))), | ||
utils_1.JSX.createElement(utils_1.Raw, { html: markdown(item.content) })))))); | ||
return (utils_1.JSX.createElement("div", { class: "tsd-comment tsd-typography" }, tags.map((item) => { | ||
const name = item.name | ||
? `${(0, lib_1.camelToTitleCase)(item.tag.substring(1))}: ${item.name}` | ||
: (0, lib_1.camelToTitleCase)(item.tag.substring(1)); | ||
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("h4", null, name), | ||
utils_1.JSX.createElement(utils_1.Raw, { html: markdown(item.content) }))); | ||
}))); | ||
} | ||
@@ -26,0 +31,0 @@ exports.commentTags = commentTags; |
@@ -9,3 +9,4 @@ "use strict"; | ||
utils_1.JSX.createElement("ul", { class: (0, lib_1.classNames)({ "tsd-signatures": true }, context.getReflectionClasses(props)) }, props.signatures?.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("li", { class: "tsd-signature tsd-anchor-link", id: item.anchor }, | ||
utils_1.JSX.createElement("li", { class: "tsd-signature tsd-anchor-link" }, | ||
utils_1.JSX.createElement("a", { id: item.anchor, class: "tsd-anchor" }), | ||
context.memberSignatureTitle(item), | ||
@@ -12,0 +13,0 @@ (0, anchor_icon_1.anchorIcon)(context, item.anchor)), |
@@ -5,2 +5,4 @@ import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
export declare function validateStateIsClean(page: string): void; | ||
export declare function type(context: DefaultThemeRenderContext, type: Type | undefined): JSX.Element; | ||
export declare function type(context: DefaultThemeRenderContext, type: Type | undefined, options?: { | ||
topLevelLinks: boolean; | ||
}): JSX.Element; |
@@ -77,3 +77,3 @@ "use strict"; | ||
renderType(context, type.checkType, models_1.TypeContext.conditionalCheck), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, " extends "), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, " extends "), | ||
renderType(context, type.extendsType, models_1.TypeContext.conditionalExtends), | ||
@@ -111,7 +111,7 @@ utils_1.JSX.createElement("br", null), | ||
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "infer "), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "infer "), | ||
" ", | ||
utils_1.JSX.createElement("span", { class: "tsd-kind-type-parameter" }, type.name), | ||
type.constraint && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, " extends "), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, " extends "), | ||
renderType(context, type.constraint, models_1.TypeContext.inferredConstraint))))); | ||
@@ -133,11 +133,13 @@ }, | ||
case "+": | ||
parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "readonly ")); | ||
parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "readonly ")); | ||
break; | ||
case "-": | ||
parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "-readonly ")); | ||
parts.push(utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "-"), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "readonly "))); | ||
break; | ||
} | ||
parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "["), utils_1.JSX.createElement("span", { class: "tsd-kind-type-parameter" }, type.parameter), utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, " in "), renderType(context, type.parameterType, models_1.TypeContext.mappedParameter)); | ||
parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "["), utils_1.JSX.createElement("span", { class: "tsd-kind-type-parameter" }, type.parameter), utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, " in "), renderType(context, type.parameterType, models_1.TypeContext.mappedParameter)); | ||
if (type.nameType) { | ||
parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, " as "), renderType(context, type.nameType, models_1.TypeContext.mappedName)); | ||
parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, " as "), renderType(context, type.nameType, models_1.TypeContext.mappedName)); | ||
} | ||
@@ -176,6 +178,6 @@ parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "]")); | ||
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
!!type.asserts && utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "asserts "), | ||
!!type.asserts && utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "asserts "), | ||
utils_1.JSX.createElement("span", { class: "tsd-kind-parameter" }, type.name), | ||
!!type.targetType && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, " is "), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, " is "), | ||
renderType(context, type.targetType, models_1.TypeContext.predicateTarget))))); | ||
@@ -185,3 +187,3 @@ }, | ||
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "typeof "), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "typeof "), | ||
renderType(context, type.queryType, models_1.TypeContext.queryTypeTarget))); | ||
@@ -219,10 +221,11 @@ }, | ||
}, | ||
reflection(context, type) { | ||
reflection(context, type, { topLevelLinks }) { | ||
const members = []; | ||
const children = type.declaration.children || []; | ||
indentationDepth++; | ||
const renderName = (named) => topLevelLinks ? (utils_1.JSX.createElement("a", { class: (0, lib_1.getKindClass)(named), href: context.urlTo(named) }, named.name)) : (utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(named) }, named.name)); | ||
for (const item of children) { | ||
if (item.getSignature && item.setSignature) { | ||
members.push(utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(item) }, item.name), | ||
renderName(item), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, ": "), | ||
@@ -234,4 +237,4 @@ renderType(context, item.getSignature.type, models_1.TypeContext.none))); | ||
members.push(utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "get "), | ||
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(item.getSignature) }, item.name), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "get "), | ||
renderName(item.getSignature), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "(): "), | ||
@@ -243,4 +246,4 @@ renderType(context, item.getSignature.type, models_1.TypeContext.none))); | ||
members.push(utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "set "), | ||
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(item.setSignature) }, item.name), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "set "), | ||
renderName(item.setSignature), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "("), | ||
@@ -257,7 +260,7 @@ item.setSignature.parameters?.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
members.push(utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(sig) }, item.name), | ||
renderName(sig), | ||
item.flags.isOptional && utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "?"), | ||
context.memberSignatureTitle(sig, { | ||
hideName: true, | ||
arrowStyle: true, | ||
arrowStyle: false, | ||
}))); | ||
@@ -268,3 +271,3 @@ } | ||
members.push(utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(item) }, item.name), | ||
renderName(item), | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, item.flags.isOptional ? "?: " : ": "), | ||
@@ -344,3 +347,3 @@ renderType(context, item.type, models_1.TypeContext.none))); | ||
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, | ||
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, | ||
type.operator, | ||
@@ -357,3 +360,3 @@ " "), | ||
}; | ||
function renderType(context, type, where) { | ||
function renderType(context, type, where, options = { topLevelLinks: false }) { | ||
if (!type) { | ||
@@ -363,3 +366,3 @@ return utils_1.JSX.createElement("span", { class: "tsd-signature-type" }, "any"); | ||
const renderFn = typeRenderers[type.type]; | ||
const rendered = renderFn(context, type); | ||
const rendered = renderFn(context, type, options); | ||
if (type.needsParenthesis(where)) { | ||
@@ -373,5 +376,5 @@ return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
} | ||
function type(context, type) { | ||
return renderType(context, type, models_1.TypeContext.none); | ||
function type(context, type, options = { topLevelLinks: false }) { | ||
return renderType(context, type, models_1.TypeContext.none, options); | ||
} | ||
exports.type = type; |
@@ -8,3 +8,3 @@ "use strict"; | ||
function reflectionTemplate(context, props) { | ||
if ([models_1.ReflectionKind.TypeAlias, models_1.ReflectionKind.Variable].includes(props.model.kind) && | ||
if (props.model.kindOf(models_1.ReflectionKind.TypeAlias | models_1.ReflectionKind.Variable) && | ||
props.model instanceof models_1.DeclarationReflection) { | ||
@@ -21,2 +21,3 @@ return context.memberDeclaration(props.model); | ||
utils_1.JSX.createElement(utils_1.Raw, { html: context.markdown(props.model.readme) }))), | ||
context.reflectionPreview(props.model), | ||
(0, lib_1.hasTypeParameters)(props.model) && utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
@@ -23,0 +24,0 @@ " ", |
@@ -7,4 +7,4 @@ "use strict"; | ||
exports.EmitStrategy = { | ||
both: "both", | ||
docs: "docs", | ||
both: "both", // Emit both documentation and JS | ||
docs: "docs", // Emit documentation, but not JS (default) | ||
none: "none", // Emit nothing, just convert and run validation | ||
@@ -11,0 +11,0 @@ }; |
@@ -49,2 +49,3 @@ "use strict"; | ||
options._declarations = new Map(this._declarations); | ||
options.reset(); | ||
return options; | ||
@@ -89,3 +90,3 @@ } | ||
if (!declaration) { | ||
throw new Error("Cannot reset an option which has not been declared."); | ||
throw new Error(`Cannot reset an option (${name}) which has not been declared.`); | ||
} | ||
@@ -142,3 +143,3 @@ this._values[declaration.name] = (0, declaration_2.getDefaultValue)(declaration); | ||
if (!this._declarations.has(name)) { | ||
throw new Error("Tried to check if an undefined option was set"); | ||
throw new Error(`Tried to check if an undefined option (${name}) was set`); | ||
} | ||
@@ -163,3 +164,3 @@ return this._setOptions.has(name); | ||
if (this.isFrozen()) { | ||
throw new Error("Tried to modify an option value after options have been frozen."); | ||
throw new Error(`Tried to modify an option (${name}) value after options have been frozen.`); | ||
} | ||
@@ -219,3 +220,3 @@ const declaration = this.getDeclaration(name); | ||
if (this.isFrozen()) { | ||
throw new Error("Tried to modify an option value after options have been sealed."); | ||
throw new Error("Tried to modify compiler options after options have been frozen."); | ||
} | ||
@@ -272,3 +273,3 @@ // We do this here instead of in the tsconfig reader so that API consumers which | ||
set(_value) { | ||
throw new Error("Options may not be set via the Option decorator"); | ||
throw new Error(`Options may not be set via the Option decorator when setting ${name}`); | ||
}, | ||
@@ -275,0 +276,0 @@ }; |
{ | ||
"name": "typedoc", | ||
"description": "Create api documentation for TypeScript projects.", | ||
"version": "0.25.3", | ||
"version": "0.25.4", | ||
"homepage": "https://typedoc.org", | ||
@@ -33,3 +33,3 @@ "exports": { | ||
"peerDependencies": { | ||
"typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.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" | ||
}, | ||
@@ -51,3 +51,3 @@ "devDependencies": { | ||
"ts-node": "^10.9.1", | ||
"typescript": "5.2.2" | ||
"typescript": "5.3.2" | ||
}, | ||
@@ -69,3 +69,5 @@ "files": [ | ||
"doc:c": "node bin/typedoc --tsconfig src/test/converter/tsconfig.json", | ||
"doc:c2": "node --inspect-brk bin/typedoc --tsconfig src/test/converter2/tsconfig.json", | ||
"doc:c2": "node bin/typedoc --tsconfig src/test/converter2/tsconfig.json", | ||
"doc:c2d": "node --inspect-brk bin/typedoc --tsconfig src/test/converter2/tsconfig.json", | ||
"example": "cd example && node ../bin/typedoc", | ||
"test:full": "c8 mocha --config .config/mocha.full.json", | ||
@@ -72,0 +74,0 @@ "test:visual": "ts-node ./src/test/capture-screenshots.ts && ./scripts/compare_screenshots.sh", |
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
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
1374732
310
31478