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.23.9 to 0.23.10

dist/lib/converter/comments/linkResolver.d.ts

2

dist/lib/converter/comments/discovery.js

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

ts.SyntaxKind.PropertyAssignment,
// class X { constructor(/** Comment */ readonly z: any) }
ts.SyntaxKind.Parameter,
],

@@ -59,0 +61,0 @@ [models_1.ReflectionKind.Method]: [

@@ -11,2 +11,9 @@ "use strict";

const parser_1 = require("./parser");
const jsDocCommentKinds = [
ts.SyntaxKind.JSDocPropertyTag,
ts.SyntaxKind.JSDocCallbackTag,
ts.SyntaxKind.JSDocTypedefTag,
ts.SyntaxKind.JSDocTemplateTag,
ts.SyntaxKind.JSDocEnumTag,
];
const commentCache = new WeakMap();

@@ -56,2 +63,7 @@ function getCommentWithCache(discovered, config, logger) {

function getComment(symbol, kind, config, logger, commentStyle) {
if (symbol
.getDeclarations()
?.every((d) => jsDocCommentKinds.includes(d.kind))) {
return getJsDocComment(symbol.declarations[0], config, logger);
}
return getCommentImpl((0, discovery_1.discoverComment)(symbol, kind, logger, commentStyle), config, logger, symbol.declarations?.some(ts.isSourceFile) || false);

@@ -111,5 +123,5 @@ }

else {
return new models_1.Comment(tag.content.slice());
return new models_1.Comment(models_1.Comment.cloneDisplayParts(tag.content));
}
}
exports.getJsDocComment = getJsDocComment;

10

dist/lib/converter/converter.d.ts
import * as ts from "typescript";
import type { Application } from "../application";
import { ProjectReflection, SomeType } from "../models/index";
import { Comment, CommentDisplayPart, ProjectReflection, Reflection, SomeType } from "../models/index";
import { Context } from "./context";

@@ -10,3 +10,3 @@ import { ConverterComponent } from "./components";

import { CommentParserConfig } from "./comments";
import type { CommentStyle } from "../utils/options/declaration";
import type { CommentStyle, ValidationOptions } from "../utils/options/declaration";
/**

@@ -28,2 +28,4 @@ * Compiles source files using TypeScript and converts compiler symbols to reflections.

commentStyle: CommentStyle;
/** @internal */
validation: ValidationOptions;
private _config?;

@@ -113,3 +115,5 @@ get config(): CommentParserConfig;

*/
parseRawComment(file: MinimalSourceFile): import("../models/index").Comment;
parseRawComment(file: MinimalSourceFile): Comment;
resolveLinks(comment: Comment, owner: Reflection): void;
resolveLinks(parts: readonly CommentDisplayPart[], owner: Reflection): CommentDisplayPart[];
/**

@@ -116,0 +120,0 @@ * Compile the files within the given context and convert the compiler symbols to reflections.

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

const rawLexer_1 = require("./comments/rawLexer");
const linkResolver_1 = require("./comments/linkResolver");
/**

@@ -70,2 +71,17 @@ * Compiles source files using TypeScript and converts compiler symbols to reflections.

}
resolveLinks(comment, owner) {
if (comment instanceof index_1.Comment) {
(0, linkResolver_1.resolveLinks)(comment, owner, this.validation, this.owner.logger);
}
else {
let warned = false;
const warn = () => {
if (!warned) {
warned = true;
this.application.logger.warn(`${owner.name}: Comment [[target]] style links are deprecated and will be removed in 0.24`);
}
};
return (0, linkResolver_1.resolvePartLinks)(owner, comment, warn, this.validation, this.owner.logger);
}
}
/**

@@ -272,2 +288,5 @@ * Compile the files within the given context and convert the compiler symbols to reflections.

], Converter.prototype, "commentStyle", void 0);
__decorate([
(0, utils_1.BindOption)("validation")
], Converter.prototype, "validation", void 0);
Converter = Converter_1 = __decorate([

@@ -274,0 +293,0 @@ (0, component_1.Component)({

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

}
paramRefl.comment || (paramRefl.comment = (0, comments_1.getComment)(param, paramRefl.kind, context.converter.config, context.logger, context.converter.commentStyle));
context.registerReflection(paramRefl, param);

@@ -67,0 +68,0 @@ context.trigger(converter_events_1.ConverterEvents.CREATE_PARAMETER, paramRefl);

@@ -1,2 +0,1 @@

import type { Reflection } from "../../models/reflections/abstract";
import { ConverterComponent } from "../components";

@@ -14,23 +13,3 @@ import type { Context } from "../../converter";

initialize(): void;
/**
* Find all old style double bracket references to symbols within the given text and transform them into a link.
*
* @param text The text that should be parsed.
* @returns The text with symbol references replaced by links.
*/
private replaceBrackets;
onResolve(context: Context): void;
processReflection(reflection: Reflection): void;
private processParts;
private processPart;
/**
* Split the given link into text and target at first pipe or space.
*
* @param text The source string that should be checked for a split character.
* @returns An object containing the link text and target.
*/
static splitLinkText(text: string): {
caption: string;
target: string;
};
}

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

};
var LinkResolverPlugin_1;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -14,13 +13,7 @@ exports.LinkResolverPlugin = void 0;

