Skip to content

Commit bd2cce1

Browse files
shigmaulivz
authored andcommitted
docs: api (#1397)
1 parent 3d19f40 commit bd2cce1

31 files changed

+276
-33
lines changed

Diff for: packages/docs/docs/.vuepress/config.js

+11
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module.exports = ctx => ({
4343
lastUpdated: 'Last Updated',
4444
nav: require('./nav/en'),
4545
sidebar: {
46+
'/api/': getApiSidebar(),
4647
'/guide/': getGuideSidebar('Guide', 'Advanced'),
4748
'/plugin/': getPluginSidebar('Plugin', 'Introduction', 'Official Plugins'),
4849
'/theme/': getThemeSidebar('Theme', 'Introduction'),
@@ -55,6 +56,7 @@ module.exports = ctx => ({
5556
lastUpdated: '上次更新',
5657
nav: require('./nav/zh'),
5758
sidebar: {
59+
'/zh/api/': getApiSidebar(),
5860
'/zh/guide/': getGuideSidebar('指南', '深入'),
5961
'/zh/plugin/': getPluginSidebar('插件', '介绍', '官方插件'),
6062
'/zh/theme/': getThemeSidebar('主题', '介绍')
@@ -87,6 +89,15 @@ module.exports = ctx => ({
8789
],
8890
})
8991

92+
function getApiSidebar () {
93+
return [
94+
'',
95+
'config',
96+
'cli',
97+
'node'
98+
]
99+
}
100+
90101
function getGuideSidebar (groupA, groupB) {
91102
return [
92103
{

Diff for: packages/docs/docs/.vuepress/nav/en.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module.exports = [
44
link: '/guide/',
55
},
66
{
7-
text: 'Config Reference',
8-
link: '/config/'
7+
text: 'API',
8+
link: '/api/'
99
},
1010
{
1111
text: 'Plugin',

Diff for: packages/docs/docs/.vuepress/nav/zh.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module.exports = [
44
link: '/zh/guide/',
55
},
66
{
7-
text: '配置',
8-
link: '/zh/config/'
7+
text: 'API',
8+
link: '/zh/api/'
99
},
1010
{
1111
text: '插件',

Diff for: packages/docs/docs/api/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# API
2+
3+
We offer a variety of ways to use VuePress. This section will cover the following two sections:
4+
5+
- [Config Reference](./config.md)
6+
- [Node.js API](./node.md)
7+
- [Command Line Interface](./cli.md)

Diff for: packages/docs/docs/api/cli.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Command Line Interface
2+
3+
## Usage
4+
5+
```bash
6+
vuepress <command> targetDir [options]
7+
```
8+
9+
## build
10+
11+
Build dir as a static site.
12+
13+
### -p, --port `<port>`
14+
See [port](./config.md#port).
15+
16+
### -t, --temp `<temp>`
17+
See [temp](./config.md#temp).
18+
19+
### -c, --cache [cache]
20+
### -no--cache [cache]
21+
See [cache](./config.md#cache).
22+
23+
### --debug
24+
Start development server in debug mode.
25+
26+
### --silent
27+
Start development server in silent mode.
28+
29+
## dev
30+
31+
Start a development server. All options from `vuepress build` are available. And there are several options specifically for dev:
32+
33+
### --host `<host>`
34+
See [host](../config.md#host).
35+
36+
### --open
37+
Open browser when ready.
38+
39+
## eject
40+
41+
Copy the default theme into `.vuepress/theme` for customization.
42+
43+
## more commands
44+
45+
You can create a custom command with [extendCli](../plugin/option-api.md#extendcli).

Diff for: packages/docs/docs/config/README.md renamed to packages/docs/docs/api/config.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar: auto
2+
sidebarDepth: 3
33
---
44

55
# Config Reference
@@ -65,6 +65,13 @@ Specify the host to use for the dev server.
6565

6666
Specify the port to use for the dev server.
6767

68+
### temp
69+
70+
- Type: `number`
71+
- Default: `@vuepress/core/.temp`
72+
73+
Specify the temporary directory for client.
74+
6875
### dest
6976

7077
- Type: `string`

Diff for: packages/docs/docs/api/node.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Node.js API
2+
3+
```js
4+
const vuepress = require('vuepress')
5+
```
6+
7+
## Global Methods
8+
9+
### vuepress.dev
10+
11+
Start a development server.
12+
13+
### vuepress.build
14+
15+
Build dir as a static site.
16+
17+
### vuepress.eject
18+
19+
Copy the default theme into `.vuepress/theme` for customization.
20+
21+
### vuepress.createApp
22+
23+
Create a VuePress App for for customization. For example,
24+
25+
```js
26+
const app = vuepress.createApp(/* options */)
27+
app.process().then(() => {
28+
console.log('ready!')
29+
app.dev()
30+
})
31+
```
32+
33+
## App Options
34+
35+
### options.sourceDir
36+
37+
Specify the source directory for VuePress.
38+
39+
### options.theme
40+
41+
See [theme](../config.md#theme).
42+
43+
### options.plugins
44+
45+
See [plugins](../config.md#plugins).
46+
47+
### options.temp
48+
49+
See [temp](../config.md#temp).
50+
51+
### options.dest
52+
53+
See [dest](../config.md#dest).
54+
55+
### options.siteConfig
56+
57+
See [siteConfig](../config.md).

Diff for: packages/docs/docs/guide/assets.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ In addition, you can use the `~` prefix to explicitly indicate this is a webpack
1717
![Image from dependency](~some-dependency/image.png)
1818
```
1919

20-
webpack aliases can be configured via [configureWebpack](/config/#configurewebpack) in `.vuepress/config.js`. Example:
20+
webpack aliases can be configured via [configureWebpack](../api/config.md#configurewebpack) in `.vuepress/config.js`. Example:
2121

2222
``` js
2323
module.exports = {

Diff for: packages/docs/docs/guide/basic-config.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = {
2424

2525
If you've got the dev server running, you should see the page now has a header with the title and a search box. VuePress comes with built-in headers-based search - it automatically builds a simple search index from the title, `h2` and `h3` headers from all the pages.
2626

27-
Consult the [Config Reference](../config/README.md) for a full list of options.
27+
Consult the [Config Reference](../api/config.md) for a full list of options.
2828

2929
::: tip Alternative Config Formats
3030
You can also use YAML (`.vuepress/config.yml`) or TOML (`.vuepress/config.toml`) formats for the configuration file.

Diff for: packages/docs/docs/guide/directory-structure.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ For the above directory structure, the default page routing paths are as follows
6060

6161
**Also see:**
6262

63-
- [Config](../config/README.md)
64-
- [Theme](../theme/README.md)
63+
- [Config](../api/config.md)
64+
- [Theme](../theme/)
6565
- [Default Theme Config](../theme/default-theme-config.md)
6666

Diff for: packages/docs/docs/guide/markdown.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Header Anchors
44

5-
Headers automatically get anchor links applied. Rendering of anchors can be configured using the [`markdown.anchor`](../config/README.md#markdown-anchor) option.
5+
Headers automatically get anchor links applied. Rendering of anchors can be configured using the [`markdown.anchor`](../api/config.md#markdown-anchor) option.
66

77
## Links
88

@@ -53,7 +53,7 @@ Outbound links automatically gets `target="_blank" rel="noopener noreferrer"`:
5353
- [vuejs.org](https://vuejs.org)
5454
- [VuePress on GitHub](https://github.com/vuejs/vuepress)
5555

56-
You can customize the attributes added to external links by setting [config.markdown.externalLinks](../config/README.md#markdown-externallinks).
56+
You can customize the attributes added to external links by setting [config.markdown.externalLinks](../api/config.md#markdown-externallinks).
5757

5858
## Front Matter
5959

@@ -122,7 +122,7 @@ or
122122

123123
[[toc]]
124124

125-
Rendering of TOC can be configured using the [`markdown.toc`](../config/README.md#markdown-toc) option, or as props of [TOC component](./using-vue.md#toc), like `<TOC list-type="ol" :include-level="[2, Infinity]"/>`.
125+
Rendering of TOC can be configured using the [`markdown.toc`](../api/config.md#markdown-toc) option, or as props of [TOC component](./using-vue.md#toc), like `<TOC list-type="ol" :include-level="[2, Infinity]"/>`.
126126

127127
## Custom Containers
128128

Diff for: packages/docs/docs/guide/using-vue.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ yarn add -D pug pug-plain-loader
168168
::: tip
169169
If you are a Stylus user, you don't need to install `stylus` and `stylus-loader` in your project because VuePress uses Stylus internally.
170170

171-
For pre-processors that do not have built-in webpack config support, you will need to [extend the internal webpack config](../config/README.md#configurewebpack) in addition to installing the necessary dependencies.
171+
For pre-processors that do not have built-in webpack config support, you will need to [extend the internal webpack config](../api/config.md#configurewebpack) in addition to installing the necessary dependencies.
172172
:::
173173

174174
## Script & Style Hoisting

Diff for: packages/docs/docs/miscellaneous/migration-guide.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ See: [@vuepress/plugin-pwa > Migration from 0.x](../plugin/official/plugin-pwa.m
6565
Replaced by `.vuepress/styles/palette.styl`.
6666

6767
::: upgrade
68-
See: [Config > palette.styl](../config/README.md#palette-styl)
68+
See: [Config > palette.styl](../api/config.md#palette-styl)
6969
:::
7070

7171
### `.vuepress/style.styl` <Badge text="replaced"/>
7272

7373
Replaced by `.vuepress/styles/index.styl`.
7474

7575
::: upgrade
76-
See: [Config > index.styl](../config/README.md#index-styl)
76+
See: [Config > index.styl](../api/config.md#index-styl)
7777
:::

Diff for: packages/docs/docs/plugin/context-api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Output path.
4646

4747
- Type: `string`
4848

49-
See: [base](../config/README.md#base).
49+
See: [base](../api/config.md#base).
5050

5151
## ctx.writeTemp
5252

Diff for: packages/docs/docs/plugin/official/plugin-nprogress.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ $nprogressColor = red
3636

3737
**Also see:**
3838

39-
- [Config Reference > Styling](../../config/#styling)
39+
- [Config Reference > Styling](../../api/config.md#styling)

Diff for: packages/docs/docs/theme/default-theme-config.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ Note that it's `off` by default. If given a `string`, it will be displayed as a
379379
The `themeConfig.serviceWorker` option allows you to configure the service worker.
380380

381381
::: tip
382-
Please do not confuse this option with [Config > serviceWorker](../config/README.md#serviceworker), [Config > serviceWorker](../config/README.md#serviceworker) is **site-level**, while this option is **theme-level**.
382+
Please do not confuse this option with [Config > serviceWorker](../api/config.md#serviceworker), [Config > serviceWorker](../api/config.md#serviceworker) is **site-level**, while this option is **theme-level**.
383383
:::
384384

385385
### Popup UI to refresh contents <Badge text="0.13.0+"/> <Badge text="beta" type="warn"/>

Diff for: packages/docs/docs/theme/writing-a-theme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The compiled content of the current `.md` file being rendered will be available
2929

3030
## Directory Structure
3131

32-
Just one `Layout.vue` might not be enough, and you might also want to define more layout components in the theme for using on different pages. You may also want to customize the [palette](../config/README.md#palette-styl), and even apply some plugins.
32+
Just one `Layout.vue` might not be enough, and you might also want to define more layout components in the theme for using on different pages. You may also want to customize the [palette](../api/config.md#palette-styl), and even apply some plugins.
3333

3434
So it's time to reorganize your theme, an agreed theme directory structure is as follows:
3535

Diff for: packages/docs/docs/zh/api/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# API
2+
3+
我们提供了多种使用 VuePress 的方式。这一节将包括下面三个部分:
4+
5+
- [配置说明](./config.md)
6+
- [Node.js API](./node.md)
7+
- [命令行接口](./cli.md)

Diff for: packages/docs/docs/zh/api/cli.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# 命令行接口
2+
3+
## 基本用法
4+
5+
```bash
6+
vuepress <command> targetDir [options]
7+
```
8+
9+
## build
10+
11+
在指定的目录生成一个静态站点。
12+
13+
### -p, --port `<port>`
14+
查看 [port](./config.md#port)
15+
16+
### -t, --temp `<temp>`
17+
查看 [temp](./config.md#temp)
18+
19+
### -c, --cache [cache]
20+
### -no--cache [cache]
21+
查看 [cache](./config.md#cache)
22+
23+
### --debug
24+
以调试模式启动开发服务器。
25+
26+
### --silent
27+
以安静模式启动开发服务器。
28+
29+
## dev
30+
31+
启动一个开发服务器。来自 `vuepress build` 的所有选项都可用。除此以外,还有几个专门针对 dev 的选项:
32+
33+
### --host `<host>`
34+
查看 [host](./config.md#host)
35+
36+
### --open
37+
当服务端准备就绪时自动打开浏览器。
38+
39+
## eject
40+
41+
将默认主题复制到 `.vuepress/theme` 目录,以供自定义。
42+
43+
## more commands
44+
45+
你可以使用 [extendCli](../plugin/option-api.md#extendcli) 来创建自定义命令。

Diff for: packages/docs/docs/zh/config/README.md renamed to packages/docs/docs/zh/api/config.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar: auto
2+
sidebarDepth: 3
33
---
44

55
# 配置
@@ -63,6 +63,13 @@ module.exports = {
6363

6464
指定 dev server 的端口。
6565

66+
### temp
67+
68+
- Type: `number`
69+
- Default: `@vuepress/core/.temp`
70+
71+
指定客户端文件的临时目录。
72+
6673
### dest
6774

6875
- 类型: `string`

0 commit comments

Comments
 (0)