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.36 to 4.0.0-next.37

9

dist/plugin/bootstrap.js

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

exports.load = void 0;
const typedoc_1 = require("typedoc");
const theme_1 = require("../theme");

@@ -62,3 +63,11 @@ const options = __importStar(require("./options/config"));

});
app.converter.on(typedoc_1.Converter.EVENT_RESOLVE_END, (context) => {
if (app.options.packageDir) {
app.renderer.packages = {
...(app.renderer.packages || {}),
[context.project.name]: { dir: app.options.packageDir },
};
}
});
}
exports.load = load;

@@ -90,2 +90,19 @@ "use strict";

const output = new events_1.MarkdownRendererEvent(events_1.MarkdownRendererEvent.BEGIN, outputDirectory, project);
if (this.packages) {
const getOptionsForPackage = new Promise((resolve, reject) => {
const packages = {};
Object.entries(this.packages).forEach(async ([k, v]) => {
packages[k] = {};
const origOptions = this.application.options;
const packageOptions = origOptions.copyForPackage(v.dir);
await packageOptions.read(this.application.logger, v.dir);
const isSet = packageOptions.isSet('outputFileStrategy');
packages[k].outputFileStrategy = isSet
? packageOptions.getValue('outputFileStrategy')
: null;
resolve(packages);
});
});
this.packages = await getOptionsForPackage;
}
output.urls = this.theme.getUrls(project);

@@ -92,0 +109,0 @@ output.navigation = this.theme.getNavigation(project);

2

dist/theme/models.d.ts

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

import { ReflectionKind } from 'typedoc';
import { OutputFileStrategy } from '../plugin/options/custom-maps';
export interface UrlOption {

@@ -12,2 +13,3 @@ parentUrl?: string;

forceDirectory?: boolean;
outputFileStrategy?: OutputFileStrategy;
}

