You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -15,7 +15,7 @@ This project is part of the source of [The Apache ECharts Official Website](http
15
15
16
16
## Development
17
17
18
-
### Document content development
18
+
### Document Content Development
19
19
20
20
Do not need other project.
21
21
@@ -28,43 +28,74 @@ It will:
28
28
+ Watch doc site src change and rebuild.
29
29
+ Watch doc markdown change and rebuild.
30
30
31
+
### Local Config
31
32
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`.
33
34
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`
It indicates the range of saturation (color alpha) for nodes in a level.
97
128
{{ else }}
98
129
It indicates the range of saturation (color alpha) for nodes of the series.
99
130
{{ /if }}
100
131
The range of values is 0 ~ 1.
101
132
102
-
//Bad
133
+
Bad:
103
134
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.
104
135
105
136
```
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-`.
+ 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
+
<ExampleBaseOptionname="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:
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
+
106
285
## Format Option Docs
107
286
108
287
Option docs needs to be formatted before commit.
@@ -114,7 +293,7 @@ npm run format
114
293
115
294
Make sure have a double review on the git diff after formatted.
116
295
117
-
## Sync docs between different languages.
296
+
## Sync Docs Between Different Languages
118
297
119
298
After you finished editing doc of one language. You can use following script to sync it to another language.
0 commit comments