You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/04/15 10:52:39 UTC
[echarts-doc] branch master updated: add script to extract option
keys. fix some default value issue
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/echarts-doc.git
The following commit(s) were added to refs/heads/master by this push:
new a4e7828 add script to extract option keys. fix some default value issue
a4e7828 is described below
commit a4e78283fe2936fcd7bd2fe4713c31e9ffd110fd
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Apr 15 18:51:57 2021 +0800
add script to extract option keys. fix some default value issue
---
build.js | 2 +-
en/option/component/data-zoom-slider.md | 3 +--
en/option/component/visual-map.md | 10 ----------
en/option/partial/decal.md | 6 +++---
en/option/partial/item-style.md | 2 +-
en/option/partial/line-border-style.md | 31 ++++++++++++++-----------------
en/option/partial/zr-graphic.md | 2 +-
en/option/series/bar.md | 2 +-
en/option/series/treemap.md | 2 +-
tool/extractOptionKeys.js | 7 +++++++
tool/{extractDesc.js => schemaHelper.js} | 28 ++++++++++++++++++++++++++--
zh/option/partial/decal.md | 6 +++---
zh/option/partial/item-style.md | 2 +-
zh/option/partial/zr-graphic.md | 2 +-
zh/option/series/bar.md | 2 +-
zh/option/series/treemap.md | 2 +-
16 files changed, 63 insertions(+), 46 deletions(-)
diff --git a/build.js b/build.js
index 6915602..9722ff4 100644
--- a/build.js
+++ b/build.js
@@ -13,7 +13,7 @@
*/
const md2json = require('./tool/md2json');
-const extractDesc = require('./tool/extractDesc');
+const {extractDesc, extractOptionKeys} = require('./tool/schemaHelper');
const fs = require('fs');
const fse = require('fs-extra');
const marked = require('marked');
diff --git a/en/option/component/data-zoom-slider.md b/en/option/component/data-zoom-slider.md
index e43fa4f..a8b952e 100644
--- a/en/option/component/data-zoom-slider.md
+++ b/en/option/component/data-zoom-slider.md
@@ -3,7 +3,6 @@
# dataZoom.slider(Object)
-
Slider type dataZoom component provides functions like data thumbnail, zoom, brush to select, drag to move, click to locate.
The followling picture shows areas to interact.
@@ -151,7 +150,7 @@ Size of move handle.
version = "5.0.0"
) }}
-
+Style of move handle.
{{ use: partial-item-style(
prefix = "##",
diff --git a/en/option/component/visual-map.md b/en/option/component/visual-map.md
index 47e0cba..468d5fd 100644
--- a/en/option/component/visual-map.md
+++ b/en/option/component/visual-map.md
@@ -341,11 +341,6 @@ Define visual channels that will mapped from dataValues that are **out of select
See available configurations in [${visualMapName}.inRange](~${visualMapName}.inRange)
-{{ use: partial-visual-map-inRange-outOfRange(
- prefix = "",
- visualMapName = ${visualMapName}
-) }}
-
## controller(Object)
Property `inRange` and `outOfRange` can be set within property `controller`, which means those `inRange` and `outOfRange` are only used on the controller (`visualMap` component itself), but are not used on chart (series). This property is useful in some scenarios when the view of controller needs to be customized in detail.
@@ -362,11 +357,6 @@ Define visual channels that will mapped from dataValues that are **out of select
See available configurations in [${visualMapName}.inRange](~${visualMapName}.inRange)
-{{ use: partial-visual-map-inRange-outOfRange(
- prefix = "",
- visualMapName = ${visualMapName}
-) }}
-
{{ use: partial-rect-layout(
componentName = "visualMap ",
defaultZ = "4",
diff --git a/en/option/partial/decal.md b/en/option/partial/decal.md
index e5514d8..61a7de4 100644
--- a/en/option/partial/decal.md
+++ b/en/option/partial/decal.md
@@ -13,7 +13,7 @@ It works only if `areaStyle` is set.
{{ target: partial-decal }}
-#${prefix|default('#')} symbol(string|string[]) = 'rect'
+#${prefix|default('#')} symbol(string|Array) = 'rect'
The symbol type of the decal. If it is in the type of `string[]`, it means the symbols are used one by one.
@@ -35,7 +35,7 @@ For the color of the decal pattern, it is recommended to use a translucent color
The background color of the decal will be over the color of the series itself, under the decal pattern.
-#${prefix|default('#')} dashArrayX(number | number[] | (number | number[])[]) = 5
+#${prefix|default('#')} dashArrayX(number|Array) = 5
The basic pattern of the decal pattern is an infinite loop in the form of `Pattern - Blank - Pattern - Blank - Pattern - Blank` both horizontally and vertically, respectively. By setting the length of each pattern and blank, complex pattern effects can be achieved.
@@ -51,7 +51,7 @@ This interface can be better understood with the following examples.
~[700x300](${galleryViewPath}doc-example/aria-decal&edit=1&reset=1)
-#${prefix|default('#')} dashArrayY(number | number[]) = 5
+#${prefix|default('#')} dashArrayY(number|Array) = 5
The basic pattern of the decal pattern is an infinite loop in the form of `Pattern - Blank - Pattern - Blank - Pattern - Blank` both horizontally and vertically, respectively. By setting the length of each pattern and blank, complex pattern effects can be achieved.
diff --git a/en/option/partial/item-style.md b/en/option/partial/item-style.md
index d2cb08f..bfaed34 100644
--- a/en/option/partial/item-style.md
+++ b/en/option/partial/item-style.md
@@ -52,7 +52,7 @@ ${name} border width. No border when it is set to be 0.
) }}
{{ if: ${useDecal} }}
-#${prefix} decal(Object | 'none')
+#${prefix} decal(Object)
{{ use: partial-decal-desc(
onlyWithAreaStyle = ${decalOnlyWithAreaStyle}
diff --git a/en/option/partial/line-border-style.md b/en/option/partial/line-border-style.md
index 7a7aa23..7d9c317 100644
--- a/en/option/partial/line-border-style.md
+++ b/en/option/partial/line-border-style.md
@@ -1,8 +1,10 @@
+
{{ target: partial-line-border-style }}
{{ if: ${type} === 'border' }}
#${prefix} borderType(string|number|Array) = ${defaultType|default("'solid'")}
-{{ elif: ${type} === 'text' }}
+
+{{ elif: ${type} === 'text' }}
#${prefix} textBorderType(string|number|Array) = ${defaultType|default("'solid'")}
{{ else }}
#${prefix} type(string|number|Array) = ${defaultType|default("'solid'")}
@@ -12,7 +14,8 @@
{{ if: ${type} === 'border' }}
${name} border type.
-{{ elif: ${type} === 'text' }}
+
+{{ elif: ${type} === 'text' }}
Stroke line type of the text.
{{ else }}
line type.
@@ -25,7 +28,7 @@ Possible values are:
Since `v5.0.0`, it can also be a number or a number array to specify the [dash array](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray) of the line. With {{ if: ${type} === 'border' }}
`borderDashOffset`
-{{ elif: ${type} === 'text' }}
+{{ elif: ${type} === 'text' }}
`textBorderDashOffset`
{{ else }}
`dashOffset`
@@ -34,15 +37,17 @@ Since `v5.0.0`, it can also be a number or a number array to specify the [dash a
For example:
```js
{
- {{ if: ${type} === 'border' }}borderType{{ elif: ${type} === 'text' }}textBorderType{{ else }}type{{ /if }}: [5, 10],
- {{ if: ${type} === 'border' }}borderDashOffset{{ elif: ${type} === 'text' }}textBorderDashOffset{{ else }}dashOffset{{ /if }}: 5
+
+{{ if: ${type} === 'border' }}borderType{{ elif: ${type} === 'text' }}textBorderType{{ else }}type{{ /if }}: [5, 10],
+
+{{ if: ${type} === 'border' }}borderDashOffset{{ elif: ${type} === 'text' }}textBorderDashOffset{{ else }}dashOffset{{ /if }}: 5
}
```
-
{{ if: ${type} === 'border' }}
#${prefix} borderDashOffset(number) = 0
-{{ elif: ${type} === 'text' }}
+
+{{ elif: ${type} === 'text' }}
#${prefix} textBorderDashOffset(number) = 0
{{ else }}
#${prefix} dashOffset(number) = 0
@@ -56,7 +61,7 @@ For example:
To set the line dash offset. With {{ if: ${type} === 'border' }}
`borderType`
-{{ elif: ${type} === 'text' }}
+{{ elif: ${type} === 'text' }}
`textBorderType`
{{ else }}
`type`
@@ -64,9 +69,7 @@ To set the line dash offset. With {{ if: ${type} === 'border' }}
Refer to MDN [lineDashOffset](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset) for more details.
-
{{ if: !${noCap} }}
-
{{ if: ${type} === 'border' }}
#${prefix} borderCap(string) = 'butt'
{{ else }}
@@ -86,12 +89,9 @@ Possible values are:
+ `'square'`: The ends of lines are squared off by adding a box with an equal width and half the height of the line's thickness.
Default value is `'butt'`. Refer to MDN [lineCap](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap) for more details.
-
{{ /if }}
-
{{ if: !${noJoin} }}
-
{{ if: ${type} === 'border' }}
#${prefix} borderJoin(string) = 'bevel'
{{ else }}
@@ -116,12 +116,9 @@ Possible values are:
{{ /if }} property.
Default value is `'bevel'`. Refer to MDN [lineJoin](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin) for more details.
-
{{ /if }}
-
{{ if: !${noMiterLimit} }}
-
{{ if: ${type} === 'border' }}
#${prefix} borderMiterLimit(number) = 10
{{ else }}
@@ -143,5 +140,5 @@ To set the miter limit ratio. Only works when {{ if: ${type} === 'border' }}
Default value is `10`. Negative、`0`、`Infinity` and `NaN` values are ignored.
Refer to MDN [miterLimit](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimit) for more details.
+{{ /if }}
-{{ /if }}
\ No newline at end of file
diff --git a/en/option/partial/zr-graphic.md b/en/option/partial/zr-graphic.md
index 1c8da22..14f28b7 100644
--- a/en/option/partial/zr-graphic.md
+++ b/en/option/partial/zr-graphic.md
@@ -1360,7 +1360,7 @@ Default to be the bounding box of host element.
}
```
-###${prefix} offset(number[])
+###${prefix} offset(Array)
Offset of the `textContent`.
diff --git a/en/option/series/bar.md b/en/option/series/bar.md
index c0eead9..8693d68 100644
--- a/en/option/series/bar.md
+++ b/en/option/series/bar.md
@@ -326,7 +326,7 @@ Border type. Can be `'dashed'`, `'dotted'`.
) }}
{{ if: ${useDecal} }}
-#${prefix} decal(Object | 'none')
+#${prefix} decal(Object)
{{ use: partial-decal-desc() }}
diff --git a/en/option/series/treemap.md b/en/option/series/treemap.md
index 78d6ca7..00d7ce2 100644
--- a/en/option/series/treemap.md
+++ b/en/option/series/treemap.md
@@ -723,7 +723,7 @@ In this way, a effect can be implemented: different sections have different hue
prefix = ${prefix}
) }}
-#${prefix} decal(Object | 'none')
+#${prefix} decal(Object)
{{ use: partial-decal-desc() }}
diff --git a/tool/extractOptionKeys.js b/tool/extractOptionKeys.js
new file mode 100644
index 0000000..3be8882
--- /dev/null
+++ b/tool/extractOptionKeys.js
@@ -0,0 +1,7 @@
+const fs = require('fs');
+const { extractOptionKeys } = require('./schemaHelper');
+
+
+
+const schema = JSON.parse(fs.readFileSync(__dirname + '/../public/zh/documents/option.json', 'utf-8'));
+console.log(JSON.stringify(extractOptionKeys(schema)));
\ No newline at end of file
diff --git a/tool/extractDesc.js b/tool/schemaHelper.js
similarity index 89%
rename from tool/extractDesc.js
rename to tool/schemaHelper.js
index e0e489e..5ee6ebc 100644
--- a/tool/extractDesc.js
+++ b/tool/schemaHelper.js
@@ -37,7 +37,9 @@ function traverse(schema, rootName, cb) {
}
innerTraverse(schema.option, rootName, false);
-}
+};
+
+module.exports.traverse = traverse;
function convertToTree(rootSchema, rootNode) {
@@ -139,6 +141,28 @@ function convertToTree(rootSchema, rootNode) {
);
};
+module.exports.extractOptionKeys = function (schema) {
+ const keysRepeatCount = {};
+ const keysList = [];
+ traverse(schema, '', (schemaPath, schemaNode) => {
+ if (!schemaPath) {
+ return;
+ }
+ const leafKey = schemaPath.split(/[\.-]/g).pop();
+ if (keysRepeatCount[leafKey] == null) {
+ keysRepeatCount[leafKey] = 0;
+ keysList.push(leafKey);
+ }
+ keysRepeatCount[leafKey]++;
+ });
+ return keysList.map(key => {
+ return {
+ name: key,
+ count: keysRepeatCount[key]
+ };
+ }).sort((a, b) => b.count - a.count);
+};
+
// Partion the descriptions by the first part of path. For example
// { "title.label", "series-line.data", "series-bar.data" }
// Will be
@@ -147,7 +171,7 @@ function convertToTree(rootSchema, rootNode) {
// "series-line": {"data"},
// "series-bar": {"data"}
// }
-module.exports = function (schema, docName) {
+module.exports.extractDesc = function (schema, docName) {
let descriptionsMap = {};
let propWithUIControlCount = 0;
let propTotalCount = 0;
diff --git a/zh/option/partial/decal.md b/zh/option/partial/decal.md
index 461fd81..746fa02 100644
--- a/zh/option/partial/decal.md
+++ b/zh/option/partial/decal.md
@@ -14,7 +14,7 @@
{{ target: partial-decal }}
-#${prefix|default('#')} symbol(string|string[]) = 'rect'
+#${prefix|default('#')} symbol(string|Array) = 'rect'
贴花的图案,如果是 `string[]` 表示循环使用数组中的图案。
@@ -36,7 +36,7 @@
贴花的背景色,将会覆盖在系列本身颜色之上,贴花图案之下。
-#${prefix|default('#')} dashArrayX(number | number[] | (number | number[])[]) = 5
+#${prefix|default('#')} dashArrayX(number|Array) = 5
贴花图案的基本模式是在横向和纵向上分别以`图案 - 空白 - 图案 - 空白 - 图案 - 空白`的形式无限循环。通过设置每个图案和空白的长度,可以实现复杂的图案效果。
@@ -52,7 +52,7 @@
~[700x300](${galleryViewPath}doc-example/aria-decal&edit=1&reset=1)
-#${prefix|default('#')} dashArrayY(number | number[]) = 5
+#${prefix|default('#')} dashArrayY(number|Array) = 5
贴花图案的基本模式是在横向和纵向上分别以`图案 - 空白 - 图案 - 空白 - 图案 - 空白`的形式无限循环。通过设置每个图案和空白的长度,可以实现复杂的图案效果。
diff --git a/zh/option/partial/item-style.md b/zh/option/partial/item-style.md
index ca08858..d4a1818 100644
--- a/zh/option/partial/item-style.md
+++ b/zh/option/partial/item-style.md
@@ -53,7 +53,7 @@ ${name}描边线宽。为 0 时无描边。
{{ if: ${useDecal} }}
-#${prefix} decal(Object | 'none')
+#${prefix} decal(Object)
{{ use: partial-decal-desc(
onlyWithAreaStyle = ${decalOnlyWithAreaStyle}
diff --git a/zh/option/partial/zr-graphic.md b/zh/option/partial/zr-graphic.md
index 9b871db..2cfbe06 100644
--- a/zh/option/partial/zr-graphic.md
+++ b/zh/option/partial/zr-graphic.md
@@ -1413,7 +1413,7 @@ Position of `textContent`.
}
```
-###${prefix} offset(number[])
+###${prefix} offset(Array)
`textContent` 的偏移。
diff --git a/zh/option/series/bar.md b/zh/option/series/bar.md
index 7ea29e3..20fb04f 100644
--- a/zh/option/series/bar.md
+++ b/zh/option/series/bar.md
@@ -407,7 +407,7 @@ option = {
{{ if: ${useDecal} }}
-#${prefix} decal(Object | 'none')
+#${prefix} decal(Object)
{{ use: partial-decal-desc() }}
diff --git a/zh/option/series/treemap.md b/zh/option/series/treemap.md
index 5975ab9..cdfbf3d 100644
--- a/zh/option/series/treemap.md
+++ b/zh/option/series/treemap.md
@@ -864,7 +864,7 @@ treemap 默认把第一个维度(Array 第一项)映射到『面积』上。
prefix = ${prefix}
) }}
-#${prefix} decal(Object | 'none')
+#${prefix} decal(Object)
{{ use: partial-decal-desc() }}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org