const converter_events_1 = require("../converter-events");
const declarationReference_1 = require("../comments/declarationReference");
const ts = require("typescript");
const utils_1 = require("../../utils");
const declarationReferenceResolver_1 = require("../comments/declarationReferenceResolver");
const models_1 = require("../../models");
const urlPrefix = /^(http|ftp)s?:\/\//;
const brackets = /\[\[(?!include:)([^\]]+)\]\]/g;
/**
* A plugin that resolves `{@link Foo}` tags.
*/
let LinkResolverPlugin = LinkResolverPlugin_1 = class LinkResolverPlugin extends components_1.ConverterComponent {
let LinkResolverPlugin = class LinkResolverPlugin extends components_1.ConverterComponent {
/**

@@ -33,140 +26,12 @@ * Create a new LinkResolverPlugin instance.

}
/**
* Find all old style double bracket references to symbols within the given text and transform them into a link.
*
* @param text The text that should be parsed.
* @returns The text with symbol references replaced by links.
*/
replaceBrackets(reflection, text) {
const parts = [];
let begin = 0;
brackets.lastIndex = 0;
for (const match of text.matchAll(brackets)) {
if (begin != match.index) {
parts.push({
kind: "text",
text: text.substring(begin, match.index),
});
}
begin = match.index + match[0].length;
const content = match[1];
const { target, caption } = LinkResolverPlugin_1.splitLinkText(content);
if (urlPrefix.test(target)) {
parts.push({
kind: "inline-tag",
tag: "@link",
text: caption,
target,
});
}
else {
const targetRefl = reflection.findReflectionByName(target);
if (targetRefl) {
parts.push({
kind: "inline-tag",
tag: "@link",
text: caption,
target: targetRefl,
});
}
else {
if (this.validation.invalidLink) {
this.application.logger.warn("Failed to find target: " + content);
}
parts.push({
kind: "inline-tag",
tag: "@link",
text: content,
});
}
}
}
parts.push({
kind: "text",
text: text.substring(begin),
});
return parts;
}
onResolve(context) {
for (const reflection of Object.values(context.project.reflections)) {
this.processReflection(reflection);
if (reflection.comment) {
context.converter.resolveLinks(reflection.comment, reflection);
}
}
let warned = false;
const warn = () => {
if (!warned) {
warned = true;
this.application.logger.warn(`README: Comment [[target]] style links are deprecated and will be removed in 0.24`);
}
};
if (context.project.readme) {
context.project.readme = this.processParts(context.project, context.project.readme, warn);
context.project.readme = context.converter.resolveLinks(context.project.readme, context.project);
}
}
processReflection(reflection) {
const comment = reflection.comment;
if (!comment)
return;
let warned = false;
const warn = () => {
if (!warned) {
warned = true;
this.application.logger.warn(`${reflection.getFriendlyFullName()}: Comment [[target]] style links are deprecated and will be removed in 0.24`);
}
};
comment.summary = this.processParts(reflection, comment.summary, warn);
for (const tag of comment.blockTags) {
tag.content = this.processParts(reflection, tag.content, warn);
}
if (reflection instanceof models_1.DeclarationReflection && reflection.readme) {
reflection.readme = this.processParts(reflection, reflection.readme, warn);
}
}
processParts(reflection, parts, warn) {
return parts.flatMap((part) => this.processPart(reflection, part, warn));
}
processPart(reflection, part, warn) {
if (part.kind === "text" && brackets.test(part.text)) {
warn();
return this.replaceBrackets(reflection, part.text);
}
if (part.kind === "inline-tag") {
if (part.tag === "@link" ||
part.tag === "@linkcode" ||
part.tag === "@linkplain") {
return resolveLinkTag(reflection, part, (msg) => {
if (this.validation.invalidLink) {
this.application.logger.warn(msg);
}
});
}
}
return part;
}
/**
* Split the given link into text and target at first pipe or space.
*
* @param text The source string that should be checked for a split character.
* @returns An object containing the link text and target.
*/
static splitLinkText(text) {
let splitIndex = text.indexOf("|");
if (splitIndex === -1) {
splitIndex = text.search(/\s/);
}
if (splitIndex !== -1) {
return {
caption: text
.substring(splitIndex + 1)
.replace(/\n+/, " ")
.trim(),
target: text.substring(0, splitIndex).trim(),
};
}
else {
return {
caption: text,
target: text,
};
}
}
};

@@ -176,66 +41,5 @@ __decorate([

], LinkResolverPlugin.prototype, "validation", void 0);
LinkResolverPlugin = LinkResolverPlugin_1 = __decorate([
LinkResolverPlugin = __decorate([
(0, components_1.Component)({ name: "link-resolver" })
], LinkResolverPlugin);
exports.LinkResolverPlugin = LinkResolverPlugin;
function resolveLinkTag(reflection, part, warn) {
let pos = 0;
const end = part.text.length;
while (pos < end && ts.isWhiteSpaceLike(part.text.charCodeAt(pos))) {
pos++;
}
const origText = part.text;
// Try to parse one
const declRef = (0, declarationReference_1.parseDeclarationReference)(part.text, pos, end);
let target;
if (declRef) {
// Got one, great! Try to resolve the link
target = (0, declarationReferenceResolver_1.resolveDeclarationReference)(reflection, declRef[0]);
pos = declRef[1];
}
if (!target) {
if (urlPrefix.test(part.text)) {
const wsIndex = part.text.search(/\s/);
target =
wsIndex === -1 ? part.text : part.text.substring(0, wsIndex);
pos = target.length;
}
}
// If resolution via a declaration reference failed, revert to the legacy "split and check"
// method... this should go away in 0.24, once people have had a chance to migrate any failing links.
if (!target) {
const resolved = legacyResolveLinkTag(reflection, part);
if (resolved) {
warn(`Failed to resolve {@link ${origText}} in ${reflection.getFriendlyFullName()} with declaration references. This link will break in v0.24.`);
}
return resolved;
}
// Remaining text after an optional pipe is the link text, so advance
// until that's consumed.
while (pos < end && ts.isWhiteSpaceLike(part.text.charCodeAt(pos))) {
pos++;
}
if (pos < end && part.text[pos] === "|") {
pos++;
}
part.target = target;
part.text =
part.text.substring(pos).trim() ||
(typeof target === "string" ? target : target.name);
return part;
}
function legacyResolveLinkTag(reflection, part) {
const { caption, target } = LinkResolverPlugin.splitLinkText(part.text);
if (urlPrefix.test(target)) {
part.text = caption;
part.target = target;
}
else {
const targetRefl = reflection.findReflectionByName(target);
if (targetRefl) {
part.text = caption;
part.target = targetRefl;
}
}
return part;
}

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

return ref;
let startIndex = symbolPath.indexOf("node_modules/");
let startIndex = symbolPath.lastIndexOf("node_modules/");
if (startIndex === -1)

@@ -677,0 +677,0 @@ return ref;

import type { RendererHooks } from "../..";
import type { ReferenceType, Reflection } from "../../../models";
import type { Options } from "../../../utils";
import type { CommentDisplayPart, ReferenceType, Reflection } from "../../../models";
import type { NeverIfInternal, Options } from "../../../utils";
import type { DefaultTheme } from "./DefaultTheme";

@@ -14,3 +14,3 @@ export declare class DefaultThemeRenderContext {

urlTo: (reflection: Reflection) => string | undefined;
markdown: (md: string | undefined) => string;
markdown: (md: readonly CommentDisplayPart[] | NeverIfInternal<string | undefined>) => string;
attemptExternalResolution: (type: ReferenceType) => string | undefined;

@@ -17,0 +17,0 @@ reflectionTemplate: (props: import("../..").PageEvent<import("../../../models").ContainerReflection>) => import("../../../utils/jsx.elements").JsxElement;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultThemeRenderContext = void 0;
const lib_1 = require("../lib");
const default_1 = require("./layouts/default");

@@ -45,2 +46,5 @@ const partials_1 = require("./partials");

this.markdown = (md) => {
if (md instanceof Array) {
return this.theme.markedPlugin.parseMarkdown((0, lib_1.displayPartsToMarkdown)(md, this.urlTo));
}
return md ? this.theme.markedPlugin.parseMarkdown(md) : "";

@@ -47,0 +51,0 @@ };

import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
import { JSX } from "../../../../utils";
import type { Reflection } from "../../../../models";
export declare function comment({ markdown, urlTo }: DefaultThemeRenderContext, props: Reflection): JSX.Element | undefined;
export declare function comment({ markdown }: DefaultThemeRenderContext, props: Reflection): JSX.Element | undefined;

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

const lib_1 = require("../../lib");
function comment({ markdown, urlTo }, props) {
function comment({ markdown }, props) {
if (!props.comment?.hasVisibleComponent())

@@ -12,7 +12,7 @@ return;

return (utils_1.JSX.createElement("div", { class: "tsd-comment tsd-typography" },
utils_1.JSX.createElement(utils_1.Raw, { html: markdown((0, lib_1.displayPartsToMarkdown)(props.comment.summary, urlTo)) }),
utils_1.JSX.createElement(utils_1.Raw, { html: markdown(props.comment.summary) }),
props.comment.blockTags.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
utils_1.JSX.createElement("h3", null, (0, lib_1.camelToTitleCase)(item.tag.substring(1))),
utils_1.JSX.createElement(utils_1.Raw, { html: markdown((0, lib_1.displayPartsToMarkdown)(item.content, urlTo)) }))))));
utils_1.JSX.createElement(utils_1.Raw, { html: markdown(item.content) }))))));
}
exports.comment = comment;

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

