Skip to content

Commit 9bab45f

Browse files
committed
docs($core): update node api
1 parent 1c2a6b2 commit 9bab45f

File tree

2 files changed

+139
-54
lines changed

2 files changed

+139
-54
lines changed

packages/docs/docs/api/node.md

Lines changed: 67 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,99 @@
1-
# Node.js API
1+
# Node.js API <Badge text="1.0.0-alpha.44+"/>
2+
3+
## Usage
24

35
```js
4-
const vuepress = require('vuepress')
6+
const { createApp, dev, build, eject } = require('vuepress')
57
```
68

7-
## Global Methods
9+
## Methods
10+
11+
### createApp(\[options]): Promise\<App>
12+
13+
Create a VuePress application.
14+
15+
#### App.prototype.process: () => Promise\<void> | never
16+
17+
A asynchronous method used to prepare the context of the current app. which contains loading pages and plugins, apply plugins, etc.
818

9-
### vuepress.dev
19+
#### App.prototype.dev: () => Promise\<App> | never
1020

11-
Start a development server.
21+
Launch a dev process with current app context.
1222

13-
### vuepress.build
23+
#### App.prototype.build: () => Promise\<App> | never
1424

15-
Build dir as a static site.
25+
Launch a build process with current app context.
1626

17-
### vuepress.eject
1827

19-
Copy the default theme into `.vuepress/theme` for customization.
28+
### dev(\[options]): Promise\<App>
29+
30+
Start a development server, actually it's implemented by `createApp`:
31+
32+
```js
33+
async function dev (options) {
34+
const app = createApp(options)
35+
await app.process()
36+
return app.dev()
37+
}
38+
```
2039

21-
### vuepress.createApp
40+
### build(\[options]): Promise\<App>
2241

23-
Create a VuePress App for for customization. For example,
42+
Build your source files as a static site, actually it's implemented by `createApp`:
2443

2544
```js
26-
const app = vuepress.createApp(/* options */)
27-
app.process().then(() => {
28-
console.log('ready!')
29-
app.dev()
30-
})
45+
async function build (options) {
46+
const app = createApp(options)
47+
await app.process()
48+
return app.build()
49+
}
3150
```
3251

33-
## App Options
52+
### eject(targetDir): Promise\<void>
3453

35-
### options.sourceDir
54+
Copy the default theme into `{targetDir}/.vuepress/theme` for customization.
3655

37-
Specify the source directory for VuePress.
3856

39-
### options.theme
57+
## Options
58+
59+
### sourceDir
60+
61+
- Type: `string`
62+
- Required: `true`
63+
64+
Specify the source directory of your VuePress site.
65+
66+
### theme
67+
68+
- Type: `string`
69+
- Required: `false`
4070

4171
See [theme](../config/README.md#theme).
4272

43-
### options.plugins
73+
### plugins
74+
75+
- Type: `array`
76+
- Required: `false`
4477

4578
See [plugins](../config/README.md#plugins).
4679

47-
### options.temp
80+
### temp
81+
82+
- Type: `string`
83+
- Required: `false`
4884

4985
See [temp](../config/README.md#temp).
5086

51-
### options.dest
87+
### dest
88+
89+
- Type: `string`
90+
- Required: `false`
5291

5392
See [dest](../config/README.md#dest).
5493

55-
### options.siteConfig
94+
### siteConfig
95+
96+
- Type: `object`
97+
- Required: `{}`
5698

57-
See [siteConfig](../config/README.md).
99+
It's very useful when you're writing tests and don't want to depend on actual config file, for all options please head [siteConfig](../config/README.md).

packages/docs/docs/zh/api/node.md

Lines changed: 72 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,100 @@
1-
# Node.js API
1+
# Node.js API <Badge text="1.0.0-alpha.44+"/>
2+
3+
## 使用
24

35
```js
4-
const vuepress = require('vuepress')
6+
const { createApp, dev, build, eject } = require('vuepress')
57
```
68

7-
## 全局方法
9+
## 方法
10+
11+
### createApp(\[options]): Promise\<App>
12+
13+
创建一个 VuePress 应用实例。
14+
15+
#### App.prototype.process: () => Promise\<void> | never
16+
17+
用于准备当前站点上下文的异步方法。其中包含加载页面和插件、应用插件等。
818

9-
### vuepress.dev
19+
#### App.prototype.dev: () => Promise\<App> | never
1020

11-
启动一个开发服务器。
21+
使用当前应用程序上下文启动一个 devProcess.
1222

13-
### vuepress.build
1423

15-
生成一个静态站点。
24+
#### App.prototype.build: () => Promise\<App> | never
1625

17-
### vuepress.eject
26+
使用当前应用程序上下文启动一个 buildProcess.
1827

19-
将默认主题复制到 `.vuepress/theme` 目录,以供自定义。
28+
### dev(\[options]): Promise\<App>
2029

21-
### vuepress.createApp
30+
启动一个 Dev Server,实际上它是由 `createapp` 实现的:
2231

23-
创建一个 VuePress 应用。
32+
```js
33+
async function dev (options) {
34+
const app = createApp(options)
35+
await app.process()
36+
return app.dev()
37+
}
38+
```
39+
40+
### build(\[options]): Promise\<App>
41+
42+
将源文件构建为静态站点, 实际上它是由 `createapp` 实现的:
2443

2544
```js
26-
const app = vuepress.createApp(/* options */)
27-
app.process().then(() => {
28-
console.log('ready!')
29-
app.dev()
30-
})
45+
async function build (options) {
46+
const app = createApp(options)
47+
await app.process()
48+
return app.build()
49+
}
3150
```
3251

33-
## App 选项
52+
### eject(targetDir): Promise\<void>
53+
54+
将默认主题复制到 `{targetDir}/.vuepress/theme`中进行自定义。
55+
56+
57+
## Options
58+
59+
### sourceDir
60+
61+
- 类型: `string`
62+
- 默认值: `true`
63+
64+
指定 VuePress 站点的源目录。
65+
66+
### theme
67+
68+
- 类型: `string`
69+
- 默认值: `false`
70+
71+
参见 [theme](../config/README.md#theme)
72+
73+
### plugins
3474

35-
### options.sourceDir
75+
- 类型: `array`
76+
- 默认值: `false`
3677

37-
指定 VuePress 的根目录
78+
参见 [plugins](../config/README.md#plugins)
3879

39-
### options.theme
80+
### temp
4081

41-
查看 [theme](../config/README.md#theme)
82+
- 类型: `string`
83+
- 默认值: `false`
4284

43-
### options.plugins
85+
参见 [temp](../config/README.md#temp)
4486

45-
查看 [plugins](../config/README.md#plugins)
87+
### dest
4688

47-
### options.temp
89+
- 类型: `string`
90+
- 默认值: `false`
4891

49-
查看 [temp](../config/README.md#temp)
92+
参见 [dest](../config/README.md#dest)
5093

51-
### options.dest
94+
### siteConfig
5295

53-
查看 [dest](../config/README.md#dest)
96+
- 类型: `object`
97+
- 默认值: `{}`
5498

55-
### options.siteConfig
99+
当你想编写测试且不想依赖于实际的配置文件时,它将非常有用。想要查看所有的配置选项,请移步 [siteConfig](../config/README.md)
56100

57-
查看 [siteConfig](../config/README.md)

0 commit comments

Comments
 (0)