Skip to content

Commit

Permalink
fix: Added support for VuePress v2 (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Jul 25, 2022
1 parent b10ec14 commit 18af540
Show file tree
Hide file tree
Showing 37 changed files with 8,484 additions and 8,511 deletions.
4 changes: 4 additions & 0 deletions examples/vuepress-next/.gitignore
@@ -0,0 +1,4 @@
api
node_modules
.temp
.cache
33 changes: 33 additions & 0 deletions examples/vuepress-next/docs/.vuepress/config.ts
@@ -0,0 +1,33 @@
import { defaultTheme } from 'vuepress';
import { typedocPlugin } from 'vuepress-plugin-typedoc/next';

module.exports = {
title: 'VuePress Docs v2',
theme: defaultTheme({
navbar: [
{
text: 'Guide',
link: '/guide/',
},
{
text: 'API',
link: '/api/',
},
],
sidebar: {
'/guide/': [
{
text: 'Guide',
children: ['/guide/README.md'],
},
],
},
}),
plugins: [
typedocPlugin({
entryPoints: ['../../stub-project/src/index.ts'],
tsconfig: '../../stub-project/tsconfig.json',
cleanOutputDir: true,
}),
],
};
1 change: 1 addition & 0 deletions examples/vuepress-next/docs/README.md
@@ -0,0 +1 @@
# Hello VuePress 2
1 change: 1 addition & 0 deletions examples/vuepress-next/docs/guide/README.md
@@ -0,0 +1 @@
# Guide v2
16 changes: 16 additions & 0 deletions examples/vuepress-next/package.json
@@ -0,0 +1,16 @@
{
"name": "vuepress-example-v2",
"version": "0.0.0",
"private": true,
"scripts": {
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs && npx http-server ./docs/.vuepress/dist -o"
},
"devDependencies": {
"@vuepress/client": "^2.0.0-beta.49",
"typedoc-plugin-markdown": "*",
"vue": "^3.2.37",
"vuepress": "^2.0.0-beta.49",
"vuepress-plugin-typedoc": "*"
}
}
1 change: 1 addition & 0 deletions examples/vuepress/.gitignore
@@ -0,0 +1 @@
api
51 changes: 51 additions & 0 deletions examples/vuepress/docs/.vuepress/config.js
@@ -0,0 +1,51 @@
module.exports = {
/**
* Ref:https://v1.vuepress.vuejs.org/config/#title
*/
title: 'Vuepress Docs v1',

/**
* Theme configuration, here is the default theme configuration for VuePress.
*
* ref:https://v1.vuepress.vuejs.org/theme/default-theme-config.html
*/
themeConfig: {
repo: '',
editLinks: false,
docsDir: '',
editLinkText: '',
lastUpdated: false,
nav: [
{
text: 'Guide',
link: '/guide/',
},
{
text: 'API',
link: '/api/',
},
],
sidebar: {
'/guide/': [
{
title: 'Guide',
path: '/guide/',
},
],
},
},

/**
* Apply plugins,ref:https://v1.vuepress.vuejs.org/zh/plugin/
*/
plugins: [
[
'vuepress-plugin-typedoc',
{
entryPoints: ['../../stub-project/src/index.ts'],
tsconfig: '../../stub-project/tsconfig.json',
cleanOutputDir: true,
},
],
],
};
1 change: 1 addition & 0 deletions examples/vuepress/docs/README.md
@@ -0,0 +1 @@
# Hello VuePress 1
1 change: 1 addition & 0 deletions examples/vuepress/docs/guide/README.md
@@ -0,0 +1 @@
# Guide v1
16 changes: 16 additions & 0 deletions examples/vuepress/package.json
@@ -0,0 +1,16 @@
{
"name": "vuepress-example-v1",
"version": "0.0.0",
"private": true,
"scripts": {
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs && npx http-server ./docs/.vuepress/dist -o"
},
"devDependencies": {
"typedoc-plugin-markdown": "*",
"vue": "^2.6.10",
"vue-server-renderer": "2.6.11",
"vuepress": "^1.8.2",
"vuepress-plugin-typedoc": "*"
}
}
112 changes: 63 additions & 49 deletions packages/vuepress-plugin-typedoc/README.md
@@ -1,38 +1,39 @@
# vuepress-plugin-typedoc

A [VuePress](https://vuepress.vuejs.org/) plugin to build documentation with [TypeDoc](https://github.com/TypeStrong/typedoc).
A [VuePress](https://vuepress.vuejs.org/) plugin to build API documentation with [typedoc](https://github.com/TypeStrong/typedoc).

[![npm](https://img.shields.io/npm/v/vuepress-plugin-typedoc.svg)](https://www.npmjs.com/package/vuepress-plugin-typedoc)
[![Build Status](https://travis-ci.com/tgreyuk/typedoc-plugin-markdown.svg?branch=master)](https://travis-ci.com/tgreyuk/typedoc-plugin-markdown)

## What it does?

- Generates pages as part of the build.
- Adds Front Matter to pages.
- Generates sidebars config to enable navigation.
- Generates pages in Markdown as part of the build.
- Generates sidebar configuration.

## Installation

> Install in the same location as the VuePress root directory.
This guide assumes that a VuePress project has been setup. See [getting started docs](https://vuepress.vuejs.org/guide/getting-started.html).
> Install in the same location as your VuePress project root.
```shell
npm install typedoc typedoc-plugin-markdown vuepress-plugin-typedoc --save-dev
```

## Usage

### Config
### v1.x

- Setup a VuePress project https://v1.vuepress.vuejs.org/guide/getting-started.html.
- Add the plugin to `.vuepress/config.js` and specify the required options (see [options](#options)).
- TypeDoc will be bootstraped with the Vuepress `dev` and `build` [cli commands](https://vuepress.vuejs.org/api/cli.html).

Add the plugin to `.vuepress/config.js` and specify the required options (see [options](#options)).
#### `.vuepress/config.js`

```js
plugins: [
[
'vuepress-plugin-typedoc',

// Plugin / TypeDoc options
// plugin options
{
entryPoints: ['../src/index.ts'],
tsconfig: '../tsconfig.json'
Expand All @@ -41,23 +42,41 @@ plugins: [
],
```

TypeDoc will be bootstraped with the Vuepress `dev` and `build` [cli commands](https://vuepress.vuejs.org/api/cli.html):
### v2.x

- Setup a VuePress v2 project https://v2.vuepress.vuejs.org/guide/getting-started.html.
- Using a plugin via string is not supported. Import the plugin directly in `.vuepress/config.ts` under the `next` entrypoint and specify the required options (see [options](#options)).
- TypeDoc will be bootstraped with the Vuepress `dev` and `build` [cli commands](https://v2.vuepress.vuejs.org/reference/cli.html).

#### `.vuepress/config.ts`

```javascript
"dev": "vuepress dev [targetDir]",
"build": "vuepress build [targetDir]",
```ts
import { defaultTheme } from 'vuepress';
import { typedocPlugin } from 'vuepress-plugin-typedoc/next';

module.exports = {
theme: defaultTheme({}),
plugins: [
typedocPlugin({
// plugin options
entryPoints: ['../src/index.ts'],
tsconfig: '../tsconfig.json',
}),
],
};
```

Once built the docs will be available at `/api` or equivalent out directory.
### Typical project structure

```
docs/ (Vuepress website root)
├── src/
│ └── .vuepress
│ │ └───config.js
│ │ └───dist/ (static site dir)
│ └── api/ (compiled typedoc markdown)
│ └── .vuepress
│ │ └── config.js|ts
│ │ └── dist/ (static site dir)
│ └── api/ (output directory / compiled typedoc markdown)
├── package.json
├─ ─src (typescript source files)
├── tsconfig.json
```

## Options
Expand All @@ -76,7 +95,7 @@ tsconfig: '../tsconfig.json'
Additional TypeDoc plugins will need to be explicitly set:

```js
plugin:['typedoc-plugin-xyz']
plugin: ['typedoc-plugin-xyz'];
```

TypeDoc options can also be declared:
Expand All @@ -86,41 +105,36 @@ TypeDoc options can also be declared:

Note: Options declared in this manner will take priority and overwrite options declared in `docusaurus.config.js`.


### Plugin options

| Name | Default | Description |
| :----------------------- | :------ | :--------------------------------------------------------------------------- |
| `out` | `"api"` | Output directory relative to docs directory. |
| `hideInPageTOC` | `false` | Do not render in-page table of contents items. |
| `sidebar.fullNames` | `false` | Display full names with module path if applicable. |
| `sidebar.parentCategory` | `"API"` | The parent category label for sidebar. Pass `"none"` for no parent category. |
In addition to TypeDoc options there are some custom plugin options that can be configured.

| Name | Default | Description |
| :-------------------------- | :------ | :--------------------------------------------------------------------------- |
| `out` | `"api"` | Output directory relative to docs directory. |
| `hideInPageTOC` | `false` | Do not render in-page table of contents items. |
| `sidebar.autoConfiguration` | `true` | Set to `false` to disable auto sidebar configuration. |
| `sidebar.fullNames` | `false` | Display full names with module path if applicable. |
| `sidebar.parentCategory` | `"API"` | The parent category label for sidebar. Pass `"none"` for no parent category. |

### Example config
### Example options object

```js

plugins: [
[
'vuepress-plugin-typedoc',
{
// TypeDoc options
entryPoints: ['../src/index.ts'],
tsconfig: '../tsconfig.json',

// Plugin options
out: 'api',
sidebar: {
fullNames: true,
parentCategory: 'API',
},
},
],
],

{
// TypeDoc options
entryPoints: ['../src/index.ts'],
tsconfig: '../tsconfig.json',
cleanOutputDir: true

// Plugin options
out: 'api',
sidebar: {
fullNames: true,
parentCategory: 'API',
}
}
```

## License

[MIT](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/packages/vuepress-plugin-typedoc/LICENSE)
[MIT](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/packages/vuepress-plugin-typedoc/LICENSE)
27 changes: 14 additions & 13 deletions packages/vuepress-plugin-typedoc/package.json
@@ -1,8 +1,12 @@
{
"name": "vuepress-plugin-typedoc",
"version": "0.10.3",
"description": "A VuePress plugin to build api documentation with TypeDoc.",
"main": "dist/index.js",
"description": "A VuePress plugin to build API documentation with TypeDoc.",
"main": "./dist/v1/index.js",
"exports": {
".": "./dist/v1/index.js",
"./next": "./dist/v2/index.js"
},
"files": [
"dist/"
],
Expand All @@ -15,27 +19,24 @@
"directory": "packages/vuepress-plugin-typedoc"
},
"homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/vuepress-plugin-typedoc",
"author": "Thomas Grey",
"scripts": {
"lint": "eslint ./src --ext .ts",
"prepublishOnly": "yarn run lint && yarn run build",
"build": "rm -rf ./dist && tsc"
},
"peerDependencies": {
"typedoc": ">=0.23.0",
"typedoc-plugin-markdown": ">=3.13.0"
},
"devDependencies": {
"typedoc-plugin-markdown": "^3.13.0"
},
"scripts": {
"lint": "eslint ./src --ext .ts",
"prepublishOnly": "yarn run lint && yarn run build",
"build": "rm -rf ./dist && tsc",
"test:init": "rm -rf test/site && yarn create vuepress-site test/site",
"test:demo:start": "yarn run build && cd test/site/docs && yarn run dev",
"test:demo:build": "yarn run build && cd test/site/docs && yarn run build && npx http-server ./src/.vuepress/dist -o"
"typedoc-plugin-markdown": ">=3.13.0"
},
"author": "Thomas Grey",
"license": "MIT",
"keywords": [
"vuepress",
"vuepress-plugin",
"typedoc",
"plugin",
"markdown",
"typescript",
"api"
Expand Down
3 changes: 0 additions & 3 deletions packages/vuepress-plugin-typedoc/src/index.ts

This file was deleted.

0 comments on commit 18af540

Please sign in to comment.