icons[item.kind](),
utils_1.JSX.createElement("span", null, item.name ? (0, lib_1.wbr)(item.name) : utils_1.JSX.createElement("em", null, (0, lib_1.wbr)(item.kindString)))),
utils_1.JSX.createElement("span", null, (0, lib_1.renderName)(item))),
"\n"))))));

@@ -46,3 +46,3 @@ }

utils_1.JSX.createElement("section", { class: "tsd-panel tsd-typography" },
utils_1.JSX.createElement(utils_1.Raw, { html: context.markdown((0, lib_1.displayPartsToMarkdown)(props.readme || [], context.urlTo)) })))),
utils_1.JSX.createElement(utils_1.Raw, { html: context.markdown(props.readme || []) })))),
utils_1.JSX.createElement("section", { class: "tsd-panel-group tsd-index-group" },

@@ -49,0 +49,0 @@ utils_1.JSX.createElement("section", { class: "tsd-panel tsd-index-panel" }, content))));

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

context.icons[child.kind](),
(0, lib_1.wbr)(child.name))));
(0, lib_1.renderName)(child))));
});

@@ -120,3 +120,3 @@ if (effectivePageParent.kindOf(models_1.ReflectionKind.SomeModule | models_1.ReflectionKind.Project)) {

context.icons[effectivePageParent.kind](),
utils_1.JSX.createElement("span", null, (0, lib_1.wbr)(effectivePageParent.name))),
utils_1.JSX.createElement("span", null, (0, lib_1.renderName)(effectivePageParent))),
!!pageNavigation.length && utils_1.JSX.createElement("ul", null, pageNavigation)))));

