Skip to content

Commit 9c2ad34

Browse files
authored
Merge pull request #461 from apache/dev
chore: merge dev to master
2 parents a331ab0 + e33c51f commit 9c2ad34

107 files changed

Lines changed: 8434 additions & 12949 deletions

Some content is hidden

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

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ slides/webgl
178178
/public/css
179179
/public/zh/documents
180180
/public/en/documents
181+
/public/zh/coding-standard-content.html
182+
/public/en/coding-standard-content.html
181183
/public/*.html
182184

183185

@@ -188,4 +190,6 @@ slides/webgl
188190
/tool/blocks-zh.json
189191

190192
/zh-src
191-
/en-src
193+
/en-src
194+
195+
/config/env.*-local.js

README.md

Lines changed: 198 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This project is part of the source of [The Apache ECharts Official Website](http
1515

1616
## Development
1717

18-
### Document content development
18+
### Document Content Development
1919

2020
Do not need other project.
2121

@@ -28,43 +28,74 @@ It will:
2828
+ Watch doc site src change and rebuild.
2929
+ Watch doc markdown change and rebuild.
3030

31+
### Local Config
3132

32-
## Tips about writing doc
33+
To customize the links of `echarts-examples` and other configurations, you can create a local config file `echarts-doc/config/env.dev-local.js`, which is not tracked by git, and its top-level properties will be used to override the corresponding properties of `echarts-doc/config/env.dev.js` when `npm run dev`.
3334

34-
#### Global variables can be used in doc:
35+
For example, create a `echarts-doc/config/env.dev-local.js`:
36+
```js
37+
module.exports = {
38+
// These props will override the same props in `echarts-doc/config/env.dev-local.js`
39+
galleryViewPath: 'http://127.0.0.1:3002/en/view.html?local=1&c=',
40+
galleryEditorPath: 'http://127.0.0.1:3002/en/editor.html?local=1&c=',
41+
EMBEDDED_ECHARTS_SCRIPT_URL: 'http://localhost:8001/echarts/echarts/dist/echarts.js',
42+
};
43+
```
44+
45+
46+
## Tips About Writing Doc
47+
48+
### "Since Version"
49+
"Since Version" is necessary in doc.
50+
Marking "since version" indicates when a new feature was introduced.
51+
For example,
52+
```
53+
{{ use: partial-version(version = "6.0.0") }}
54+
```
55+
56+
### Global Variables
57+
58+
These global variables can be used in doc:
59+
+ `${galleryViewPath}`
60+
+ `${galleryEditorPath}`
61+
+ `${websitePath}`
3562

36-
+ galleryViewPath
37-
+ galleryEditorPath
38-
+ websitePath
63+
See samples in "Reference of echarts-examples or other links"
3964

40-
For example:
41-
Embed a example in doc:
65+
### Reference of echarts-examples or Other Links
66+
67+
Embed an example in doc:
4268
```md
69+
~[700X300](${galleryEditorPath}pie-legend&edit=1&reset=1)
4370
~[700x300](${galleryViewPath}doc-example/aria-pie&edit=1&reset=1)
4471
```
45-
Provide a example link in doc:
72+
73+
Provide an example link in doc:
4674
```md
4775
[vertically scrollable legend](${galleryEditorPath}pie-legend&edit=1&reset=1)
76+
[aria pie](${galleryViewPath}doc-example/aria-pie&edit=1&reset=1)
4877
```
78+
4979
Provide a website link in doc:
5080
```md
5181
[Apache ECharts website](${websitePath}/en/download.html)
5282
```
5383

54-
#### Reference of option
84+
### Reference of Other ECharts Option
5585

5686
A `~` can be used to refer to a option item in the same doc. For example:
57-
5887
```md
5988
[xAxis.name](~xAxis.name)
6089
```
6190

6291
If intending to reference an anchor in different doc, it can be:
6392
```md
93+
In api.html, reference
6494
[itemStyle](option.html#series.itemStyle)
6595
```
6696

67-
#### Notes:
97+
98+
### Notice
6899

69100
1. Formatter will treat {{use}} as a block. So don't use it **inline**.
70101

@@ -77,32 +108,180 @@ Some other description
77108
Some description about {{ use: partial-inline-xxx }}
78109
```
79110

80-
2. Don't use to complex **inline** {{if}} {{else}} structure. It will make reading and patching between different languages harder.
111+
2. Don't use complex **inline** {{if}} {{else}} structure. It will make reading and patching between different languages harder.
81112

82-
```js
83-
// Good
113+
```template
114+
Good:
84115
{{ if: ${prefix} !== '#' }}
85116
表示同一层级的节点的颜色饱和度 选取范围。
86117
{{ else }}
87118
本系列默认的节点的颜色饱和度 选取范围。
88119
{{ /if }}
89120
数值范围 0 ~ 1。
90121
91-
// Bad
122+
Bad:
92123
{{ if: ${prefix} !== '#' }}表示同一层级的节点的{{ else }}本系列默认的{{ /if }} 颜色饱和度 选取范围。数值范围 0 ~ 1。
93124
94-
// Good
125+
Good:
95126
{{ if: ${prefix} !== '#' }}
96127
It indicates the range of saturation (color alpha) for nodes in a level.
97128
{{ else }}
98129
It indicates the range of saturation (color alpha) for nodes of the series.
99130
{{ /if }}
100131
The range of values is 0 ~ 1.
101132
102-
// Bad
133+
Bad:
103134
It indicates the range of saturation (color alpha) {{ if: ${prefix} !== '#' }}for nodes in a level {{ else }} of the series{{ /if }}. The range of values is 0 ~ 1.
104135
105136
```
137+
138+
### Doc Structure
139+
140+
+ Entries:
141+
+ the entry in source code is like `en/api/api.md`, `en/api/option.md`, they will be compiled to webpage like `api.html`, `option.html`
142+
143+
+ Shared targets (text blocks):
144+
+ All of the shared targets should be put into the `partial` folder, such as, `en/api/partial/xxx`, `en/optino/partial/xxx`, and named with a prefix `partial-`.
145+
146+
+ Subtitles:
147+
+ The doc is structured by subtitles.
148+
+ For example:
149+
```
150+
# series.bar(Object)
151+
## propA(number|string) = null
152+
some desc xxx
153+
## propB(number|string) = null
154+
some desc yyy
155+
## propC(string) = ${defaultPropC|default("'auto'")}
156+
157+
#${prefix} someOtherProp(Object)
158+
some desc zzz
159+
```
160+
+ `(xxx|yyy)` is the data type in that subtitle:
161+
+ Can only be `number`, `string`, `boolean`, `Object`, `Array`, `Function`
162+
+ Can be an union, such as `number|string`.
163+
+ `= xxx` is the default value in that subtitle:
164+
+ Can be omitted.
165+
+ Typically be `null`, `undefined`, `true`, `false`, `90` (a literal number), `some literal string`, `[0, 90]` (an literal array).
166+
+ The default value can be specified by a template variable, such as, `= ${someVar}`, `= ${someVar|default(123)}`, `= ${someVar|default("'auto'")}`.
167+
+ The top level subtitles:
168+
+ For example, `# series.bar(Object)`, the dot symbol represents a special meaning: the component main type is `'series'` and the component sub-type is `'bar'`.
169+
+ The variable `${prefix}`
170+
+ It is commonly used in "target: partial-xxx", which serves different subtitle levels. The value of `${prefix}` is like `'#'`, `'##'`, `'###'`, ...
171+
+ Typical usage:
172+
```tpl
173+
When we define a "target"
174+
{{ target: partial-abc-1 }}
175+
#${prefix} propLayout(Object)
176+
All of the subtitles should uses that prefix variable.
177+
##${prefix} x(number)
178+
some desc
179+
##${prefix} y(number)
180+
some desc
181+
{{ /target }}
182+
{{ target: partial-target-2 }}
183+
```
184+
```tpl
185+
When we use that "partial-abc-1"
186+
{{ target: partial-def-2 }}
187+
#${prefix|default('#')} somePropA(Object)
188+
{{ use: partial-abc-1(
189+
prefix: ${prefix} + '#'
190+
) }}
191+
```
192+
193+
### Template Syntax
194+
195+
The template syntax follows [etpl](https://github.com/ecomfe/etpl/blob/master/doc/syntax.md) (but use `{{ }}` rather than `<!-- -->` as the interpolate tags).
196+
> A syntax highlight tool: [etpl-vscode](https://marketplace.visualstudio.com/items?itemName=yibuyisheng.etpl-vscode)
197+
198+
Summary of the commonly used syntax:
199+
```template
200+
--- TEMPLATE VARIABLE ---
201+
Use a variable:
202+
some text ${someVariable} some text
203+
Variable scope:
204+
The scope of any variable is "target" (see below).
205+
Variable filter:
206+
Some predefined filters can be used in the template variable, e.g.,
207+
${someVariable|default("'auto'")} means using the string "'auto'"
208+
as the default if ${someVariable} is '' or null or undefined.
209+
Declaration or assignment of a target-local variable:
210+
{{ var: myVar = 'some' }}
211+
{{ var: myVar = 123 }}
212+
{{ var: myVar = ${someOtherStr} + 'some_str' }}
213+
214+
215+
--- IF ELSE ---
216+
{{ if: ${number1} > 0 }}
217+
some text xxx
218+
{{ elif: ${string1} === 'abc' }}
219+
some text yyy
220+
{{ else }}
221+
some text zzz
222+
{{ /if }}
223+
224+
225+
--- FOR LOOP ---
226+
{{ for: ${persons} as ${person}, ${index} }}
227+
some text ${index}: ${person.name}
228+
{{ /for }}
229+
230+
231+
--- TARGET (DEFINE A TEXT BLOCK) ---
232+
{{ target: a_predefined_block_name_1 }}
233+
The input varA is ${varA}
234+
The input varB is ${varB}
235+
The input varC is ${varC}
236+
Notice:
237+
- The scope of the "target name" is the entire webpage (such as, `option.html`, `api.html`), so name conflicts should be avoided.
238+
- "target" is not shared across webpage (such as, `option.html`, `api.html`).
239+
- The close tag of "target" can be omitted, but not recommended.
240+
{{ /target }}
241+
242+
243+
--- USE (USE A PREDEFINED TEXT BLOCK) ---
244+
{{ use: a_predefined_block_name_1 }}
245+
{{ use: a_predefined_block_name_2(
246+
varA = ${myVarX},
247+
varB = 123,
248+
varC = 'some string',
249+
prefix: ${prefix} + '##'
250+
) }}
251+
Concatenation operator `+` can be used in that string.
252+
```
253+
254+
255+
### Document Embedded Examples
256+
257+
This is the embedded example that can be opened by clicking "try it" and then appears on the right side of the doc page.
258+
259+
Declare the base echarts options (`ExampleBaseOption`), whose scope is each echarts component or series. A `ExampleBaseOption` can be shared by multiple options. e.g.,
260+
```md
261+
<ExampleBaseOption name="cartesian-bar" title="直角坐标系上的柱状图" title-en="Bar on Cartesian">
262+
const option = {
263+
...
264+
}
265+
</ExampleBaseOption>
266+
```
267+
268+
Declare example UI control in each option, who uses the currently opened example. Supported UI controls:
269+
+ `<ExampleUIControlBoolean default="true" />`
270+
+ `<ExampleUIControlNumber default="8" step="0.5" />`
271+
+ `<ExampleUIControlColor default="#d2dbee" />`
272+
+ `<ExampleUIControlEnum options="horizontal,vertical" default="horizontal" />`
273+
+ `<ExampleUIControlIcon default="none" />`
274+
+ `<ExampleUIControlVector default="0,0" />`
275+
+ `<ExampleUIControlAngle min="-90" max="90" step="1" />`
276+
+ `<ExampleUIControlPercent default="0" />`
277+
+ `<ExampleUIControlPercentVector min="0" dims="InnerStart,InnerEnd,OuterStart,OuterEnd" default="0,0,0,0" />`
278+
+ `<ExampleUIControlText />`
279+
280+
The detailed API and implementation of the UI controls can be checked in `echarts-doc/src/controls/*.vue` and `echarts-doc/src/components/OptionControl.vue`.
281+
282+
Note: currently `ExampleBaseOption` and `ExampleUIControlXxx` will be copied (by `echarts-doc/build.js`) from `echarts-doc/zh/**/*.md` to `echarts-doc/en/**/*.md` if they are not declared in `echarts-doc/en/**/*.md`.
283+
284+
106285
## Format Option Docs
107286

108287
Option docs needs to be formatted before commit.
@@ -114,7 +293,7 @@ npm run format
114293

115294
Make sure have a double review on the git diff after formatted.
116295

117-
## Sync docs between different languages.
296+
## Sync Docs Between Different Languages
118297

119298
After you finished editing doc of one language. You can use following script to sync it to another language.
120299

0 commit comments

Comments
 (0)