typedoc-gitlab-wiki-theme
Advanced tools
Comparing version 2.0.0-next.2 to 2.0.0-next.3
import { Application } from 'typedoc'; | ||
import { NavigationItem } from 'typedoc-plugin-markdown'; | ||
export declare function load(app: Application): void; | ||
export declare function navigation(navigationItems: NavigationItem[]): string; |
@@ -25,5 +25,9 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.load = void 0; | ||
exports.navigation = exports.load = void 0; | ||
const fs = __importStar(require("fs")); | ||
const presets_1 = __importDefault(require("./options/presets")); | ||
const theme_1 = require("./theme"); | ||
@@ -39,12 +43,4 @@ function load(app) { | ||
read(container) { | ||
Object.entries({ | ||
theme: 'gitlab-wiki', | ||
entryFileName: 'home.md', | ||
flattenOutputFiles: true, | ||
skipIndexPage: true, | ||
hideBreadcrumbs: true, | ||
hideInPageTOC: true, | ||
hidePageHeader: true, | ||
hidePageTitle: true, | ||
}).forEach(([key, value]) => { | ||
Object.entries(presets_1.default).forEach(([key, value]) => { | ||
container.setValue('theme', 'gitlab-wiki'); | ||
container.setValue(key, value); | ||
@@ -55,8 +51,23 @@ }); | ||
app.renderer.postRenderAsyncJobs.push(async (output) => { | ||
const navigation = app.renderer.theme | ||
.getRenderContext(null) | ||
.navigation(output.navigation); | ||
fs.writeFileSync(`${output.outputDirectory}/_sidebar.md`, navigation); | ||
fs.writeFileSync(`${output.outputDirectory}/_sidebar.md`, navigation(output.navigation)); | ||
}); | ||
} | ||
exports.load = load; | ||
function navigation(navigationItems) { | ||
const md = []; | ||
navigationItems.forEach((navigationItem) => { | ||
var _a, _b; | ||
if (navigationItem.url) { | ||
md.push(`- [${navigationItem.title}](${navigationItem.url})`); | ||
} | ||
if ((_a = navigationItem.children) === null || _a === void 0 ? void 0 : _a.length) { | ||
md.push(`## ${navigationItem.title} \n`); | ||
(_b = navigationItem.children) === null || _b === void 0 ? void 0 : _b.forEach((navItem) => { | ||
md.push(`- [${navItem.title}](${navItem.url})`); | ||
}); | ||
md.push('\n'); | ||
} | ||
}); | ||
return md.join('\n'); | ||
} | ||
exports.navigation = navigation; |
@@ -1,9 +0,5 @@ | ||
import { PageEvent, Reflection } from 'typedoc'; | ||
import { MarkdownTheme, MarkdownThemeRenderContext } from 'typedoc-plugin-markdown'; | ||
import { Reflection } from 'typedoc'; | ||
import { MarkdownPageEvent, MarkdownTheme } from 'typedoc-plugin-markdown'; | ||
export declare class GitlabWikiTheme extends MarkdownTheme { | ||
getRenderContext(pageEvent: PageEvent<Reflection>): ThemeRenderContext; | ||
getRenderContext(pageEvent: MarkdownPageEvent<Reflection>): any; | ||
} | ||
declare class ThemeRenderContext extends MarkdownThemeRenderContext { | ||
parseUrl(url: string): string; | ||
} | ||
export {}; |
@@ -7,3 +7,3 @@ "use strict"; | ||
getRenderContext(pageEvent) { | ||
return new ThemeRenderContext(pageEvent, this.application.options); | ||
return new ThemeRenderContext(this, pageEvent, this.application.options); | ||
} | ||
@@ -10,0 +10,0 @@ } |
{ | ||
"name": "typedoc-gitlab-wiki-theme", | ||
"version": "2.0.0-next.2", | ||
"description": "A typedoc-plugin-markdown theme that publishes Markdown pages compatible with Gitlab Wiki.", | ||
"version": "2.0.0-next.3", | ||
"description": "A TypeDoc ( + typedoc-plugin-markdown ) theme that generates docs compatible with Gitlab Wiki.", | ||
"main": "dist/index.js", | ||
@@ -21,4 +21,5 @@ "files": [ | ||
"prepublishOnly": "npm run lint && npm run build", | ||
"build": "rm -rf ./dist && tsc", | ||
"docs": "rm -rf ./demo && npm run build && typedoc --options ../../stubs/typedoc.1.js --plugin typedoc-plugin-markdown --plugin ./dist/index --out ./out" | ||
"prebuild": "rm -rf dist && prebuild-options", | ||
"build": "tsc", | ||
"docs": "rm -rf ./demo && npm run build && typedoc" | ||
}, | ||
@@ -28,3 +29,3 @@ "author": "Thomas Grey", | ||
"peerDependencies": { | ||
"typedoc-plugin-markdown": ">=4.0.0-next.13" | ||
"typedoc-plugin-markdown": ">=4.0.0-next.40" | ||
}, | ||
@@ -31,0 +32,0 @@ "keywords": [ |
# typedoc-gitlab-wiki-theme | ||
A [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/packages/typedoc-plugin-markdown/README.md) theme that publishes Markdown pages compatible with [Gitlab Wiki](https://docs.gitlab.com/ee/user/project/wiki/). | ||
![npm](https://img.shields.io/npm/v/typedoc-gitlab-wiki-theme%2Fnext?&logo=npm) ![Downloads](https://img.shields.io/npm/dm/typedoc-gitlab-wiki-theme) [![Build Status](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml/badge.svg?branch=next)](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml) | ||
[![npm](https://img.shields.io/npm/v/typedoc-gitlab-wiki-theme.svg)](https://www.npmjs.com/package/typedoc-gitlab-wiki-theme) | ||
![CI](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml/badge.svg?branch=master) | ||
A TypeDoc ( + typedoc-plugin-markdown ) theme that generates docs compatible with Gitlab Wiki. | ||
## What does it do? | ||
This theme customises the output from [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/packages/typedoc-plugin-markdown/README.md): | ||
- Generates Wiki friendly file names. | ||
- Updates internal urls to a compatible format. | ||
- Writes a `_sidebar.md` file to enable custom sidebar navigation. | ||
## Installation | ||
```shell | ||
npm install typedoc typedoc-plugin-markdown@next typedoc-gitlab-wiki-theme@next --save-dev | ||
``` | ||
npm install typedoc-gitlab-wiki-theme --save-dev | ||
``` | ||
## Usage | ||
## Documentation | ||
**typedoc.json** | ||
Please visit https://typedoc-plugin-markdown.org/themes/gitlab-wiki. | ||
```json | ||
{ | ||
"plugin": ["typedoc-plugin-markdown", "typedoc-gitlab-wiki-theme"] | ||
} | ||
``` | ||
## Options | ||
For options please refer to [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/packages/typedoc-plugin-markdown/README.md#options). | ||
The following options are preset with the theme: | ||
```json | ||
{ | ||
"entryFileName": "home.md", | ||
"flattenOutputFiles": true, | ||
"hideBreadcrumbs": true, | ||
"hideInPageTOC": true, | ||
"hidePageHeader": true, | ||
"hidePageTitle": true | ||
} | ||
``` | ||
## License | ||
[MIT](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/packages/typedoc-gitlab-wiki-theme/LICENSE) | ||
Released under the [MIT License](./LICENSE). |
Sorry, the diff of this file is not supported yet
9
110
7290
19