@@ -123,0 +123,0 @@ }

@@ -5,2 +5,2 @@ import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";

import { JSX } from "../../../../utils";
export declare const indexTemplate: ({ markdown, urlTo }: DefaultThemeRenderContext, props: PageEvent<ProjectReflection>) => JSX.Element;
export declare const indexTemplate: ({ markdown }: DefaultThemeRenderContext, props: PageEvent<ProjectReflection>) => JSX.Element;

@@ -5,5 +5,4 @@ "use strict";

const utils_1 = require("../../../../utils");
const lib_1 = require("../../lib");
const indexTemplate = ({ markdown, urlTo }, props) => (utils_1.JSX.createElement("div", { class: "tsd-panel tsd-typography" },
utils_1.JSX.createElement(utils_1.Raw, { html: markdown((0, lib_1.displayPartsToMarkdown)(props.model.readme || [], urlTo)) })));
const indexTemplate = ({ markdown }, props) => (utils_1.JSX.createElement("div", { class: "tsd-panel tsd-typography" },
utils_1.JSX.createElement(utils_1.Raw, { html: markdown(props.model.readme || []) })));
exports.indexTemplate = indexTemplate;

@@ -22,2 +22,6 @@ import { Comment, CommentDisplayPart, Reflection, ReflectionFlags, TypeParameterReflection } from "../../models";