@@ -14,0 +16,0 @@ export interface TemplateMapping {

7

dist/theme/resources/partials/header.js

@@ -64,5 +64,8 @@ "use strict";

md.push(getProjectName(page.project, context, page.project.url));
md.push('\\>');
md.push((0, elements_1.bold)(packageItem.name));
md.push('•');
const packageItemName = packageItem.packageVersion
? `${packageItem.name} - v${packageItem.packageVersion}`
: packageItem.name;
md.push((0, elements_1.bold)(packageItemName));
md.push('•');
const preservePackageReadme = Boolean(packageItem.readme) && !context.options.getValue('mergeReadme');

@@ -69,0 +72,0 @@ if (preservePackageReadme) {

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

const name = (0, helpers_1.getMemberTitle)(page.model);
const projectName = (0, helpers_1.getProjectDisplayName)(page.project, context.options.getValue('includeVersion'));
if (((_a = page.model) === null || _a === void 0 ? void 0 : _a.url) === page.project.url) {
const projectName = (0, helpers_1.getProjectDisplayName)(page.project, context.options.getValue('includeVersion'));
return context.options

@@ -21,3 +21,5 @@ .getValue('indexPageTitle')

if (page.model.kindOf(typedoc_1.ReflectionKind.Module)) {
return name;
return page.model.packageVersion
? `${name} - v${page.model.packageVersion}`
: name;
}

@@ -24,0 +26,0 @@ return memberPageTitle

import { DeclarationReflection, PageEvent, ProjectReflection, Reflection, ReflectionKind, RenderTemplate, Renderer, Theme } from 'typedoc';
import { MarkdownPageEvent } from '../plugin/events';
import { OutputFileStrategy } from '../plugin/options/custom-maps';
import { UrlMapping } from '../plugin/url-mapping';

@@ -39,3 +40,3 @@ import { NavigationItem, TemplateMapping } from './models';

*/
getTemplateMapping(kind: ReflectionKind): TemplateMapping;
getTemplateMapping(kind: ReflectionKind, outputFileStrategyOverride?: OutputFileStrategy): TemplateMapping;
}

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

getUrlsContext(project) {
return new urls_context_1.UrlsContext(this, project, this.application.options.getRawValues());
return new urls_context_1.UrlsContext(this, project, this.application.renderer, this.application.options);
}

@@ -108,4 +108,5 @@ /**

*/
getTemplateMapping(kind) {
const outputFileStrategy = this.application.options.getValue('outputFileStrategy');
getTemplateMapping(kind, outputFileStrategyOverride) {
const outputFileStrategy = outputFileStrategyOverride ||
this.application.options.getValue('outputFileStrategy');
const getDirectoryName = (reflectionKind) => {

@@ -112,0 +113,0 @@ const pluralString = typedoc_1.ReflectionKind.pluralString(reflectionKind);

@@ -1,4 +0,4 @@

import { DeclarationReflection, ProjectReflection, TypeDocOptions } from 'typedoc';
import { DeclarationReflection, Options, ProjectReflection, Renderer } from 'typedoc';
import { UrlMapping } from '../plugin/url-mapping';
import { UrlOption } from '../theme/models';
import { UrlOption } from './models';
import { MarkdownTheme } from './theme';

@@ -8,6 +8,7 @@ export declare class UrlsContext {

project: ProjectReflection;
options: Partial<TypeDocOptions>;
renderer: Renderer;
options: Options;
urls: UrlMapping[];
anchors: Record<string, string[]>;
constructor(theme: MarkdownTheme, project: ProjectReflection, options: Partial<TypeDocOptions>);
constructor(theme: MarkdownTheme, project: ProjectReflection, renderer: Renderer, options: Options);
/**

@@ -14,0 +15,0 @@ * Map the models of the given project to the desired output files.

@@ -34,5 +34,6 @@ "use strict";

class UrlsContext {
constructor(theme, project, options) {
constructor(theme, project, renderer, options) {
this.theme = theme;
this.project = project;
this.renderer = renderer;
this.options = options;

@@ -50,8 +51,9 @@ this.urls = [];

var _a, _b, _c, _d;
const preserveReadme = Boolean(this.project.readme) && !this.options.mergeReadme;
const preserveReadme = Boolean(this.project.readme) && !this.options.getValue('mergeReadme');
const preserveModulesPage = (((_a = this.project) === null || _a === void 0 ? void 0 : _a.groups) &&
Boolean((_c = (_b = this.project) === null || _b === void 0 ? void 0 : _b.groups[0]) === null || _c === void 0 ? void 0 : _c.children.find((child) => child.name === this.options.entryModule))) ||
Boolean((_c = (_b = this.project) === null || _b === void 0 ? void 0 : _b.groups[0]) === null || _c === void 0 ? void 0 : _c.children.find((child) => child.name === this.options.getValue('entryModule')))) ||
false;
const isPackages = this.options.entryPointStrategy === typedoc_1.EntryPointStrategy.Packages;
const entryFileName = this.options.entryFileName;
const isPackages = this.options.getValue('entryPointStrategy') ===
typedoc_1.EntryPointStrategy.Packages;
const entryFileName = this.options.getValue('entryFileName');
const indexFilename = (0, helpers_1.getIndexFileName)(this.project, isPackages);

@@ -62,3 +64,3 @@ this.project.url = preserveReadme

? indexFilename
: this.options.entryFileName;
: this.options.getValue('entryFileName');
if (preserveReadme) {

@@ -73,4 +75,7 @@ this.urls.push(new url_mapping_1.UrlMapping(preserveModulesPage ? 'readme_.md' : entryFileName, this.project, this.theme.readmeTemplate));

(_d = this.project.children) === null || _d === void 0 ? void 0 : _d.forEach((projectChild) => {
const preservePackageReadme = Boolean(projectChild.readme) && !this.options.mergeReadme;
const preservePackageReadme = Boolean(projectChild.readme) && !this.options.getValue('mergeReadme');
const packagesIndex = (0, helpers_1.getIndexFileName)(projectChild);
const packageMeta = this.renderer.packages[projectChild.name];
const outputFileStrategy = packageMeta.outputFileStrategy ||
this.options.getValue('outputFileStrategy');
const url = `${projectChild.name}/${preservePackageReadme ? packagesIndex : entryFileName}`;

@@ -82,3 +87,3 @@ if (preservePackageReadme) {

projectChild.url = url;
this.buildUrlsFromProject(projectChild, url);
this.buildUrlsFromProject(projectChild, url, outputFileStrategy);
});

@@ -96,3 +101,3 @@ }

*/
buildUrlsFromProject(project, parentUrl) {
buildUrlsFromProject(project, parentUrl, outputFileStrategy) {
var _a;

@@ -103,3 +108,4 @@ (_a = project.groups) === null || _a === void 0 ? void 0 : _a.forEach((projectGroup) => {

this.buildUrlsFromGroup(projectGroupChild, {
...(parentUrl && { parentUrl: parentUrl }),
...(parentUrl && { parentUrl }),
...(outputFileStrategy && { outputFileStrategy }),
});

@@ -111,3 +117,3 @@ });

var _a;
const mapping = this.theme.getTemplateMapping(reflection.kind);
const mapping = this.theme.getTemplateMapping(reflection.kind, options.outputFileStrategy);
if (mapping) {

@@ -125,6 +131,7 @@ const directory = options.directory || mapping.directory;

group.children.forEach((groupChild) => {
const mapping = this.theme.getTemplateMapping(groupChild.kind);
const mapping = this.theme.getTemplateMapping(groupChild.kind, options.outputFileStrategy);
this.buildUrlsFromGroup(groupChild, {
parentUrl: urlPath,
directory: (mapping === null || mapping === void 0 ? void 0 : mapping.directory) || null,
outputFileStrategy: options.outputFileStrategy,
});

@@ -139,6 +146,7 @@ });

getUrl(reflection, urlPath) {
if (reflection.name === this.options.entryModule) {
return this.options.entryFileName;
if (reflection.name === this.options.getValue('entryModule')) {
return this.options.getValue('entryFileName');
}
if (this.options.outputFileStrategy === custom_maps_1.OutputFileStrategy.Modules &&
if (this.options.getValue('outputFileStrategy') ===
custom_maps_1.OutputFileStrategy.Modules &&
reflection.name === 'index') {

@@ -170,3 +178,4 @@ return `module.index.md`;

if ([typedoc_1.ReflectionKind.Module, typedoc_1.ReflectionKind.Namespace].includes(reflection.kind) &&
this.options.outputFileStrategy === custom_maps_1.OutputFileStrategy.Modules &&
this.options.getValue('outputFileStrategy') ===
custom_maps_1.OutputFileStrategy.Modules &&
!this.childrenIncludeNamespaces(reflection)) {

@@ -176,3 +185,3 @@ return null;

if ([typedoc_1.ReflectionKind.Module, typedoc_1.ReflectionKind.Namespace].includes(reflection.kind)) {
return path.parse(this.options.entryFileName).name;
return path.parse(this.options.getValue('entryFileName')).name;
}

@@ -188,3 +197,3 @@ return alias;

if (!reflection.kindOf(typedoc_1.ReflectionKind.TypeLiteral)) {
const anchorPrefix = this.options.anchorPrefix;
const anchorPrefix = this.options.getValue('anchorPrefix');
const anchorId = this.getAnchorId(reflection);

@@ -219,3 +228,3 @@ if (anchorId) {

getAnchorId(reflection) {
const preserveAnchorCasing = this.options.preserveAnchorCasing;
const preserveAnchorCasing = this.options.getValue('preserveAnchorCasing');
const anchorName = this.getAnchorName(reflection);

@@ -228,8 +237,9 @@ if (anchorName) {

getAnchorName(reflection) {
const htmlTableAnchors = this.options.namedAnchors && this.options.namedAnchors['tableRows'];
const htmlTableAnchors = this.options.getValue('namedAnchors') &&
this.options.getValue('namedAnchors')['tableRows'];
if (!htmlTableAnchors) {
if ((reflection.kindOf(typedoc_1.ReflectionKind.Property) &&
this.options.propertiesFormat === 'table') ||
this.options.getValue('propertiesFormat') === 'table') ||
(reflection.kindOf(typedoc_1.ReflectionKind.EnumMember) &&
this.options.enumMembersFormat === 'table')) {
this.options.getValue('enumMembersFormat') === 'table')) {
return null;

@@ -236,0 +246,0 @@ }

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

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

"test:lint-mdx": "node test/__scripts__/lint.mdx.mjs",
"test:jest": "jest --updateSnapshot",
"test:jest": "jest",
"build-and-run": "npm run build && npm run pretest",

@@ -21,0 +21,0 @@ "build-and-test": "npm run build && npm run test",

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