Skip to content

Commit

Permalink
Merge branch 'next-vuepress' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Apr 29, 2023
2 parents 91ac164 + 3bc6449 commit 037af87
Show file tree
Hide file tree
Showing 17 changed files with 229 additions and 189 deletions.
2 changes: 1 addition & 1 deletion examples/vuepress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"scripts": {
"publish-typedoc": "typedoc --plugin ../../packages/typedoc-plugin-markdown/dist --plugin ../../packages/vuepress-plugin-typedoc/dist --kindsWithOwnFile \"none\" --options \"../../stubs/typedoc.json\"",
"publish-typedoc": "typedoc --plugin ../../packages/typedoc-plugin-markdown/dist --plugin ../../packages/vuepress-plugin-typedoc/dist --options \"../../stubs/typedoc.json\"",
"predocs:dev": "npm run publish-typedoc",
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs && npx http-server ./docs/.vuepress/dist -o"
Expand Down
107 changes: 0 additions & 107 deletions packages/typedoc-plugin-vuepress/README.md

This file was deleted.

69 changes: 0 additions & 69 deletions packages/typedoc-plugin-vuepress/src/index.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
134 changes: 134 additions & 0 deletions packages/typedoc-vuepress-theme/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# typedoc-vuepress-theme

A [TypeDoc](https://github.com/TypeStrong/typedoc) plugin that publishes Markdown pages compatible with [VuePress](https://vuepress.vuejs.org/).

[![npm](https://img.shields.io/npm/v/vuepress-plugin-typedoc.svg)](https://www.npmjs.com/package/vuepress-plugin-typedoc)
![CI](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml/badge.svg?branch=master)

> Previously this project was consumed as a VuePress plugin. However in hindsight this was an overly complicated abstraction.
## Installation

Install the plugin in the same location as your VuePress project root.

[TypeDoc](https://github.com/TypeStrong/typedoc) and [TypeDoc Plugin Markdown](https://github.com/tgreyuk/typedoc-plugin-markdown) are required peer dependencies.

```shell
npm install typedoc typedoc-plugin-markdown@next typedoc-vuepress-theme@next --save-dev
```

### Typical project structure

```
│ docs/ (docs root)
│ └── .vuepress
│ │ └── config.js|ts (VuePress config)
│ │ └── dist/ (static site dir)
| |
│ └── api/ (output directory / compiled typedoc markdown and generated typedoc-sidebar.json file)
├── package.json (vuepress project package.json)
├── tsconfig.json
```

## Usage

Simply build TypeDoc pages and then bootstrap VuePress. The following is a guideline only and can be tailored as required.

### 1. Create a script to build Markdown pages

Please refer to [TypeDoc](https://github.com/TypeStrong/typedoc) for general TypeDoc usage.

```js
"publish-typedoc": "typedoc --options typedoc.json"
```

`typedoc.json`

```json
{
"entryPoints": ["../src"],
"tsconfig": "../src/tsconfig.json",
"plugin": ["typedoc-plugin-markdown", "typedoc-vuepress-theme"],
"sidebar": { "autoConfiguration": true, "version": "v1" }
}
```

### 2. Run the script before bootstrapping VuePress

```json
"docs:dev": "npm run publish-typedoc && vuepress dev docs",
"docs:build": "npm run publish-typedoc && vuepress build docs && npx http-server ./docs/.vuepress/dist -o"
```

### 3. Configure Navbar and Sidebar

A VuePress sidebar can be auto-generated for documentation can be generated with the `--sidebar` option targetting a specific version.

#### V1

`docs/.vuepress/config.js`

```js
const typedocSidebar = require('../api/typedoc-sidebar.json');

themeConfig: {
nav: [
{
text: 'API',
link: '/api/',
},
],
sidebar: {
// the out directory (./docs/api)
'/api/': [
{
title: 'API',
children: typedocSidebar,
},
],
},
}
```

#### V2

`docs/.vuepress/config.ts`

```js
import typedocSidebar from '../api/typedoc-sidebar.json';

module.exports = {
theme: defaultTheme({
navbar: [
{
text: 'API',
link: '/api/',
},
],
sidebar: {
// the out directory (./docs/api)
'/api/': [
{
text: 'API',
children: typedocSidebar,
},
],
},
}),
};
```

## Options

### Plugin options

In addition to TypeDoc options there are some custom plugin options that can be configured.

- **`--sidebar`**<br>
The target version of VuePress. Expected values [`none` `v1` `v2`]. Defaults to `none` (no sidebar generated).
- **`--sourceDir`**<br>
The VuePress docs folder. The Defaults to `./docs`.

## License

[MIT](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/packages/vuepress-plugin-typedoc/LICENSE)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typedoc-vuepress-theme",
"version": "0.0.0",
"version": "1.0.0",
"description": "A TypeDoc plugin to build API documentation to be consumed with VuePress.",
"main": "./dist/index.js",
"files": [
Expand All @@ -12,25 +12,24 @@
"repository": {
"type": "git",
"url": "git+https://github.com/tgreyuk/typedoc-plugin-vuepress.git",
"directory": "packages/typedoc-plugin-vuepress"
"directory": "packages/typedoc-vuepress-theme"
},
"homepage": "https://github.com/tgreyuk/typedoc-plugin-vuepress/tree/master/packages/vuepress-plugin-typedoc",
"homepage": "https://github.com/tgreyuk/typedoc-plugin-vuepress/tree/master/packages/typedoc-vuepress-theme",
"author": "Thomas Grey",
"scripts": {
"lint": "eslint ./src --ext .ts",
"prepublishOnly": "npm run lint && npm run build",
"build": "rm -rf ./dist && tsc",
"docs": "rm -rf ./demo && npm run build && typedoc --options ../../stubs/typedoc.json --plugin typedoc-plugin-markdown --vuepressVersion \"v2\" --plugin ./dist/index --out ./out"
"docs": "npm run build && npm-run-all docs:*",
"docs:v1": "typedoc --options ./test/typedoc-v1.json --out docs/v1",
"docs:v2": "typedoc --options ./test/typedoc-v2.json --out docs/v2"
},
"peerDependencies": {
"typedoc-plugin-markdown": ">=4.0.0-next.8"
},
"license": "MIT",
"keywords": [
"vuepress",
"typedoc",
"markdown",
"typescript",
"api"
"typedoc"
]
}

0 comments on commit 037af87

Please sign in to comment.