Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typedoc-plugin-markdown

Package Overview
Dependencies
Maintainers
1
Versions
252
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typedoc-plugin-markdown - npm Package Compare versions

Comparing version 4.0.0-next.19 to 4.0.0-next.20

5

dist/plugin/options/config.d.ts

@@ -128,6 +128,2 @@ import { DeclarationOption } from 'typedoc';

/**
* @category ui
*/
export declare const hideHierarchy: DeclarationOption;
/**
* Note if `true` references will not be linked.

@@ -171,1 +167,2 @@ *

export declare const anchorPrefix: DeclarationOption;
export declare const namedAnchors: DeclarationOption;

17

dist/plugin/options/config.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.anchorPrefix = exports.preserveAnchorCasing = exports.titleTemplate = exports.tocFormat = exports.typeDeclarationFormat = exports.enumMembersFormat = exports.propertiesFormat = exports.identifiersAsCodeBlocks = exports.hideHierarchy = exports.hideInPageTOC = exports.hideBreadcrumbs = exports.hidePageTitle = exports.hidePageHeader = exports.excludeGroups = exports.skipIndexPage = exports.indexPageTitle = exports.indexFileName = exports.entryFileName = exports.flattenOutputFiles = exports.includeFileNumberPrefixes = exports.outputFileStrategy = void 0;
exports.namedAnchors = exports.anchorPrefix = exports.preserveAnchorCasing = exports.titleTemplate = exports.tocFormat = exports.typeDeclarationFormat = exports.enumMembersFormat = exports.propertiesFormat = exports.identifiersAsCodeBlocks = exports.hideInPageTOC = exports.hideBreadcrumbs = exports.hidePageTitle = exports.hidePageHeader = exports.excludeGroups = exports.skipIndexPage = exports.indexPageTitle = exports.indexFileName = exports.entryFileName = exports.flattenOutputFiles = exports.includeFileNumberPrefixes = exports.outputFileStrategy = void 0;
const typedoc_1 = require("typedoc");

@@ -193,11 +193,2 @@ const custom_maps_1 = require("./custom-maps");

/**
* @category ui
*/
exports.hideHierarchy = {
name: 'hideHierarchy',
help: 'Do not print reflection hierarchy.',
type: typedoc_1.ParameterType.Boolean,
defaultValue: false,
};
/**
* Note if `true` references will not be linked.

@@ -285,1 +276,7 @@ *

};
exports.namedAnchors = {
name: 'namedAnchors',
help: 'Use HTML named anchors for item anchor references.',
type: typedoc_1.ParameterType.Boolean,
defaultValue: false,
};

@@ -15,3 +15,2 @@ declare module 'typedoc' {

hideInPageTOC: boolean;
hideHierarchy: boolean;
identifiersAsCodeBlocks: boolean;

@@ -25,2 +24,3 @@ propertiesFormat: 'list' | 'table';

anchorPrefix: string;
namedAnchors: boolean;
}

@@ -41,3 +41,2 @@ }

hideInPageTOC: boolean;
hideHierarchy: boolean;
identifiersAsCodeBlocks: boolean;

@@ -51,2 +50,3 @@ propertiesFormat: 'list' | 'table';

anchorPrefix: string;
namedAnchors: boolean;
}

@@ -12,1 +12,2 @@ /**

export declare function hasTOC(reflection: DeclarationReflection, options: Options): boolean;
export declare function getModifier(reflection: DeclarationReflection): "get" | "Abstract" | "Private" | "Readonly" | "Static" | "set" | null;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.hasTOC = exports.hasIndex = exports.getProjectDisplayName = exports.getDeclarationType = void 0;
exports.getModifier = exports.hasTOC = exports.hasIndex = exports.getProjectDisplayName = exports.getDeclarationType = void 0;
const typedoc_1 = require("typedoc");

@@ -39,1 +39,23 @@ function getDeclarationType(declaration) {

exports.hasTOC = hasTOC;
function getModifier(reflection) {
if (reflection.flags.isAbstract) {
return 'Abstract';
}
if (reflection.flags.isPrivate) {
return 'Private';
}
if (reflection.flags.isReadonly) {
return 'Readonly';
}
if (reflection.flags.isStatic) {
return 'Static';
}
if (reflection.getSignature) {
return 'get';
}
if (reflection.setSignature) {
return 'set';
}
return null;
}
exports.getModifier = getModifier;

@@ -14,5 +14,10 @@ "use strict";

const md = [];
const useCodeBlocks = context.options.getValue('identifiersAsCodeBlocks');
const declarationType = (0, helpers_1.getDeclarationType)(reflection);
if (((_a = reflection.flags) === null || _a === void 0 ? void 0 : _a.length) && !reflection.flags.isRest) {
md.push(reflection.flags.map((flag) => (0, elements_1.backTicks)(flag.toLowerCase())).join(' '));
if (((_a = reflection.flags) === null || _a === void 0 ? void 0 : _a.length) &&
!reflection.flags.isRest &&
!reflection.flags.isOptional) {
md.push(reflection.flags
.map((flag) => (0, elements_1.bold)((0, elements_1.backTicks)(flag.toLowerCase())))
.join(' '));
}

@@ -34,2 +39,5 @@ if (reflection.kindOf(typedoc_1.ReflectionKind.Variable) && !reflection.flags.isConst) {

}
if (reflection.flags.isOptional) {
name.push('?');
}
if (declarationType) {

@@ -43,3 +51,3 @@ name.push(':');

if (declarationType) {
md.push(`${context.someType(declarationType, true)}`);
md.push(`${context.someType(declarationType, !useCodeBlocks)}`);
}

@@ -46,0 +54,0 @@ if (reflection.defaultValue && reflection.defaultValue !== '...') {

@@ -12,8 +12,9 @@ "use strict";

const md = [];
const useCodeBlocks = context.options.getValue('identifiersAsCodeBlocks');
const typeDeclaration = (_a = declaration.type) === null || _a === void 0 ? void 0 : _a.declaration;
if (context.options.getValue('identifiersAsCodeBlocks')) {
if (useCodeBlocks) {
md.push((0, elements_1.codeBlock)(context.declarationMemberIdentifier(declaration)));
}
else {
md.push('> ' + context.declarationMemberIdentifier(declaration));
md.push(`${!nested ? '> ' : ''}${context.declarationMemberIdentifier(declaration)}`);
}

@@ -47,14 +48,16 @@ if (declaration.comment) {

}
if ((_h = typeDeclaration === null || typeDeclaration === void 0 ? void 0 : typeDeclaration.children) === null || _h === void 0 ? void 0 : _h.length) {
md.push((0, elements_1.heading)(headingLevel, 'Type declaration'));
md.push(context.typeDeclarationMember(typeDeclaration, headingLevel + 1, hasParent ? declaration.name : undefined));
if (((_h = typeDeclaration === null || typeDeclaration === void 0 ? void 0 : typeDeclaration.children) === null || _h === void 0 ? void 0 : _h.length) && !useCodeBlocks) {
if (!nested) {
md.push((0, elements_1.heading)(headingLevel, 'Type declaration'));
}
md.push(context.typeDeclarationMember(typeDeclaration, nested ? headingLevel : headingLevel + 1, hasParent ? declaration.name : undefined));
}
}
}
md.push(context.inheritance(declaration, headingLevel));
if (!nested && declaration.sources) {
md.push(context.sources(declaration, headingLevel));
}
md.push(context.inheritance(declaration, headingLevel));
return md.join('\n\n');
}
exports.declarationMember = declarationMember;

@@ -10,11 +10,17 @@ "use strict";

if (reflection.implementationOf) {
md.push((0, elements_1.heading)(headingLevel, 'Implementation of'));
if (headingLevel !== -1) {
md.push((0, elements_1.heading)(headingLevel, 'Implementation of'));
}
md.push(typeAndParent(context, reflection.implementationOf));
}
if (reflection.inheritedFrom) {
md.push((0, elements_1.heading)(headingLevel, 'Inherited from'));
if (headingLevel !== -1) {
md.push((0, elements_1.heading)(headingLevel, 'Inherited from'));
}
md.push(typeAndParent(context, reflection.inheritedFrom));
}
if (reflection.overwrites) {
md.push((0, elements_1.heading)(headingLevel, 'Overrides'));
if (headingLevel !== -1) {
md.push((0, elements_1.heading)(headingLevel, 'Overrides'));
}
md.push(typeAndParent(context, reflection.overwrites));

@@ -27,3 +33,3 @@ }

var _a, _b, _c;
const getUrl = (name, url) => (0, elements_1.link)((0, elements_1.backTicks)(name), context.relativeURL(url));
const getLink = (name, url) => (0, elements_1.link)((0, elements_1.backTicks)(name), context.relativeURL(url));
if (props) {

@@ -38,5 +44,5 @@ if ('elementType' in props) {

if ((_b = (_a = props.reflection.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.url) {
md.push(getUrl(props.reflection.parent.parent.name, props.reflection.parent.parent.url));
if (props.reflection.parent.url) {
md.push(getUrl(props.reflection.parent.name, props.reflection.parent.url));
md.push(getLink(props.reflection.parent.parent.name, props.reflection.parent.parent.url));
if ((_c = props.reflection.parent) === null || _c === void 0 ? void 0 : _c.url) {
md.push(getLink(props.reflection.parent.name, props.reflection.parent.url));
}

@@ -46,7 +52,17 @@ }

else {
if ((_c = props.reflection.parent) === null || _c === void 0 ? void 0 : _c.url) {
md.push(getUrl(props.reflection.parent.name, props.reflection.parent.url));
if (props.reflection.url) {
md.push(getUrl(props.reflection.name, props.reflection.url));
if (props.reflection.parent) {
if (props.reflection.parent.url) {
md.push(getLink(props.reflection.parent.name, props.reflection.parent.url));
}
else {
md.push((0, elements_1.backTicks)(props.reflection.parent.name));
}
if (props.reflection) {
if (props.reflection.url) {
md.push(getLink(props.reflection.name, props.reflection.url));
}
else {
md.push((0, elements_1.backTicks)(props.reflection.name));
}
}
}

@@ -53,0 +69,0 @@ }

@@ -11,26 +11,36 @@ "use strict";

const md = [];
if (context.options.getValue('namedAnchors')) {
md.push(`<a id="${reflection.anchor}" name="${reflection.anchor}"></a>`);
}
if (!reflection.hasOwnDocument) {
md.push((0, elements_1.heading)(headingLevel, context.memberTitle(reflection)));
}
if ([
typedoc_1.ReflectionKind.Class,
typedoc_1.ReflectionKind.Interface,
typedoc_1.ReflectionKind.Enum,
].includes(reflection.kind)) {
md.push(context.reflectionMember(reflection, headingLevel + 1));
}
else {
const getMember = (reflection) => {
var _a;
if (reflection.kindOf([
typedoc_1.ReflectionKind.Class,
typedoc_1.ReflectionKind.Interface,
typedoc_1.ReflectionKind.Enum,
])) {
return context.reflectionMember(reflection, headingLevel + 1);
}
if (reflection.signatures) {
reflection.signatures.forEach((signature) => {
md.push(context.signatureMember(signature, headingLevel + 1));
});
return (_a = reflection.signatures) === null || _a === void 0 ? void 0 : _a.map((signature) => {
return context.signatureMember(signature, headingLevel + 1);
}).join('\n\n');
}
else {
if (reflection instanceof typedoc_1.ReferenceReflection) {
md.push(context.referenceMember(reflection));
}
if (reflection instanceof typedoc_1.DeclarationReflection) {
md.push(context.declarationMember(reflection, headingLevel + 1));
}
if (reflection.getSignature) {
return context.signatureMember(reflection.getSignature, headingLevel + 1);
}
if (reflection.setSignature) {
return context.signatureMember(reflection.setSignature, headingLevel + 1);
}
if (reflection instanceof typedoc_1.ReferenceReflection) {
return context.referenceMember(reflection);
}
return context.declarationMember(reflection, headingLevel + 1);
};
const member = getMember(reflection);
if (member) {
md.push(member);
}

@@ -37,0 +47,0 @@ return md.join('\n\n');

@@ -13,7 +13,9 @@ "use strict";

const md = [];
if (reflection.flags.isAbstract) {
md.push((0, elements_1.bold)((0, elements_1.backTicks)('abstract')));
}
if (reflection.comment) {
md.push(context.comment(reflection.comment, headingLevel));
}
if (!context.options.getValue('hideHierarchy') &&
((_a = reflection.typeHierarchy) === null || _a === void 0 ? void 0 : _a.next)) {
if ((_a = reflection.typeHierarchy) === null || _a === void 0 ? void 0 : _a.next) {
md.push(context.memberHierarchy(reflection.typeHierarchy, headingLevel));

@@ -20,0 +22,0 @@ }

@@ -10,5 +10,11 @@ "use strict";

function signatureMemberIdentifier(context, signature) {
var _a, _b;
var _a, _b, _c, _d;
const md = [];
if (signature.parent && ((_a = signature.parent.flags) === null || _a === void 0 ? void 0 : _a.length) > 0) {
if ((_a = signature.parent) === null || _a === void 0 ? void 0 : _a.getSignature) {
md.push('get ');
}
if ((_b = signature.parent) === null || _b === void 0 ? void 0 : _b.setSignature) {
md.push('set ');
}
if (signature.parent && ((_c = signature.parent.flags) === null || _c === void 0 ? void 0 : _c.length) > 0) {
md.push(signature.parent.flags

@@ -46,3 +52,3 @@ .map((flag) => `\`${flag.toLowerCase()}\``)

};
md.push(signature.parameters && ((_b = signature.parameters) === null || _b === void 0 ? void 0 : _b.length) > 0
md.push(signature.parameters && ((_d = signature.parameters) === null || _d === void 0 ? void 0 : _d.length) > 0
? `(${getParameters(signature.parameters)})`

@@ -49,0 +55,0 @@ : '()');

@@ -54,10 +54,10 @@ "use strict";

md.push(context.inheritance(signature, headingLevel));
if (showSources && signature.sources) {
md.push(context.sources(signature, headingLevel));
}
if (signature.comment) {
md.push(context.comment(signature.comment, headingLevel, false, true));
}
if (showSources && signature.sources) {
md.push(context.sources(signature, headingLevel));
}
return md.join('\n\n');
}
exports.signatureMember = signatureMember;

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

var _a;
const md = [(0, elements_1.heading)(headingLevel, 'Defined In')];
const md = [];
if (headingLevel !== -1) {
md.push((0, elements_1.heading)(headingLevel, 'Source'));
}
(_a = reflection.sources) === null || _a === void 0 ? void 0 : _a.forEach((source) => {

@@ -14,0 +17,0 @@ if (source.url) {

@@ -19,3 +19,11 @@ "use strict";

md.push(context.member(item, memberHeadingLevel || headingLevel));
if (index !== items.length - 1) {
if (index !== items.length - 1 &&
(item.kindOf([
typedoc_1.ReflectionKind.Class,
typedoc_1.ReflectionKind.Interface,
typedoc_1.ReflectionKind.Function,
typedoc_1.ReflectionKind.Enum,
typedoc_1.ReflectionKind.Variable,
]) ||
context.options.getValue('outputFileStrategy') === 'members')) {
md.push((0, elements_1.horizontalRule)());

@@ -22,0 +30,0 @@ }

@@ -14,3 +14,7 @@ "use strict";

const hasComments = comments.some((value) => Boolean(value));
const headers = [nameCol];
const inheritance = props.map((reflection) => Boolean(reflection.overwrites) || Boolean(reflection.inheritedFrom));
const hasInheritance = inheritance.some((value) => Boolean(value));
const hasSources = !context.options.getValue('disableSources');
const headers = [];
headers.push(nameCol);
headers.push('Type');

@@ -20,2 +24,8 @@ if (hasComments) {

}
if (hasInheritance) {
headers.push('Inheritance');
}
if (hasSources) {
headers.push('Source');
}
const flattenParams = (current) => {

@@ -44,5 +54,11 @@ var _a, _b, _c;

const nameColumn = [];
if (property.flags.length && !property.flags.isOptional) {
nameColumn.push(property.flags.map((flag) => (0, elements_1.backTicks)(flag.toLowerCase())).join(' '));
if (context.options.getValue('namedAnchors') && property.anchor) {
nameColumn.push(`<a id="${property.anchor}" name="${property.anchor}"></a>`);
}
if (property.flags.length) {
nameColumn.push(property.flags
.filter((flag) => flag !== 'Optional')
.map((flag) => (0, elements_1.bold)((0, elements_1.backTicks)(flag.toLowerCase())))
.join(' '));
}
if (Boolean(property.getSignature || Boolean(property.setSignature))) {

@@ -52,3 +68,3 @@ nameColumn.push(context.declarationMemberAccessor(property));

else {
nameColumn.push(`${(0, elements_1.backTicks)((0, utils_1.tableComments)(property.name))}${property.flags.isOptional ? '?' : ''}`);
nameColumn.push(`${(0, elements_1.backTicks)(`${property.name}${property.flags.isOptional ? '?' : ''}`)}`);
}

@@ -68,2 +84,8 @@ row.push(nameColumn.join(' '));

}
if (hasInheritance) {
row.push(context.inheritance(property, -1) || '-');
}
if (hasSources) {
row.push(context.sources(property, -1));
}
rows.push(row);

@@ -70,0 +92,0 @@ });

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

const types = declarationReflection.children &&
declarationReflection.children.map((obj) => {
declarationReflection.children.map((obj, index) => {
const name = [];

@@ -33,3 +33,5 @@ if (Boolean(obj.getSignature || Boolean(obj.setSignature))) {

}
return `${name.join(' ')}: ${context.someType((0, helpers_1.getDeclarationType)(obj))};`;
const theType = (0, helpers_1.getDeclarationType)(obj);
const typeString = context.someType(theType);
return `${name.join(' ')}: ${indentBlock(typeString)};\n `;
});

@@ -39,3 +41,3 @@ if (indexSignature) {

}
return types ? `\\{${types.join(' ')}}` : '\\{}';
return types ? `\\{\n ${types.join(' ')}}` : '\\{}';
}

@@ -45,1 +47,16 @@ return '\\{}';

exports.declarationType = declarationType;
function indentBlock(content) {
const lines = content.split('\n');
return lines
.filter((line) => Boolean(line.length))
.map((line, i) => {
if (i === 0) {
return line;
}
if (i === lines.length - 1) {
return ` ${line}`;
}
return ` ${line}`;
})
.join('\n');
}

@@ -14,5 +14,3 @@ "use strict";

if (root.signatures) {
return collapse
? (0, elements_1.backTicks)('function')
: context.functionType(root.signatures);
return context.functionType(root.signatures);
}

@@ -19,0 +17,0 @@ return collapse ? (0, elements_1.backTicks)('object') : context.declarationType(root);

@@ -7,3 +7,3 @@ import { Options, ProjectReflection, UrlMapping } from 'typedoc';

urls: UrlMapping[];
anchors: string[];
anchors: Record<string, string[]>;
constructor(theme: MarkdownTheme, options: Options);

@@ -27,2 +27,3 @@ /**

private getAnchorId;
private getAnchorName;
private getPartName;

@@ -29,0 +30,0 @@ private childrenIncludeNamespaces;

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

this.urls = [];
this.anchors = [];
this.anchors = {};
}

@@ -202,3 +202,2 @@ /**

}
// remove leading underscores
const alias = reflection.getAlias().replace(/^_/, '');

@@ -251,23 +250,26 @@ const parentDir = options.parentUrl

var _a, _b;
if (container.url && !reflection.url) {
if (container.url) {
if (!reflection.kindOf(typedoc_1.ReflectionKind.TypeLiteral)) {
const anchorPrefix = this.options.getValue('anchorPrefix');
const anchorId = this.getAnchorId(reflection);
if (!this.anchors[container.url]) {
this.anchors[container.url] = [];
if (anchorId) {
if (!this.anchors[container.url]) {
this.anchors[container.url] = [];
}
this.anchors[container.url].push(anchorId);
const count = (_b = (_a = this.anchors[container.url]) === null || _a === void 0 ? void 0 : _a.filter((id) => id === anchorId)) === null || _b === void 0 ? void 0 : _b.length;
const anchorParts = [anchorId];
if (count > 1) {
anchorParts.push(`-${count}`);
}
if (anchorPrefix) {
anchorParts.unshift(`${anchorPrefix}`);
}
reflection.url = container.url + '#' + anchorParts.join('');
reflection.anchor = anchorParts.join('');
}
this.anchors[container.url].push(anchorId);
const count = (_b = (_a = this.anchors[container.url]) === null || _a === void 0 ? void 0 : _a.filter((id) => id === anchorId)) === null || _b === void 0 ? void 0 : _b.length;
const anchorParts = [anchorId];
if (count > 1) {
anchorParts.push(`-${count}`);
}
if (anchorPrefix) {
anchorParts.unshift(`${anchorPrefix}`);
}
reflection.url = container.url + '#' + anchorParts.join('');
}
reflection.hasOwnDocument = false;
}
else if (reflection.parent) {
if (reflection.parent) {
reflection.traverse((child) => {

@@ -282,6 +284,18 @@ if (child instanceof typedoc_1.DeclarationReflection) {

const preserveAnchorCasing = this.options.getValue('preserveAnchorCasing');
return preserveAnchorCasing
? reflection.name
: reflection.name.toLowerCase();
const anchorName = this.getAnchorName(reflection);
if (anchorName) {
return preserveAnchorCasing ? anchorName : anchorName.toLowerCase();
}
return null;
}
getAnchorName(reflection) {
const namedAnchors = this.options.getValue('namedAnchors');
const propertiesTableStyle = this.options.getValue('propertiesFormat') === 'table';
if (!namedAnchors) {
if (reflection.kindOf(typedoc_1.ReflectionKind.Property) && propertiesTableStyle) {
return null;
}
}
return reflection.name;
}
getPartName(part, position) {

@@ -288,0 +302,0 @@ return this.options.getValue('includeFileNumberPrefixes')

{
"name": "typedoc-plugin-markdown",
"version": "4.0.0-next.19",
"version": "4.0.0-next.20",
"description": "A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.",

@@ -14,6 +14,12 @@ "main": "dist/index.js",

"prepublishOnly": "npm run lint && npm run build",
"copyJs": "copyfiles --up 1 ./src/**/*.*js ./dist/",
"prebuild": "rm -rf dist && npm run copyJs && npm-run-all task:code",
"prebuild": "rm -rf dist && npm-run-all task:code",
"build": "tsc",
"test": "jest --colors",
"prestubs": "npm run build",
"stubs": "npm-run-all stubs:*",
"stubs:md-1": "typedoc --options ./test/typedoc1.cjs --out ./test/fixtures/md-1",
"stubs:md-2": "typedoc --options ./test/typedoc2.cjs --out ./test/fixtures/md-2",
"stubs:md-3": "typedoc --options ./test/typedoc3.cjs --out ./test/fixtures/md-3",
"stubs:md-4": "typedoc --options ./test/typedoc4.cjs --out ./test/fixtures/md-4",
"stubs:html": "typedoc --options ./test/typedoc-html.cjs --out ./test/fixtures/html",
"build-and-test": "npm run build && npm run test",

@@ -20,0 +26,0 @@ "api-docs": "npm run build && typedoc --options ./typedoc.api.js --out ./docs/api",

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