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

typedoc-plugin-markdown

Package Overview
Dependencies
Maintainers
0
Versions
250
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.3.0 to 4.3.1

dist/theme/context/partials/type.optional.d.ts

1

dist/theme/context/partials/index.d.ts

@@ -51,2 +51,3 @@ export * from './comments.comment.js';

export * from './type.named-tuple.js';
export * from './type.optional.js';
export * from './type.query.js';

@@ -53,0 +54,0 @@ export * from './type.reference.js';

@@ -51,2 +51,3 @@ export * from './comments.comment.js';

export * from './type.named-tuple.js';
export * from './type.optional.js';
export * from './type.query.js';

@@ -53,0 +54,0 @@ export * from './type.reference.js';

8

dist/theme/context/partials/member.declaration.js
import { heading } from '../../../libs/markdown/index.js';
import { IntersectionType, ReferenceType, ReflectionKind, ReflectionType, UnionType, } from 'typedoc';
import { ArrayType, IntersectionType, ReferenceType, ReflectionKind, ReflectionType, UnionType, } from 'typedoc';
export function declaration(model, options = {

@@ -18,4 +18,8 @@ headingLevel: 2,

}
const typeDeclaration = model.type
let typeDeclaration = model.type
?.declaration;
if (model.type instanceof ArrayType &&
model.type?.elementType instanceof ReflectionType) {
typeDeclaration = model.type?.elementType?.declaration;
}
const hasTypeDeclaration = Boolean(typeDeclaration) ||

@@ -22,0 +26,0 @@ (model.type instanceof UnionType &&

@@ -15,19 +15,33 @@ import { backTicks, heading } from '../../../libs/markdown/index.js';

if (parameter.type instanceof UnionType && parameter.type?.types) {
const containsReflectionUnion = parameter.type.types.some((type) => type instanceof ReflectionType);
const unions = [];
if (parameter.comment) {
row.push(this.partials.comment(parameter.comment));
}
parameter.type?.types.forEach((type) => {
const hasUsefulTypeDetails = this.helpers.hasUsefulTypeDetails(type);
if (type instanceof ReflectionType) {
unions.push(this.partials.someType(type, { forceCollapse: true }));
unions.push(getReflectionType(this, options, parameter, type));
const typeOut = this.partials.someType(type, {
forceCollapse: true,
});
if (hasUsefulTypeDetails) {
const usefulDetails = [];
usefulDetails.push('\n\n');
usefulDetails.push(typeOut);
usefulDetails.push(getReflectionType(this, options, parameter, type));
usefulDetails.push('\n\n');
unions.push(usefulDetails.join('\n\n'));
}
else {
unions.push(typeOut);
}
}
else {
unions.push(this.partials.someType(type));
unions.push(this.partials.someType(type, { forceCollapse: true }));
}
});
if (containsReflectionUnion) {
row.push(unions.join('\n\n'));
}
else {
row.push(unions.join(' | '));
}
row.push(unions
.join(' | ')
.split('\n')
.map((ln) => ln.trim())
.join('\n'));
}

@@ -37,5 +51,5 @@ else {

if (parameter.type.declaration?.signatures) {
row.push(this.partials.someType(parameter.type));
row.push(this.partials.someType(parameter.type, { forceCollapse: true }));
}
row.push(getReflectionType(this, options, parameter, parameter.type));
row.push(`${'\n\n'}${getReflectionType(this, options, parameter, parameter.type)}`);
}

@@ -50,7 +64,9 @@ else {

}
function getOtherType(context, parameter) {
function getOtherType(context, parameter, skipHeading = false) {
const rest = parameter.flags.isRest ? '...' : '';
const identifier = [];
const md = [];
identifier.push(context.partials.someType(parameter.type));
if (!skipHeading) {
identifier.push(context.partials.someType(parameter.type, { forceCollapse: true }));
}
if (parameter.defaultValue) {

@@ -69,3 +85,3 @@ identifier.push(' = ' + backTicks(context.helpers.getParameterDefaultValue(parameter)));

type,
});
}, true);
const block = [];

@@ -77,3 +93,3 @@ const typeMd = [];

flatten?.forEach((flat) => {
typeMd.push(heading(options.headingLevel + 2, flat.name));
typeMd.push('\n' + heading(options.headingLevel + 2, flat.name));
typeMd.push(getOtherType(context, flat));

@@ -84,7 +100,7 @@ });

}
function flattenParams(current) {
function flattenParams(current, skip = false) {
return current.type?.declaration?.children?.reduce((acc, child) => {
const childObj = {
...child,
name: `${current.name}.${child.name}`,
name: skip ? child.name : `${current.name}.${child.name}`,
};

@@ -91,0 +107,0 @@ return parseParams(childObj, acc);

import { MarkdownThemeContext } from '../../../theme/index.js';
import { DeclarationReflection } from 'typedoc';
export declare function declarationType(this: MarkdownThemeContext, model: DeclarationReflection): string;
export declare function declarationType(this: MarkdownThemeContext, model: DeclarationReflection, options?: {
forceCollapse?: boolean;
}): string;
import { backTicks } from '../../../libs/markdown/index.js';
export function declarationType(model) {
export function declarationType(model, options) {
const shouldFormat = this.options.getValue('useCodeBlocks');

@@ -29,3 +29,3 @@ if (model.indexSignatures || model.children) {

const theType = this.helpers.getDeclarationType(obj);
const typeString = this.partials.someType(theType);
const typeString = this.partials.someType(theType, options);
if (shouldFormat) {

@@ -32,0 +32,0 @@ return ` ${name.join(' ')}: ${indentBlock(typeString)};\n`;

@@ -10,4 +10,4 @@ import { backTicks } from '../../../libs/markdown/index.js';

return expandObjects
? this.partials.declarationType(root)
? this.partials.declarationType(root, options)
: backTicks('object');
}

@@ -52,3 +52,3 @@ import { backTicks } from '../../../libs/markdown/index.js';

if (model instanceof OptionalType) {
return this.partials.someType(model.elementType) + '?';
return this.partials.optionalType(model);
}

@@ -55,0 +55,0 @@ if (model.toString() == 'null') {

import { MarkdownPageEvent } from '../../events/index.js';
import { MarkdownThemeContext } from '../../theme/index.js';
import { ArrayType, Comment, CommentDisplayPart, ConditionalType, ContainerReflection, DeclarationHierarchy, DeclarationReflection, DocumentReflection, IndexedAccessType, InferredType, IntersectionType, IntrinsicType, LiteralType, NamedTupleMember, ParameterReflection, ProjectReflection, QueryType, ReferenceReflection, ReferenceType, Reflection, ReflectionCategory, ReflectionFlags, ReflectionGroup, ReflectionKind, ReflectionType, SignatureReflection, SomeType, TupleType, TypeOperatorType, TypeParameterReflection, UnionType, UnknownType } from 'typedoc';
import { ArrayType, Comment, CommentDisplayPart, ConditionalType, ContainerReflection, DeclarationHierarchy, DeclarationReflection, DocumentReflection, IndexedAccessType, InferredType, IntersectionType, IntrinsicType, LiteralType, NamedTupleMember, OptionalType, ParameterReflection, ProjectReflection, QueryType, ReferenceReflection, ReferenceType, Reflection, ReflectionCategory, ReflectionFlags, ReflectionGroup, ReflectionKind, ReflectionType, SignatureReflection, SomeType, TupleType, TypeOperatorType, TypeParameterReflection, UnionType, UnknownType } from 'typedoc';
export declare const resourceTemplates: (context: MarkdownThemeContext) => {

@@ -152,5 +152,8 @@ /**

namedTupleType: (model: NamedTupleMember) => string;
optionalType: (model: OptionalType) => string;
queryType: (model: QueryType) => string;
referenceType: (model: ReferenceType) => string;
declarationType: (model: DeclarationReflection) => string;
declarationType: (model: DeclarationReflection, options?: {
forceCollapse?: boolean | undefined;
} | undefined) => string;
functionType: (model: SignatureReflection[], options?: {

@@ -157,0 +160,0 @@ forceParameterType: boolean;

@@ -89,5 +89,6 @@ import { templates, partials, helpers } from './index.js';

namedTupleType: (model) => partials.namedTupleType.apply(context, [model]),
optionalType: (model) => partials.optionalType.apply(context, [model]),
queryType: (model) => partials.queryType.apply(context, [model]),
referenceType: (model) => partials.referenceType.apply(context, [model]),
declarationType: (model) => partials.declarationType.apply(context, [model]),
declarationType: (model, options) => partials.declarationType.apply(context, [model, options]),
functionType: (model, options) => partials.functionType.apply(context, [model, options]),

@@ -94,0 +95,0 @@ reflectionType: (model, options) => partials.reflectionType.apply(context, [model, options]),

@@ -220,5 +220,8 @@ import { MarkdownPageEvent } from '../events/index.js';

namedTupleType: (model: import("typedoc").NamedTupleMember) => string;
optionalType: (model: import("typedoc").OptionalType) => string;
queryType: (model: import("typedoc").QueryType) => string;
referenceType: (model: import("typedoc").ReferenceType) => string;
declarationType: (model: import("typedoc").DeclarationReflection) => string;
declarationType: (model: import("typedoc").DeclarationReflection, options?: {
forceCollapse?: boolean | undefined;
} | undefined) => string;
functionType: (model: import("typedoc").SignatureReflection[], options?: {

@@ -225,0 +228,0 @@ forceParameterType: boolean;

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

@@ -20,4 +20,5 @@ "exports": {

"validate": "node test/__scripts__/lint/lint.md.mjs && tsx test/__scripts__/lint/lint.mdx.mjs",
"pretest": "npm run fixtures -- -isCI",
"test": "npm run validate && jest",
"test:update": "npm run build && npm run fixtures && npm run test -- -u",
"test:update": "npm run build-and-run && npm run validate && jest -u",
"playground": "npm run build && typedoc --options ./playground/typedoc.json",

@@ -24,0 +25,0 @@ "schema": "tsx ./.scripts/schema/generate-schema.ts",

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