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 2020/09/02 15:04:01 UTC
[incubator-echarts-doc] branch next updated: format: parse example
ui control tag as blocks.
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-echarts-doc.git
The following commit(s) were added to refs/heads/next by this push:
new 23b6cb1 format: parse example ui control tag as blocks.
23b6cb1 is described below
commit 23b6cb1791f72c0cfd75ba23b7a64d688a822a85
Author: pissang <bm...@gmail.com>
AuthorDate: Wed Sep 2 23:03:02 2020 +0800
format: parse example ui control tag as blocks.
---
editor/common/blockHelper.js | 17 +++++++--
editor/common/parseBlocks.js | 84 +++++++++++++++++++----------------------
en/option/partial/area-style.md | 2 +-
en/option/partial/line-style.md | 2 +-
en/option/partial/mark-area.md | 4 +-
en/option/partial/mark-line.md | 4 +-
en/option/series/funnel.md | 4 +-
tool/patchLanguage.js | 5 ++-
zh/option/component/title.md | 1 -
zh/option/component/toolbox.md | 1 -
zh/option/partial/area-style.md | 2 +-
zh/option/partial/line-style.md | 2 +-
zh/option/partial/mark-area.md | 4 +-
zh/option/partial/mark-line.md | 4 +-
zh/option/series/gauge.md | 2 -
zh/option/series/pie.md | 1 +
zh/option/series/tree.md | 1 -
17 files changed, 68 insertions(+), 72 deletions(-)
diff --git a/editor/common/blockHelper.js b/editor/common/blockHelper.js
index 1547941..2793941 100644
--- a/editor/common/blockHelper.js
+++ b/editor/common/blockHelper.js
@@ -152,7 +152,7 @@ module.exports.updateBlocksLevels = function (blocks, targetsMap) {
if (targetObj.topLevel === 0) {
// Target has no header if topLevel is 0.
// Assume it's only description
- // Indent by default.
+ // Indent== by default.
block.level = currentLevel + 1;
}
else if (!targetObj.topLevelHasPrefix || (prefixVal && prefixVal.match(/#+/))) {
@@ -183,6 +183,7 @@ module.exports.updateBlocksKeys = function (blocks) {
const keyMap = {};
const contentKeyCountMap = {};
+ const uiControlKeyCountMap = {};
for (const block of blocks) {
let baseKey = '';
@@ -222,6 +223,13 @@ module.exports.updateBlocksKeys = function (blocks) {
baseKey = `${baseKey}:${block.expr}`
}
break;
+ case 'exampleuicontrol':
+ baseKey = `uicontrol:${scopeKey}`;
+ uiControlKeyCountMap[baseKey] = uiControlKeyCountMap[baseKey] || 0;
+ if (uiControlKeyCountMap[baseKey]) {
+ baseKey += '-' + uiControlKeyCountMap[baseKey];
+ }
+ uiControlKeyCountMap[baseKey]++;
}
let keyNoDuplicate = baseKey;
while (keyMap[keyNoDuplicate]) {
@@ -312,6 +320,9 @@ module.exports.blockCompositors = {
},
endfor(block) {
return module.exports.etplCommandCompositors.endfor();
+ },
+ uicontrol(block) {
+ return block.html;
}
};
@@ -324,8 +335,8 @@ module.exports.compositeBlocks = function (blocks) {
if (str && !block.inline) {
let prefix = '\n\n';
// A bit format here. No extra newline between if/for block.
- if ((prevBlock && (prevBlock.type === 'if' || prevBlock.type === 'elif' || prevBlock.type == 'else' || prevBlock.type === 'for'))
- || block.type === 'endif' || block.type === 'endfor') {
+ if ((prevBlock && (prevBlock.type === 'if' || prevBlock.type === 'elif' || prevBlock.type === 'else' || prevBlock.type === 'for')) ||
+ block.type === 'endif' || block.type === 'endfor') {
prefix = '\n';
}
blockStr = prefix + blockStr;
diff --git a/editor/common/parseBlocks.js b/editor/common/parseBlocks.js
index 0f0bf95..488224a 100644
--- a/editor/common/parseBlocks.js
+++ b/editor/common/parseBlocks.js
@@ -23,18 +23,10 @@ function hasNewlineBefore(value) {
return startSpaces && startSpaces[0].indexOf('\n') >= 0;
}
-function parseMarkDown(mdStr, isInline) {
- const headers = [];
+function parseMarkDown(mdStr, parseExampleUI) {
const blocks = [];
- mdStr.replace(
- new RegExp('(?:^|\n) *(#{1,' + MAX_DEPTH + '}) *([^#][^\n]+)', 'g'),
- function (header, headerPrefix, text) {
- headers.push({
- text: text,
- level: headerPrefix.length
- });
- }
- );
+
+ const EXAMPLE_CONTROL_REGEX = /<ExampleUIControl.* \/>/;
function removeNewline(mdStr) {
// Keep leading and trailing space and remove newline. Newline will be added when compositing.
@@ -47,42 +39,44 @@ function parseMarkDown(mdStr, isInline) {
});
}
- if (headers.length) {
- mdStr.split(new RegExp('(?:^|\n) *(?:#{1,' + MAX_DEPTH + '}) *(?:[^#][^\n]+)', 'g'))
- .forEach((section, idx) => {
- if (idx > 0) {
- const headerText = headers[idx - 1].text.trim();
- const headerLevel = headers[idx - 1].level;
-
- const {propertyName, propertyDefault, propertyType, prefixCode} = parseHeader(headerText);
-
+ mdStr.split(new RegExp('(?:^|\n) *((?:#{1,' + MAX_DEPTH + '}) *(?:[^#][^\n]+)|<ExampleUIControl.* \/>)'))
+ .forEach((section, idx) => {
+ const headerParts = new RegExp('(?:^|\n) *(#{1,' + MAX_DEPTH + '}) *([^#][^\n]+)', 'g').exec(section);
+ if (headerParts) {
+ const headerText = headerParts[2];
+ const headerLevel = headerParts[1].length;
+
+ const {propertyName, propertyDefault, propertyType, prefixCode} = parseHeader(headerText);
+
+ blocks.push({
+ type: 'header',
+ level: headerLevel,
+ value: headerText,
+ propertyName,
+ propertyDefault,
+ propertyType,
+ prefixCode,
+ inline: false
+ });
+ }
+ else {
+ const controlParts = /<ExampleUIControl.* \/>/.exec(section);
+ if (controlParts) {
blocks.push({
- type: 'header',
- level: headerLevel,
- value: headerText,
- propertyName,
- propertyDefault,
- propertyType,
- prefixCode,
- inline: false
+ type: 'uicontrol',
+ html: section
});
}
- const text = removeNewline(section);
- text && blocks.push({
- type: 'content',
- value: text,
- inline: false
- });
- });
- }
- else {
- const text = removeNewline(mdStr);
- text && blocks.push({
- type: 'content',
- value: text,
- inline: !hasNewlineBefore(mdStr)
+ else {
+ const text = removeNewline(section);
+ text && blocks.push({
+ type: 'content',
+ value: text,
+ inline: !hasNewlineBefore(section)
+ });
+ }
+ }
});
- }
return blocks;
}
@@ -119,7 +113,7 @@ function compositeIfCommand(command) {
if (isIf) {
texts.push(etplCommandCompositors.endif());
}
- return texts('');
+ return texts.join('');
}
function compositeForCommand(command) {
@@ -174,7 +168,7 @@ function parseSingleFileBlocks(fileName, root, detailed, blocksStore) {
function closeTextBlock() {
if (textBlockText) {
- const mdBlocks = parseMarkDown(textBlockText);
+ const mdBlocks = parseMarkDown(textBlockText, detailed);
for (let i = 0; i < mdBlocks.length; i++) {
outBlocks.push(mdBlocks[i]);
}
diff --git a/en/option/partial/area-style.md b/en/option/partial/area-style.md
index f37f737..03e317e 100644
--- a/en/option/partial/area-style.md
+++ b/en/option/partial/area-style.md
@@ -1,7 +1,7 @@
{{ target: partial-area-style }}
-#${prefix} color(Color) ={{ if: !${useColorPalatte} }} ${defaultColor|default('"#000"')} {{ else }}'adaptive'{{ /if }}
+#${prefix} color(Color) = {{ if: !${useColorPalatte} }} ${defaultColor|default('"#000"')} {{ else }}'adaptive'{{ /if }}
Fill color. {{ if: ${useColorPalatte} }} Color is taken from [option.color Palette](~color) by default. {{ /if }}
diff --git a/en/option/partial/line-style.md b/en/option/partial/line-style.md
index 8d3fb7f..9465f9b 100644
--- a/en/option/partial/line-style.md
+++ b/en/option/partial/line-style.md
@@ -1,7 +1,7 @@
{{ target: partial-line-style }}
-#${prefix} color(Color) ={{ if: !${useColorPalatte} }} ${defaultColor|default('"#000"')} {{ else }}'self-adaptive'{{ /if }}
+#${prefix} color(Color) = {{ if: !${useColorPalatte} }} ${defaultColor|default('"#000"')} {{ else }}'self-adaptive'{{ /if }}
${name}Line color. {{ if: ${useColorPalatte} }} Color is taken from [option.color Palette](~color) by default. {{ /if }}
diff --git a/en/option/partial/mark-area.md b/en/option/partial/mark-area.md
index 0cb0bef..94e58ed 100644
--- a/en/option/partial/mark-area.md
+++ b/en/option/partial/mark-area.md
@@ -97,9 +97,7 @@ data: [
coord: ['max', 'max']
}
],
-{{ /if }}
-
-[
+{{ /if }}[
{
name: 'Mark area in two screen points',
x: 100,
diff --git a/en/option/partial/mark-line.md b/en/option/partial/mark-line.md
index b7f31f8..46ccb4d 100644
--- a/en/option/partial/mark-line.md
+++ b/en/option/partial/mark-line.md
@@ -111,9 +111,7 @@ data: [
}, {
type: 'max'
}],
-{{ /if }}
-
-[
+{{ /if }}[
{
name: 'Mark line between two points',
x: 100,
diff --git a/en/option/series/funnel.md b/en/option/series/funnel.md
index 790e768..64fd0b8 100644
--- a/en/option/series/funnel.md
+++ b/en/option/series/funnel.md
@@ -38,8 +38,8 @@ It can be absolute pixel and also the percentage of [layout width](~series-funne
## orient(string) = 'vertical'
-<ExampleUIControlEnum options="vertical,horizontal" />
-
+<ExampleUIControlEnum options="vertical,horizontal" />
+
Orient of funnel,Can be `'vertical'` or `'horizontal'`.
## sort(string|Function) = 'descending'
diff --git a/tool/patchLanguage.js b/tool/patchLanguage.js
index 23341ea..01988ee 100644
--- a/tool/patchLanguage.js
+++ b/tool/patchLanguage.js
@@ -83,7 +83,10 @@ function applyTargetsPatch(fromJson, toJson) {
const blocksByLang = {};
for (let lang of [fromLang, toLang]) {
- const json = await parseBlocks(path.resolve(__dirname, `../${lang}/option`));
+ const json = await parseBlocks(
+ path.resolve(__dirname, `../${lang}/option`),
+ true
+ );
blocksByLang[lang] = json;
}
diff --git a/zh/option/component/title.md b/zh/option/component/title.md
index b250761..dffeef3 100644
--- a/zh/option/component/title.md
+++ b/zh/option/component/title.md
@@ -127,7 +127,6 @@ const option = {
<ExampleUIControlNumber min="0" default="10" step="1" />
-
主副标题之间的间距。
{{ use: partial-rect-layout(
diff --git a/zh/option/component/toolbox.md b/zh/option/component/toolbox.md
index 68cb7db..93b2261 100644
--- a/zh/option/component/toolbox.md
+++ b/zh/option/component/toolbox.md
@@ -46,7 +46,6 @@ ${name} icon 样式设置。由于 icon 的文本信息只在 icon hover 时候
<ExampleUIControlVector min="0" dims="LT,RT,RB,LB" />
-
文本区域圆角大小。
###${prefix} textPadding(number)
diff --git a/zh/option/partial/area-style.md b/zh/option/partial/area-style.md
index f7823a7..51056e9 100644
--- a/zh/option/partial/area-style.md
+++ b/zh/option/partial/area-style.md
@@ -1,7 +1,7 @@
{{ target: partial-area-style }}
-#${prefix} color(Color) ={{ if: !${useColorPalatte} }} ${defaultColor|default('"#000"')} {{ else }}'自适应'{{ /if }}
+#${prefix} color(Color) = {{ if: !${useColorPalatte} }} ${defaultColor|default('"#000"')} {{ else }}'自适应'{{ /if }}
<ExampleUIControlColor />
diff --git a/zh/option/partial/line-style.md b/zh/option/partial/line-style.md
index 17cad67..340b26d 100644
--- a/zh/option/partial/line-style.md
+++ b/zh/option/partial/line-style.md
@@ -1,7 +1,7 @@
{{ target: partial-line-style }}
-#${prefix} color(Color) ={{ if: !${useColorPalatte} }} ${defaultColor|default('"#000"')} {{ else }}'自适应'{{ /if }}
+#${prefix} color(Color) = {{ if: !${useColorPalatte} }} ${defaultColor|default('"#000"')} {{ else }}'自适应'{{ /if }}
<ExampleUIControlColor />
diff --git a/zh/option/partial/mark-area.md b/zh/option/partial/mark-area.md
index 11c797b..3f7ddd0 100644
--- a/zh/option/partial/mark-area.md
+++ b/zh/option/partial/mark-area.md
@@ -99,9 +99,7 @@ data: [
coord: ['max', 'max']
}
],
-{{ /if }}
-
-[
+{{ /if }}[
{
name: '两个屏幕坐标之间的标域',
x: 100,
diff --git a/zh/option/partial/mark-line.md b/zh/option/partial/mark-line.md
index 5e52b94..e71c337 100644
--- a/zh/option/partial/mark-line.md
+++ b/zh/option/partial/mark-line.md
@@ -114,9 +114,7 @@ data: [
}, {
type: 'max'
}],
-{{ /if }}
-
-[
+{{ /if }}[
{
name: '两个屏幕坐标之间的标线',
x: 100,
diff --git a/zh/option/series/gauge.md b/zh/option/series/gauge.md
index d7ea552..d977278 100644
--- a/zh/option/series/gauge.md
+++ b/zh/option/series/gauge.md
@@ -45,7 +45,6 @@ const option = {
<ExampleUIControlAngle min="-360" max="360" default="225" step="1" />
-
仪表盘起始角度。[圆心](~series-gauge.center) 正右手侧为`0`度,正上方为`90`度,正左手侧为`180`度。
## endAngle(number) = -45
@@ -275,7 +274,6 @@ formatter: function (value) {
<ExampleUIControlPercentVector default="0,-40%" dims="x,y" />
-
相对于仪表盘中心的偏移位置,数组第一项是水平方向的偏移,第二项是垂直方向的偏移。可以是绝对的数值,也可以是相对于仪表盘半径的百分比。
{{ use: partial-text-style(
diff --git a/zh/option/series/pie.md b/zh/option/series/pie.md
index 2b50863..2847a69 100644
--- a/zh/option/series/pie.md
+++ b/zh/option/series/pie.md
@@ -432,6 +432,7 @@ const option = {
#${prefix} length2(number)
<ExampleUIControlNumber default="15" min="0" step="1" />
+
视觉引导项第二段的长度。
{{ /if }}
diff --git a/zh/option/series/tree.md b/zh/option/series/tree.md
index df90536..da23fe5 100644
--- a/zh/option/series/tree.md
+++ b/zh/option/series/tree.md
@@ -97,7 +97,6 @@ const option = {
<ExampleUIControlEnum options="LR,RL,TB,BT" default="LR" />
-
树图中 `正交布局` 的方向,也就是说只有在 `layout = 'orthogonal'` 的时候,该配置项才生效。对应有 `水平` 方向的 `从左到右`,`从右到左`;以及垂直方向的 `从上到下`,`从下到上`。取值分别为 `'LR'` , `'RL'`, `'TB'`, `'BT'`。**注意**,之前的配置项值 `'horizontal'` 等同于 `'LR'`, `'vertical'` 等同于 `'TB'`。
{{ use: partial-symbol(
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org