export declare function camelToTitleCase(text: string): string;
export declare function displayPartsToMarkdown(parts: CommentDisplayPart[], urlTo: DefaultThemeRenderContext["urlTo"]): string;
export declare function displayPartsToMarkdown(parts: readonly CommentDisplayPart[], urlTo: DefaultThemeRenderContext["urlTo"]): string;
/**
* Renders the reflection name with an additional `?` if optional.
*/
export declare function renderName(refl: Reflection): JSX.Element | (string | JSX.Element)[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.displayPartsToMarkdown = exports.camelToTitleCase = exports.renderTypeParametersSignature = exports.hasTypeParameters = exports.classNames = exports.renderFlags = exports.join = exports.wbr = exports.stringify = void 0;
exports.renderName = exports.displayPartsToMarkdown = exports.camelToTitleCase = exports.renderTypeParametersSignature = exports.hasTypeParameters = exports.classNames = exports.renderFlags = exports.join = exports.wbr = exports.stringify = void 0;
const models_1 = require("../../models");

@@ -125,1 +125,16 @@ const utils_1 = require("../../utils");

exports.displayPartsToMarkdown = displayPartsToMarkdown;
/**
* Renders the reflection name with an additional `?` if optional.
*/
function renderName(refl) {
if (!refl.name) {
return utils_1.JSX.createElement("em", null, wbr(refl.kindString));
}
if (refl.flags.isOptional) {
return utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
wbr(refl.name),
"?");
}
return wbr(refl.name);
}
exports.renderName = renderName;
{
"name": "typedoc",
"description": "Create api documentation for TypeScript projects.",
"version": "0.23.9",
"version": "0.23.10",
"homepage": "https://typedoc.org",

@@ -28,3 +28,3 @@ "main": "./dist/index.js",

"lunr": "^2.3.9",
"marked": "^4.0.16",
"marked": "^4.0.18",
"minimatch": "^5.1.0",

@@ -41,18 +41,17 @@ "shiki": "^0.10.1"

"@types/mocha": "^9.1.1",
"@types/node": "^17.0.35",
"@typescript-eslint/eslint-plugin": "^5.26.0",
"@typescript-eslint/parser": "^5.26.0",
"@types/node": "^18.6.3",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"@typestrong/fs-fixture-builder": "github:TypeStrong/fs-fixture-builder#b88cd06fe814614a0d924af9d10d04ff95a551de",
"c8": "^7.11.3",
"c8": "^7.12.0",
"esbuild": "^0.14.39",
"eslint": "^8.16.0",
"mocha": "^9.2.1",
"prettier": "2.6.2",
"eslint": "^8.20.0",
"mocha": "^10.0.0",
"prettier": "2.7.1",
"puppeteer": "^13.5.2",
"reg-notify-github-plugin": "^0.11.1",
"reg-suit": "^0.11.1",
"reg-suit-core": "^0.11.1",
"reg-suit-interface": "^0.11.0",
"ts-node": "^10.8.0",
"typescript": "^4.7.2"
"reg-suit": "^0.12.1",
"reg-suit-core": "^0.12.1",
"reg-suit-interface": "^0.12.0",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
},

@@ -59,0 +58,0 @@ "files": [

{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/tsdoc/v0/tsdoc.schema.json",
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"noStandardTags": false,

@@ -4,0 +4,0 @@ "tagDefinitions": [

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