Socket
Socket
Sign inDemoInstall

typedoc

Package Overview
Dependencies
Maintainers
5
Versions
309
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typedoc - npm Package Compare versions

Comparing version 0.24.0-beta.4 to 0.24.0-beta.5

39

dist/lib/converter/comments/discovery.js

@@ -13,2 +13,15 @@ "use strict";

const assert_1 = require("assert");
const variablePropertyKinds = [
typescript_1.default.SyntaxKind.PropertyDeclaration,
typescript_1.default.SyntaxKind.PropertySignature,
typescript_1.default.SyntaxKind.BinaryExpression,
typescript_1.default.SyntaxKind.PropertyAssignment,
// class X { constructor(/** Comment */ readonly z: string) }
typescript_1.default.SyntaxKind.Parameter,
// Variable values
typescript_1.default.SyntaxKind.VariableDeclaration,
typescript_1.default.SyntaxKind.BindingElement,
typescript_1.default.SyntaxKind.ExportAssignment,
typescript_1.default.SyntaxKind.PropertyAccessExpression,
];
// Note: This does NOT include JSDoc syntax kinds. This is important!

@@ -27,2 +40,7 @@ // Comments from @typedef and @callback tags are handled specially by

typescript_1.default.SyntaxKind.NamespaceExport,
// @namespace support
typescript_1.default.SyntaxKind.VariableDeclaration,
typescript_1.default.SyntaxKind.BindingElement,
typescript_1.default.SyntaxKind.ExportAssignment,
typescript_1.default.SyntaxKind.PropertyAccessExpression,
],

