Skip to content

Commit 1e5fcff

Browse files
committed
feat: publicize doc implemetation
1 parent 55b9b04 commit 1e5fcff

File tree

372 files changed

+50636
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

372 files changed

+50636
-0
lines changed

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintrc.js

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// http://eslint.org/docs/user-guide/configuring
2+
3+
module.exports = {
4+
root: true,
5+
parserOptions: {
6+
parser: 'babel-eslint',
7+
sourceType: 'module'
8+
},
9+
extends: [
10+
// https://github.com/vuejs/eslint-plugin-vue#bulb-rules
11+
'plugin:vue/essential',
12+
'plugin:vue/recommended',
13+
'plugin:vue/strongly-recommended',
14+
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
15+
'standard',
16+
'prettier/standard'
17+
],
18+
// required to lint *.vue files
19+
plugins: ['vue'],
20+
// add your custom rules here
21+
rules: {
22+
// allow paren-less arrow functions
23+
'arrow-parens': 0,
24+
// allow async-await
25+
'generator-star-spacing': 0,
26+
// allow debugger during development
27+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
28+
'no-multi-spaces': ['error', { ignoreEOLComments: true }],
29+
'no-template-curly-in-string': 0,
30+
// to many false positives
31+
'vue/no-side-effects-in-computed-properties': 0,
32+
// fix unused var error for JSX custom tags
33+
'vue/jsx-uses-vars': 2,
34+
'vue/require-default-prop': 0,
35+
'vue/name-property-casing': ['error', 'kebab-case'],
36+
'vue/component-name-in-template-casing': ['error', 'kebab-case'],
37+
'vue/html-indent': [
38+
'error',
39+
2,
40+
{
41+
attribute: 1,
42+
baseIndent: 0,
43+
closeBracket: 0,
44+
alignAttributesVertically: true
45+
}
46+
],
47+
'vue/html-self-closing': [
48+
'error',
49+
{
50+
html: {
51+
void: 'never',
52+
normal: 'always',
53+
component: 'always'
54+
},
55+
svg: 'always',
56+
math: 'always'
57+
}
58+
],
59+
'vue/html-closing-bracket-spacing': [
60+
'error',
61+
{
62+
startTag: 'never',
63+
endTag: 'never',
64+
selfClosingTag: 'never'
65+
}
66+
],
67+
'vue/no-v-html': 0
68+
}
69+
}

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
node_modules
2+
npm-debug.log
3+
one/build/deps.json
4+
.DS_Store
5+
.nuxt
6+
.vscode
7+
pages
8+
components/demos
9+
dist
10+
logs
11+
assets/data
12+
static/images/mermaid

