typedoc-github-wiki-theme
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -1,3 +0,3 @@ | ||
import { Application } from 'typedoc'; | ||
export declare function load(app: Application): void; | ||
import { MarkdownApplication } from 'typedoc-plugin-markdown'; | ||
export declare function load(app: MarkdownApplication): void; | ||
export declare function formatContents(contents: string): string; |
@@ -1,37 +0,13 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.formatContents = exports.load = void 0; | ||
const fs = __importStar(require("fs")); | ||
const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown"); | ||
const options_1 = require("./options"); | ||
const options = __importStar(require("./options/declarations")); | ||
const presets_1 = __importDefault(require("./options/presets")); | ||
const sidebar_1 = require("./sidebar"); | ||
function load(app) { | ||
/** | ||
* The plugin entrypoint and bootstrapping of the plugin. | ||
* | ||
* @module | ||
*/ | ||
import * as fs from 'fs'; | ||
import { MarkdownPageEvent, } from 'typedoc-plugin-markdown'; | ||
import { DEFAULT_SIDEBAR_OPTIONS } from './options.js'; | ||
import * as options from './options/declarations.js'; | ||
import { presets } from './options/presets.js'; | ||
import { getSidebar } from './sidebar.js'; | ||
export function load(app) { | ||
Object.entries(options).forEach(([name, option]) => { | ||
@@ -44,9 +20,7 @@ app.options.addDeclaration({ | ||
app.options.addReader(new (class { | ||
constructor() { | ||
this.name = 'github-wiki-options'; | ||
this.order = 0; | ||
this.supportsPackages = false; | ||
} | ||
name = 'github-wiki-options'; | ||
order = 0; | ||
supportsPackages = false; | ||
read(container) { | ||
Object.entries(presets_1.default).forEach(([key, value]) => { | ||
Object.entries(presets).forEach(([key, value]) => { | ||
container.setValue(key, value); | ||
@@ -56,3 +30,3 @@ }); | ||
})()); | ||
app.renderer.on(typedoc_plugin_markdown_1.MarkdownPageEvent.END, (page) => { | ||
app.renderer.on(MarkdownPageEvent.END, (page) => { | ||
page.contents = page.contents?.replace(/\[([^\]]+)\]\((?!https?:|\/|\.)([^)]+)\)/g, (match, text, url) => { | ||
@@ -64,3 +38,3 @@ return `[${text}](${encodeURI('../wiki/' + url.replace('.md', ''))})`; | ||
const sidebarOptions = { | ||
...options_1.DEFAULT_SIDEBAR_OPTIONS, | ||
...DEFAULT_SIDEBAR_OPTIONS, | ||
...app.options.getValue('sidebar'), | ||
@@ -70,5 +44,5 @@ }; | ||
const sidebarHeading = sidebarOptions.heading; | ||
const sidebarContent = (0, sidebar_1.getSidebar)(output.navigation); | ||
const sidebarContent = getSidebar(output.navigation); | ||
if (sidebarContent.length) { | ||
fs.writeFileSync(`${output.outputDirectory}/_Sidebar.md`, `## ${sidebarHeading}\n\n${formatContents((0, sidebar_1.getSidebar)(output.navigation))}`); | ||
fs.writeFileSync(`${output.outputDirectory}/_Sidebar.md`, `## ${sidebarHeading}\n\n${formatContents(getSidebar(output.navigation))}`); | ||
} | ||
@@ -78,6 +52,4 @@ } | ||
} | ||
exports.load = load; | ||
function formatContents(contents) { | ||
export function formatContents(contents) { | ||
return (contents.replace(/[\r\n]{2,}/g, '\n\n').replace(/^\s+|\s+$/g, '') + '\n'); | ||
} | ||
exports.formatContents = formatContents; |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DEFAULT_SIDEBAR_OPTIONS = void 0; | ||
exports.DEFAULT_SIDEBAR_OPTIONS = { | ||
export const DEFAULT_SIDEBAR_OPTIONS = { | ||
autoConfiguration: true, | ||
heading: 'API', | ||
}; |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sidebar = void 0; | ||
const typedoc_1 = require("typedoc"); | ||
const options_1 = require("../options"); | ||
import { ParameterType } from 'typedoc'; | ||
import { DEFAULT_SIDEBAR_OPTIONS } from '../options.js'; | ||
/** | ||
@@ -16,6 +13,6 @@ * **sidebar.autoConfiguration** | ||
*/ | ||
exports.sidebar = { | ||
export const sidebar = { | ||
help: 'Configures the autogenerated `_sidebar.md file`.', | ||
type: typedoc_1.ParameterType.Mixed, | ||
defaultValue: options_1.DEFAULT_SIDEBAR_OPTIONS, | ||
type: ParameterType.Mixed, | ||
defaultValue: DEFAULT_SIDEBAR_OPTIONS, | ||
}; |
@@ -1,2 +0,2 @@ | ||
declare const _default: { | ||
export declare const presets: { | ||
entryFileName: string; | ||
@@ -6,2 +6,1 @@ hidePageHeader: boolean; | ||
}; | ||
export default _default; |
@@ -1,4 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = { | ||
export const presets = { | ||
entryFileName: 'Home.md', | ||
@@ -5,0 +3,0 @@ hidePageHeader: true, |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getSidebar = void 0; | ||
function getSidebar(navigationItems) { | ||
export function getSidebar(navigationItems) { | ||
const parseSidebarUrl = (url) => '../wiki/' + url.replace('.md', ''); | ||
@@ -25,2 +22,1 @@ const md = []; | ||
} | ||
exports.getSidebar = getSidebar; |
{ | ||
"name": "typedoc-github-wiki-theme", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "A TypeDoc ( + typedoc-plugin-markdown ) theme that generates Markdown compatible with Github Wiki.", | ||
"main": "dist/index.js", | ||
"exports": { | ||
".": "./dist/index.js" | ||
}, | ||
"type": "module", | ||
"files": [ | ||
@@ -19,3 +22,3 @@ "dist/" | ||
"scripts": { | ||
"lint": "eslint ./src --ext .ts", | ||
"lint": "eslint ./src", | ||
"prepublishOnly": "npm run lint && npm run build", | ||
@@ -25,3 +28,3 @@ "prebuild": "rm -rf dist && prebuild-options", | ||
"build-and-test": "npm run build && npm run test", | ||
"pretest": "ts-node ./test/__scripts__/prepare.ts", | ||
"pretest": "tsx ./test/__scripts__/prepare.ts", | ||
"test": "jest", | ||
@@ -33,3 +36,3 @@ "test:update": "npm run build && npm test -- -u" | ||
"peerDependencies": { | ||
"typedoc-plugin-markdown": ">=4.0.0" | ||
"typedoc-plugin-markdown": ">=4.3.0" | ||
}, | ||
@@ -36,0 +39,0 @@ "keywords": [ |
@@ -5,10 +5,4 @@ # typedoc-github-wiki-theme | ||
> A TypeDoc ( + typedoc-plugin-markdown ) theme that generates docs compatible with Github Wiki. | ||
> A TypeDoc ( + typedoc-plugin-markdown ) theme that generates Markdown compatible with Github Wiki. | ||
## Installation | ||
```shell | ||
npm install typedoc-github-wiki-theme --save-dev | ||
``` | ||
## Documentation | ||
@@ -15,0 +9,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
19
Yes
7986
167
13