@@ -39,8 +57,3 @@ [models_1.ReflectionKind.Enum]: [

],
[models_1.ReflectionKind.Variable]: [
typescript_1.default.SyntaxKind.VariableDeclaration,
typescript_1.default.SyntaxKind.BindingElement,
typescript_1.default.SyntaxKind.ExportAssignment,
typescript_1.default.SyntaxKind.PropertyAccessExpression,
],
[models_1.ReflectionKind.Variable]: variablePropertyKinds,
[models_1.ReflectionKind.Function]: [

@@ -57,12 +70,8 @@ typescript_1.default.SyntaxKind.FunctionDeclaration,

],
[models_1.ReflectionKind.Interface]: [typescript_1.default.SyntaxKind.InterfaceDeclaration],
[models_1.ReflectionKind.Interface]: [
typescript_1.default.SyntaxKind.InterfaceDeclaration,
typescript_1.default.SyntaxKind.TypeAliasDeclaration,
],
[models_1.ReflectionKind.Constructor]: [typescript_1.default.SyntaxKind.Constructor],
[models_1.ReflectionKind.Property]: [
typescript_1.default.SyntaxKind.PropertyDeclaration,
typescript_1.default.SyntaxKind.PropertySignature,
typescript_1.default.SyntaxKind.BinaryExpression,
typescript_1.default.SyntaxKind.PropertyAssignment,
// class X { constructor(/** Comment */ readonly z: string) }
typescript_1.default.SyntaxKind.Parameter,
],
[models_1.ReflectionKind.Property]: variablePropertyKinds,
[models_1.ReflectionKind.Method]: [

@@ -69,0 +78,0 @@ typescript_1.default.SyntaxKind.FunctionDeclaration,

@@ -34,9 +34,5 @@ import ts from "typescript";

readonly scope: Reflection;
/** @internal */
isConvertingTypeNode(): boolean;
/** @internal */
setConvertingTypeNode(): void;
/** @internal */
convertingTypeNode: boolean;
convertingClassOrInterface: boolean;
shouldBeStatic: boolean;
private convertingTypeNode;
/**

@@ -52,6 +48,2 @@ * Create a new Context instance.

/**
* Return the compiler options.
*/
getCompilerOptions(): ts.CompilerOptions;
/**
* Return the type declaration of the given node.

@@ -58,0 +50,0 @@ *

@@ -33,10 +33,2 @@ "use strict";

}
/** @internal */
isConvertingTypeNode() {
return this.convertingTypeNode;
}
/** @internal */
setConvertingTypeNode() {
this.convertingTypeNode = true;
}
/**

@@ -49,5 +41,5 @@ * Create a new Context instance.

constructor(converter, programs, project, scope = project) {
/** @internal */
this.shouldBeStatic = false;
this.convertingTypeNode = false;
this.convertingTypeNode = false; // Inherited by withScope
this.convertingClassOrInterface = false; // Not inherited
this.shouldBeStatic = false; // Not inherited
this.converter = converter;

@@ -63,8 +55,2 @@ this.programs = programs;

/**
* Return the compiler options.
*/
getCompilerOptions() {
return this.converter.application.options.getCompilerOptions();
}
/**
* Return the type declaration of the given node.

@@ -118,2 +104,10 @@ *

const name = (0, tsutils_1.getHumanName)(nameOverride ?? exportSymbol?.name ?? symbol?.name ?? "unknown");
if (this.convertingClassOrInterface) {
if (kind === index_1.ReflectionKind.Function) {
kind = index_1.ReflectionKind.Method;
}
if (kind === index_1.ReflectionKind.Variable) {
kind = index_1.ReflectionKind.Property;
}
}
const reflection = new index_1.DeclarationReflection(name, kind, this.scope);

@@ -120,0 +114,0 @@ this.postReflectionCreation(reflection, symbol, exportSymbol);

@@ -120,2 +120,8 @@ "use strict";

applyModifiers(reflection, comment) {
if (reflection.kindOf(models_1.ReflectionKind.SomeModule)) {
comment.removeModifier("@namespace");
}
if (reflection.kindOf(models_1.ReflectionKind.Interface)) {
comment.removeModifier("@interface");
}
if (comment.hasModifier("@private")) {

@@ -271,2 +277,3 @@ reflection.setFlag(models_1.ReflectionFlag.Private);

mergeSeeTags(reflection.comment);
movePropertyTags(reflection.comment, reflection);
}

@@ -450,2 +457,13 @@ if (!(reflection instanceof models_1.DeclarationReflection)) {

}
function movePropertyTags(comment, container) {
const propTags = comment.blockTags.filter((tag) => tag.tag === "@prop" || tag.tag === "@property");
for (const prop of propTags) {
if (!prop.name)
continue;
const child = container.getChildByName(prop.name);
if (child) {
child.comment = new models_1.Comment(models_1.Comment.cloneDisplayParts(prop.content));
}
}
}
function mergeSeeTags(comment) {

@@ -452,0 +470,0 @@ const see = comment.getTags("@see");

@@ -78,2 +78,5 @@ "use strict";

}
else if (typescript_1.default.isSourceFile(node)) {
position = { character: 0, line: 0 };
}
else {

@@ -80,0 +83,0 @@ position = typescript_1.default.getLineAndCharacterOfPosition(sourceFile, node.getStart());

@@ -194,2 +194,5 @@ "use strict";

if (typescript_1.default.isTypeAliasDeclaration(declaration)) {
if (symbol.getJsDocTags().some((tag) => tag.name === "interface")) {
return convertTypeAliasAsInterface(context, symbol, exportSymbol, declaration);
}
const reflection = context.createDeclarationReflection(models_1.ReflectionKind.TypeAlias, symbol, exportSymbol);

@@ -210,2 +213,26 @@ reflection.type = context.converter.convertType(context.withScope(reflection), declaration.type);

}
function convertTypeAliasAsInterface(context, symbol, exportSymbol, declaration) {
const reflection = context.createDeclarationReflection(models_1.ReflectionKind.Interface, symbol, exportSymbol);
context.finalizeDeclarationReflection(reflection);
const rc = context.withScope(reflection);
const type = context.checker.getTypeAtLocation(declaration);
// Interfaces have properties
convertSymbols(rc, type.getProperties());
// And type arguments
if (declaration.typeParameters) {
reflection.typeParameters = declaration.typeParameters.map((param) => {
const declaration = param.symbol?.declarations?.[0];
(0, assert_1.default)(declaration && typescript_1.default.isTypeParameterDeclaration(declaration));
return (0, signature_1.createTypeParamReflection)(declaration, rc);
});
}
// And maybe call signatures
context.checker
.getSignaturesOfType(type, typescript_1.default.SignatureKind.Call)
.forEach((sig) => (0, signature_1.createSignature)(rc, models_1.ReflectionKind.CallSignature, sig, symbol));
// And maybe constructor signatures
convertConstructSignatures(rc, symbol);
// And finally, index signatures
(0, index_signature_1.convertIndexSignature)(rc, symbol);
}
function convertFunctionOrMethod(context, symbol, exportSymbol) {

@@ -263,2 +290,3 @@ // Can't just check method flag because this might be called for properties as well

const reflectionContext = context.withScope(reflection);
reflectionContext.convertingClassOrInterface = true;
const instanceType = context.checker.getDeclaredTypeOfSymbol(symbol);

@@ -368,3 +396,3 @@ (0, assert_1.default)(instanceType.isClassOrInterface());

reflection.defaultValue = declaration && (0, convert_expression_1.convertDefaultValue)(declaration);
reflection.type = context.converter.convertType(context.withScope(reflection), (context.isConvertingTypeNode() ? parameterType : void 0) ??
reflection.type = context.converter.convertType(context.withScope(reflection), (context.convertingTypeNode ? parameterType : void 0) ??
context.checker.getTypeOfSymbol(symbol));

@@ -436,2 +464,5 @@ if (reflection.flags.isOptional) {

}
if (symbol.getJsDocTags().some((tag) => tag.name === "namespace")) {
return convertVariableAsNamespace(context, symbol, exportSymbol);
}
if (type.getCallSignatures().length) {

@@ -479,2 +510,11 @@ return convertVariableAsFunction(context, symbol, exportSymbol);

}
function convertVariableAsNamespace(context, symbol, exportSymbol) {
const reflection = context.createDeclarationReflection(models_1.ReflectionKind.Namespace, symbol, exportSymbol);
context.finalizeDeclarationReflection(reflection);
const rc = context.withScope(reflection);
const declaration = symbol.declarations[0];
const type = context.checker.getTypeAtLocation(declaration);
convertSymbols(rc, type.getProperties());
return typescript_1.default.SymbolFlags.Property;
}
function convertVariableAsFunction(context, symbol, exportSymbol) {

@@ -481,0 +521,0 @@ const declaration = symbol

@@ -146,3 +146,3 @@ "use strict";

const rc = context.withScope(reflection);
rc.setConvertingTypeNode();
rc.convertingTypeNode = true;
context.registerReflection(reflection, symbol);

@@ -350,3 +350,3 @@ context.trigger(converter_events_1.ConverterEvents.CREATE_DECLARATION, reflection);

const rc = context.withScope(reflection);
rc.setConvertingTypeNode();
rc.convertingTypeNode = true;
context.registerReflection(reflection, symbol);

@@ -353,0 +353,0 @@ context.trigger(converter_events_1.ConverterEvents.CREATE_DECLARATION, reflection);

@@ -135,5 +135,8 @@ import type { Application } from "../application";

/** @internal */
cacheBust: boolean;
/** @internal */
lightTheme: ShikiTheme;
/** @internal */
darkTheme: ShikiTheme;
renderStartTime: number;
/**

@@ -140,0 +143,0 @@ * Define a new theme that can be used to render output.

@@ -120,2 +120,3 @@ "use strict";

this.hooks = new utils_1.EventHooks();
this.renderStartTime = -1;
}

@@ -143,5 +144,5 @@ /**

const momento = this.hooks.saveMomento();
const start = Date.now();
this.renderStartTime = Date.now();
await (0, highlighter_1.loadHighlighter)(this.lightTheme, this.darkTheme);
this.application.logger.verbose(`Renderer: Loading highlighter took ${Date.now() - start}ms`);
this.application.logger.verbose(`Renderer: Loading highlighter took ${Date.now() - this.renderStartTime}ms`);
if (!this.prepareTheme() ||

@@ -292,2 +293,5 @@ !(await this.prepareOutputDirectory(outputDirectory))) {

__decorate([
(0, utils_1.BindOption)("cacheBust")
], Renderer.prototype, "cacheBust", void 0);
__decorate([
(0, utils_1.BindOption)("lightHighlightTheme")

@@ -294,0 +298,0 @@ ], Renderer.prototype, "lightTheme", void 0);

@@ -12,3 +12,3 @@ import type { RendererHooks } from "../..";

/** Avoid this in favor of urlTo if possible */
relativeURL: (url: string | undefined) => string | undefined;
relativeURL: (url: string, cacheBust?: boolean) => string;
urlTo: (reflection: Reflection) => string;

@@ -15,0 +15,0 @@ markdown: (md: readonly CommentDisplayPart[] | NeverIfInternal<string | undefined>) => string;

@@ -41,6 +41,12 @@ "use strict";

/** Avoid this in favor of urlTo if possible */
this.relativeURL = (url) => {
return url ? this.theme.markedPlugin.getRelativeUrl(url) : url;
this.relativeURL = (url, cacheBust = false) => {
const result = this.theme.markedPlugin.getRelativeUrl(url);
if (cacheBust && this.theme.owner.cacheBust) {
return result + `?cache=${this.theme.owner.renderStartTime}`;
}
return result;
};
this.urlTo = (reflection) => this.relativeURL(reflection.url);
this.urlTo = (reflection) => {
return reflection.url ? this.relativeURL(reflection.url) : "";
};
this.markdown = (md) => {

@@ -47,0 +53,0 @@ if (md instanceof Array) {

@@ -15,6 +15,6 @@ "use strict";

utils_1.JSX.createElement("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }),
utils_1.JSX.createElement("link", { rel: "stylesheet", href: context.relativeURL("assets/style.css") }),
utils_1.JSX.createElement("link", { rel: "stylesheet", href: context.relativeURL("assets/highlight.css") }),
context.options.getValue("customCss") && (utils_1.JSX.createElement("link", { rel: "stylesheet", href: context.relativeURL("assets/custom.css") })),
utils_1.JSX.createElement("script", { async: true, src: context.relativeURL("assets/search.js"), id: "search-script" }),
utils_1.JSX.createElement("link", { rel: "stylesheet", href: context.relativeURL("assets/style.css", true) }),
utils_1.JSX.createElement("link", { rel: "stylesheet", href: context.relativeURL("assets/highlight.css", true) }),
context.options.getValue("customCss") && (utils_1.JSX.createElement("link", { rel: "stylesheet", href: context.relativeURL("assets/custom.css", true) })),
utils_1.JSX.createElement("script", { async: true, src: context.relativeURL("assets/search.js", true), id: "search-script" }),
context.hook("head.end")),

@@ -38,5 +38,5 @@ utils_1.JSX.createElement("body", null,

utils_1.JSX.createElement("div", { class: "overlay" }),
utils_1.JSX.createElement("script", { src: context.relativeURL("assets/main.js") }),
utils_1.JSX.createElement("script", { src: context.relativeURL("assets/main.js", true) }),
context.analytics(),
context.hook("body.end"))));
exports.defaultLayout = defaultLayout;

@@ -96,2 +96,3 @@ import type { Theme as ShikiTheme } from "shiki";

hideGenerator: boolean;
cacheBust: boolean;
searchInComments: boolean;

@@ -98,0 +99,0 @@ cleanOutputDir: boolean;

@@ -351,2 +351,7 @@ "use strict";

options.addDeclaration({
name: "cacheBust",
help: "Include the generation time in links to static assets.",
type: declaration_1.ParameterType.Boolean,
});
options.addDeclaration({
name: "searchInComments",

@@ -353,0 +358,0 @@ help: "If set, the search index will also include comments. This will greatly increase the size of the search index.",

@@ -6,2 +6,2 @@ export declare const tsdocBlockTags: readonly ["@deprecated", "@param", "@remarks", "@returns", "@throws", "@privateRemarks", "@defaultValue", "@typeParam"];

export declare const tsdocModifierTags: readonly ["@public", "@private", "@protected", "@internal", "@readonly", "@packageDocumentation", "@eventProperty", "@alpha", "@beta", "@experimental", "@sealed", "@override", "@virtual"];
export declare const modifierTags: readonly ["@public", "@private", "@protected", "@internal", "@readonly", "@packageDocumentation", "@eventProperty", "@alpha", "@beta", "@experimental", "@sealed", "@override", "@virtual", "@hidden", "@ignore", "@enum", "@event", "@overload"];
export declare const modifierTags: readonly ["@public", "@private", "@protected", "@internal", "@readonly", "@packageDocumentation", "@eventProperty", "@alpha", "@beta", "@experimental", "@sealed", "@override", "@virtual", "@hidden", "@ignore", "@enum", "@event", "@overload", "@namespace", "@interface"];

@@ -55,2 +55,4 @@ "use strict";

"@overload",
"@namespace",
"@interface",
];
{
"name": "typedoc",
"description": "Create api documentation for TypeScript projects.",
"version": "0.24.0-beta.4",
"version": "0.24.0-beta.5",
"homepage": "https://typedoc.org",

@@ -6,0 +6,0 @@ "exports": {

@@ -85,4 +85,12 @@ {

"syntaxKind": "modifier"
},
{
"tagName": "@namespace",
"syntaxKind": "modifier"
},
{
"tagName": "@interface",
"syntaxKind": "modifier"
}
]
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc