Comparing version 0.24.0-beta.8 to 0.24.0
import ts from "typescript"; | ||
import { Comment, ReflectionKind } from "../../models"; | ||
import { Logger } from "../../utils"; | ||
import type { CommentStyle } from "../../utils/options/declaration"; | ||
import type { CommentStyle, JsDocCompatibility } from "../../utils/options/declaration"; | ||
export interface CommentParserConfig { | ||
@@ -9,2 +9,3 @@ blockTags: Set<string>; | ||
modifierTags: Set<string>; | ||
jsDocCompatibility: JsDocCompatibility; | ||
} | ||
@@ -11,0 +12,0 @@ export declare function clearCommentCache(): void; |
@@ -130,5 +130,8 @@ "use strict"; | ||
let content; | ||
if (tagName === "@example") { | ||
if (tagName === "@example" && config.jsDocCompatibility.exampleTag) { | ||
content = exampleBlockContent(comment, lexer, config, warning); | ||
} | ||
else if (tagName === "@default" && config.jsDocCompatibility.defaultTag) { | ||
content = defaultBlockContent(comment, lexer, config, warning); | ||
} | ||
else { | ||
@@ -140,4 +143,31 @@ content = blockContent(comment, lexer, config, warning); | ||
/** | ||
* The `@default` tag gets a special case because otherwise we will produce many warnings | ||
* about unescaped/mismatched/missing braces in legacy JSDoc comments | ||
*/ | ||
function defaultBlockContent(comment, lexer, config, warning) { | ||
lexer.mark(); | ||
const content = blockContent(comment, lexer, config, () => { }); | ||
const end = lexer.done() || lexer.peek(); | ||
lexer.release(); | ||
if (content.some((part) => part.kind === "code")) { | ||
return blockContent(comment, lexer, config, warning); | ||
} | ||
const tokens = []; | ||
while ((lexer.done() || lexer.peek()) !== end) { | ||
tokens.push(lexer.take()); | ||
} | ||
const blockText = tokens | ||
.map((tok) => tok.text) | ||
.join("") | ||
.trim(); | ||
return [ | ||
{ | ||
kind: "code", | ||
text: makeCodeBlock(blockText), | ||
}, | ||
]; | ||
} | ||
/** | ||
* The `@example` tag gets a special case because otherwise we will produce many warnings | ||
* about unescaped/mismatched/missing braces | ||
* about unescaped/mismatched/missing braces in legacy JSDoc comments. | ||
*/ | ||
@@ -144,0 +174,0 @@ function exampleBlockContent(comment, lexer, config, warning) { |
@@ -75,2 +75,3 @@ "use strict"; | ||
this.trigger(Converter_1.EVENT_END, context); | ||
this._config = undefined; | ||
return project; | ||
@@ -242,2 +243,3 @@ } | ||
modifierTags: new Set(this.application.options.getValue("modifierTags")), | ||
jsDocCompatibility: this.application.options.getValue("jsDocCompatibility"), | ||
}; | ||
@@ -244,0 +246,0 @@ return this._config; |
@@ -395,4 +395,4 @@ "use strict"; | ||
}, | ||
convertType(context, type) { | ||
const symbol = type.getSymbol(); | ||
convertType(context, type, node) { | ||
const symbol = type.getSymbol() || context.getSymbolAtLocation(node.exprName); | ||
(0, assert_1.default)(symbol, `Query type failed to get a symbol for: ${context.checker.typeToString(type)}. This is a bug.`); | ||
@@ -399,0 +399,0 @@ return new models_1.QueryType(models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(symbol), context)); |
import { JSX } from "../../../../utils"; | ||
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
export declare const anchorIcon: (context: DefaultThemeRenderContext, anchor: string | undefined) => JSX.Element; | ||
export declare function anchorIcon(context: DefaultThemeRenderContext, anchor: string | undefined): JSX.Element; |
@@ -5,3 +5,7 @@ "use strict"; | ||
const utils_1 = require("../../../../utils"); | ||
const anchorIcon = (context, anchor) => (utils_1.JSX.createElement("a", { href: `#${anchor}`, "aria-label": "Permalink", class: "tsd-anchor-icon" }, context.icons.anchor())); | ||
function anchorIcon(context, anchor) { | ||
if (!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())); | ||
} | ||
exports.anchorIcon = anchorIcon; |
@@ -105,2 +105,3 @@ import type { Theme as ShikiTheme } from "shiki"; | ||
sidebarLinks: ManuallyValidatedOption<Record<string, string>>; | ||
jsDocCompatibility: JsDocCompatibility; | ||
commentStyle: typeof CommentStyle; | ||
@@ -161,2 +162,14 @@ useTsLinkResolution: boolean; | ||
}; | ||
export type JsDocCompatibility = { | ||
/** | ||
* If set, TypeDoc will treat `@example` blocks as code unless they contain a code block. | ||
* On by default, this is how VSCode renders blocks. | ||
*/ | ||
exampleTag: boolean; | ||
/** | ||
* If set, TypeDoc will treat `@default` blocks as code unless they contain a code block. | ||
* On by default, this is how VSCode renders blocks. | ||
*/ | ||
defaultTag: boolean; | ||
}; | ||
/** | ||
@@ -163,0 +176,0 @@ * Converts a given TypeDoc option key to the type of the declaration expected. |
@@ -70,3 +70,3 @@ "use strict"; | ||
optionSnapshots.set(key, { | ||
values: { ...this._values }, | ||
values: JSON.stringify(this._values), | ||
set: new Set(this._setOptions), | ||
@@ -82,3 +82,3 @@ }); | ||
const data = optionSnapshots.get(snapshot); | ||
this._values = { ...data.values }; | ||
this._values = JSON.parse(data.values); | ||
this._setOptions = new Set(data.set); | ||
@@ -85,0 +85,0 @@ } |
@@ -408,2 +408,11 @@ "use strict"; | ||
options.addDeclaration({ | ||
name: "jsDocCompatibility", | ||
help: "Sets compatibility options for comment parsing that increase similarity with JSDoc comments.", | ||
type: declaration_1.ParameterType.Flags, | ||
defaults: { | ||
defaultTag: true, | ||
exampleTag: true, | ||
}, | ||
}); | ||
options.addDeclaration({ | ||
name: "commentStyle", | ||
@@ -410,0 +419,0 @@ help: "Determines how TypeDoc searches for comments.", |
{ | ||
"name": "typedoc", | ||
"description": "Create api documentation for TypeScript projects.", | ||
"version": "0.24.0-beta.8", | ||
"version": "0.24.0", | ||
"homepage": "https://typedoc.org", | ||
@@ -6,0 +6,0 @@ "exports": { |
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
1128368
26440