README.md

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# veui/docs
2+
3+
> VEUI 文档。
4+
5+
## 本地安装
6+
7+
`git clone` 到本地后,在项目根目录下运行:
8+
9+
```shell
10+
npm i
11+
npm run dev
12+
```
13+
14+
后在浏览访问 `http://localhost:3000` 即可。
15+
16+
## 文档编写
17+
18+
开发相关文档位于 `one/docs/development` 下。文档目录结构与网站的目录结构一致,新建 `.md` 文件后需要在 `one/docs/nav.json` 中新建相应的条目,作为目录配置。添加 `sub: true` 将缩进一个层级。
19+
20+
### 组件文档结构
21+
22+
每个组件的文档请按如下顺序编写:
23+
24+
1. 示例
25+
2. API
26+
27+
1. 属性
28+
2. 插槽
29+
3. 作用域插槽
30+
4. 事件
31+
5. 方法
32+
33+
3. 全局配置
34+
35+
1. `veui` 中的默认
36+
2. `veui-theme-dls` 中的默认配置
37+
38+
4. 图标名称
39+
40+
另外,如有关联组件请在最开始进行说明。比如:
41+
42+
```md
43+
:::tip
44+
`Select` 组件可以内联 [`Option`](./option) 或 [`OptionGroup`](./option-group) 组件使用。
45+
:::
46+
```
47+
48+
### 在文档中插入示例
49+
50+
使用 Markdown 的 shortcode 语法,如下:
51+
52+
```md
53+
[[ demo src="../demo/button.vue"]]
54+
```
55+
56+
路径为 demo 文件相对于当前文档文件的路径。Demo 文件是一个 Vue 单文件组件,最后会将代码展示到文档中。可以编写多个 `<style>` 块,如果带上自定义的 `docs` 属性,则会从文档的源码中去除,用来写一些不想输出到文档里的样式(建议文档里只展示和演示的用法相关的样式代码)。
57+
58+
可以为 demo 书写内嵌的说明,方法为在 demo 文件中增加 `<docs>` 自定义块,比如:
59+
60+
```html
61+
<docs>
62+
具体内容请参考项目 [repo](https://github.com/ecomfe/veui)。
63+
</docs>
64+
```
65+
66+
### 扩展 Markdown 语法
67+
68+
#### 自定义块
69+
70+
因为 Markdown 原生不支持对特定区块设定自定义的 `class`,直接书写 HTML 标签的话内部的内容就无法直接写 Markdown 了。故扩展了如下自定义块的语法:
71+
72+
```md
73+
:::tip
74+
这是一条小贴士。
75+
:::
76+
```
77+
78+
将会渲染为:
79+
80+
```html
81+
<div class="tip custom-block">这是一条小贴士。</div>
82+
```
83+
84+
目前支持的状态类型有 `tip`/`warning`/`alert`
85+
86+
标注 `v-model``.sync` 的属性/事件请使用如下格式:
87+
88+
```md
89+
:::badges
90+
`v-model`
91+
:::
92+
```
93+
94+
#### 内联引用
95+
96+
Markdown 中书写表格比较麻烦,如果想在里面嵌入格式比较复杂的内容,原生语法 + GFM 扩展都是不够用的。这里提供了一个定义可被引用内容+将对应内容块内联到文档内任意位置的语法。
97+
98+
定义可被引用的内容:
99+
100+
```md
101+
^^^ui
102+
内容
103+
^^^
104+
```
105+
106+
引用方式和脚注的引用方式相同,只是会将内容直接嵌入当前位置:
107+
108+
```md
109+
[^ui]
110+
```
111+
112+
#### 可折叠区块
113+
114+
有时内容过长不利于阅读全文,故扩展了如下语法支持默认收起的区块,可点击展开。
115+
116+
```md
117+
+++摘要内容
118+
详细内容
119+
+++
120+
```
121+
122+
## 文案规范
123+
124+
参见[《中文文案排版指北》](https://github.com/sparanoid/chinese-copywriting-guidelines)

app.html

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html {{ HTML_ATTRS }}>
3+
<head>
4+
{{ HEAD }}
5+
</head>
6+
<body {{ BODY_ATTRS }}>
7+
{{ APP }}
8+
</body>
9+
</html>

app.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const express = require('express')
2+
const nuxt = require('nuxt')
3+
const { Nuxt, Builder } = nuxt
4+
5+
const app = express()
6+
const host = process.env.HOST || '127.0.0.1'
7+
const port = process.env.PORT || 8080
8+
9+
// uncaughtException 避免程序崩溃
10+
process.on('uncaughtException', function (err) {
11+
console.error(err)
12+
try {
13+
let killTimer = setTimeout(function () {
14+
process.exit(1)
15+
}, 10000)
16+
killTimer.unref()
17+
server.close()
18+
} catch (e) {
19+
console.error('Fail to close server safely. ', e.stack)
20+
}
21+
})
22+
23+
app.set('port', port)
24+
25+
// Import and Set Nuxt.js options
26+
const config = require('./nuxt.config.js')
27+
config.dev = !(process.env.NODE_ENV === 'production')
28+
29+
// Init Nuxt.js
30+
const server = new Nuxt(config)
31+
32+
// Build only in dev mode
33+
if (config.dev) {
34+
const builder = new Builder(server)
35+
builder.build()
36+
}
37+
38+
// Give nuxt middleware to express
39+
app.use(server.render)
40+
41+
// Listen the server
42+
app.listen(port, host)
43+
console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console

app/router.scrollBehavior.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export default function scrollBehavior (to) {
2+
// if the returned position is falsy or an empty object,
3+
// will retain current scroll position.
4+
let position = false
5+
6+
// if no children detected
7+
if (to.matched.length < 2) {
8+
// scroll to the top of the page
9+
position = { x: 0, y: 0 }
10+
} else if (
11+
to.matched.some(r => r.components.default.options.scrollToTop)
12+
) {
13+
// if one of the children has scrollToTop option set to true
14+
position = { x: 0, y: 0 }
15+
} else if (
16+
to.hash &&
17+
document.querySelector(decodeURIComponent(to.hash))
18+
) {
19+
// scroll to anchor by returning the selector
20+
position = { selector: to.hash }
21+
}
22+
return position
23+
}

assets/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# ASSETS
2+
3+
This directory contains your un-compiled assets such as LESS, SASS, or JavaScript.
4+
5+
More information about the usage of this directory in the documentation:
6+
https://nuxtjs.org/guide/assets#webpacked
7+
8+
**This directory is not required, you can delete it if you don't want to use it.**

0 commit comments

Comments
 (0)