typedoc-github-wiki-theme
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -1,2 +0,2 @@ | ||
import { DeclarationReflection, Reflection } from 'typedoc'; | ||
import { DeclarationReflection, ProjectReflection, Reflection } from 'typedoc'; | ||
import MarkdownTheme from 'typedoc-plugin-markdown/dist/theme'; | ||
@@ -8,7 +8,10 @@ import { RendererEvent } from 'typedoc/dist/lib/output/events'; | ||
renderer: Renderer; | ||
entryPoints: string[]; | ||
readme: string; | ||
constructor(renderer: Renderer, basePath: string); | ||
getUrls(project: ProjectReflection): import("typedoc").UrlMapping[]; | ||
toUrl(mapping: TemplateMapping, reflection: DeclarationReflection): string; | ||
getUrl(reflection: Reflection): string; | ||
onRendererEnd(renderer: RendererEvent): void; | ||
get globalsFile(): string; | ||
get globalsFile(): "Modules.md" | "Exports.md"; | ||
} |
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const fs = require("fs-extra"); | ||
const typedoc_1 = require("typedoc"); | ||
const theme_1 = require("typedoc-plugin-markdown/dist/theme"); | ||
const plugins_1 = require("typedoc/dist/lib/converter/plugins"); | ||
const events_1 = require("typedoc/dist/lib/output/events"); | ||
@@ -11,20 +19,21 @@ const utils_1 = require("./components/utils"); | ||
this.renderer = renderer; | ||
renderer.addComponent('github-wiki-utils', new utils_1.UtilsComponent(renderer)); | ||
this.renderer.application.options.setValue('entryDocument', 'Home.md'); | ||
this.renderer.application.options.setValue('hideInPageTOC', true); | ||
this.renderer.application.options.setValue('hideBreadcrumbs', true); | ||
this.renderer.application.options.setValue('hidePageTitle', true); | ||
renderer.addComponent('utils', new utils_1.UtilsComponent(renderer)); | ||
this.listenTo(renderer, events_1.RendererEvent.END, this.onRendererEnd, 1024); | ||
} | ||
getUrls(project) { | ||
return super.getUrls(project).map((urlMapping) => { | ||
if (this.readme !== 'none' && project.url === urlMapping.url) { | ||
return { | ||
...urlMapping, | ||
url: this.entryPoints.length > 1 ? 'Modules.md' : 'Exports.md', | ||
}; | ||
} | ||
return urlMapping; | ||
}); | ||
} | ||
toUrl(mapping, reflection) { | ||
const kindLabelMap = { | ||
modules: 'Module', | ||
classes: 'Class', | ||
interfaces: 'Interface', | ||
functions: 'Function', | ||
enums: 'Enum', | ||
}; | ||
return ((kindLabelMap[mapping.directory] || mapping.directory) + | ||
': ' + | ||
this.getUrl(reflection) + | ||
'.md'); | ||
return `${plugins_1.GroupPlugin.getKindSingular(reflection.kind)}: ${this.getUrl(reflection)}.md`; | ||
} | ||
@@ -36,29 +45,33 @@ getUrl(reflection) { | ||
onRendererEnd(renderer) { | ||
var _a; | ||
const parseUrl = (url) => '../wiki/' + url.replace('.md', ''); | ||
const navigation = this.getNavigation(renderer.project); | ||
const navJson = [ | ||
`## [${renderer.project.name}](${parseUrl(this.entryDocument)})\n`, | ||
]; | ||
if (this.readme !== 'none') { | ||
navJson.push(`- [Modules](${parseUrl(this.globalsFile)})`); | ||
} | ||
if (navigation.children) { | ||
navigation.children.forEach((navItem) => { | ||
var _a; | ||
if (navItem.isLabel) { | ||
navJson.push(`\n### ${navItem.title}\n`); | ||
(_a = navItem.children) === null || _a === void 0 ? void 0 : _a.forEach((navItemChild) => { | ||
const longTitle = navItemChild.title.split('.'); | ||
const shortTitle = longTitle[longTitle.length - 1]; | ||
navJson.push(`- [${shortTitle}](${parseUrl(encodeURI(navItemChild.url))})`); | ||
}); | ||
} | ||
}); | ||
} | ||
fs.outputFileSync(renderer.outputDirectory + '/_Sidebar.md', navJson.join('\n')); | ||
const navJson = [`## ${renderer.project.name}\n`]; | ||
(_a = navigation.children) === null || _a === void 0 ? void 0 : _a.forEach((navItem) => { | ||
var _a; | ||
if (navItem.isLabel) { | ||
navJson.push(`\n### ${navItem.title}\n`); | ||
(_a = navItem.children) === null || _a === void 0 ? void 0 : _a.forEach((navItemChild) => { | ||
const longTitle = navItemChild.title.split('.'); | ||
const shortTitle = longTitle[longTitle.length - 1]; | ||
navJson.push(`- [${shortTitle}](${parseUrl(encodeURI(navItemChild.url))})`); | ||
}); | ||
} | ||
else { | ||
const title = navItem.url === this.entryDocument ? 'Home' : navItem.title; | ||
navJson.push(`- [${title}](${parseUrl(navItem.url)})`); | ||
} | ||
}); | ||
fs.outputFileSync(renderer.outputDirectory + '/_Sidebar.md', navJson.join('\n') + '\n'); | ||
} | ||
get globalsFile() { | ||
return 'Modules.md'; | ||
return this.entryPoints.length > 1 ? 'Modules.md' : 'Exports.md'; | ||
} | ||
} | ||
__decorate([ | ||
typedoc_1.BindOption('entryPoints') | ||
], GithubWikiTheme.prototype, "entryPoints", void 0); | ||
__decorate([ | ||
typedoc_1.BindOption('readme') | ||
], GithubWikiTheme.prototype, "readme", void 0); | ||
exports.default = GithubWikiTheme; |
{ | ||
"name": "typedoc-github-wiki-theme", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "An extension of the default theme from typedoc-plugin-markdown to create a compatible file structure for Github Wiki pages.", | ||
@@ -21,6 +21,6 @@ "main": "dist/theme.js", | ||
"prepublishOnly": "npm run lint && npm run build && npm run test", | ||
"build": "rm -rf ./dist && tsc && copyfiles --up 1 ./src/**/*.hbs ./dist/", | ||
"build": "rm -rf ./dist && tsc", | ||
"test": "jest --colors", | ||
"build-and-test": "npm run build && npm run test", | ||
"demo": "rm -rf ./demo && npm run build && typedoc ../typedoc-plugin-markdown/test/stubs/src/index.ts --tsconfig ../typedoc-plugin-markdown/test/stubs/tsconfig.json --theme ./dist --disableOutputCheck --out ./demo" | ||
"demo": "rm -rf ./demo && npm run build && typedoc --readme none --entryPoints ../typedoc-plugin-markdown/test/stubs/src/index.ts --tsconfig ../typedoc-plugin-markdown/test/stubs/tsconfig.json --theme ./dist --out ./demo" | ||
}, | ||
@@ -33,9 +33,7 @@ "author": "Thomas Grey", | ||
}, | ||
"devDependencies": { | ||
"typedoc": "0.20.13", | ||
"typedoc-plugin-markdown": "*", | ||
"typescript": "^4.0.5" | ||
}, | ||
"keywords": [], | ||
"gitHead": "a80f25930cbe0462a4ea2ebd28f3093521b7132b" | ||
"keywords": [ | ||
"typedoc", | ||
"githubwiki" | ||
], | ||
"gitHead": "5c29035c5b98686c7e065dd7491a59309a707f9f" | ||
} |
# typedoc-github-wiki-theme | ||
An extension of the default theme from [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/typedoc-plugin-markdown) to create a compatible file structure for Github Wiki pages. | ||
A [Github Wiki](https://docs.github.com/en/communities/documenting-your-project-with-wikis/about-wikis) compatible [TypeDoc](https://github.com/TypeStrong/typedoc) theme. | ||
[![npm](https://img.shields.io/npm/v/typedoc-github-wiki-theme.svg)](https://www.npmjs.com/package/typedoc-github-wiki-theme) | ||
[![Build Status](https://travis-ci.org/tgreyuk/typedoc-plugin-markdown.svg?branch=master)](https://travis-ci.org/tgreyuk/typedoc-plugin-markdown) | ||
## What is does? | ||
- Generates Wiki friendly file names. | ||
- Updates internal urls to a compatible format. | ||
- Writes a `_Sidebar.md` file to enable custom sidebar navigation. | ||
## Installation | ||
@@ -18,1 +25,5 @@ | ||
``` | ||
## License | ||
[MIT](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/packages/typedoc-github-wiki-theme/LICENSE) |
10182
0
8
118
28