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/01 04:23:57 UTC
[incubator-echarts-doc] 02/02: add doc format script
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
commit c1e19a7553284f548676bf8912d32e79edb0bd0e
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Sep 1 12:23:19 2020 +0800
add doc format script
---
README.md | 9 +++++++++
editor/{server => common}/parseBlocks.js | 2 +-
editor/server/main.js | 3 +--
package.json | 1 +
tool/format.js | 14 ++++++++++++++
5 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 4149a2d..d8304f8 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,15 @@ Provide a website link in doc:
[Apache ECharts (incubating) website](${websitePath}/en/download.html)
```
+#### Format Option Docs
+
+Option docs needs to be formatted before commit.
+
+Run
+```shell
+npm run format
+```
+
#### Reference of option
diff --git a/editor/server/parseBlocks.js b/editor/common/parseBlocks.js
similarity index 99%
rename from editor/server/parseBlocks.js
rename to editor/common/parseBlocks.js
index f772cf9..a013aa7 100644
--- a/editor/server/parseBlocks.js
+++ b/editor/common/parseBlocks.js
@@ -2,7 +2,7 @@ const etpl = require('../../dep/etpl');
const fs = require('fs');
const globby = require('globby');
const path = require('path');
-const {updateBlocksLevels, parseHeader, parseArgs, updateBlocksKeys} = require('../common/blockHelper');
+const {updateBlocksLevels, parseHeader, parseArgs, updateBlocksKeys} = require('./blockHelper');
const IfCommand = etpl.commandTypes.if;
const UseCommand = etpl.commandTypes.use;
diff --git a/editor/server/main.js b/editor/server/main.js
index cbc6a62..d80910b 100644
--- a/editor/server/main.js
+++ b/editor/server/main.js
@@ -1,9 +1,8 @@
-const { parseBlocks } = require('./parseBlocks');
+const { parseBlocks } = require('../common/parseBlocks');
const {compositeTargets} = require('../common/blockHelper');
const config = require('../common/config');
const path = require('path');
const fs = require('fs');
-const { fail } = require('assert');
const io = require('socket.io').listen(config.SOCKET_PORT);
diff --git a/package.json b/package.json
index 843383c..0d500ff 100644
--- a/package.json
+++ b/package.json
@@ -13,6 +13,7 @@
"build:site": "npx webpack --config build/webpack.config.js --mode production",
"watch:site": "npx webpack --config build/webpack.config.js --mode development --devtool sourcemap --watch",
"server": "node server.js",
+ "format": "node tool/format.js",
"dev": "npx concurrently --kill-others \"npm run watch\" \"npm run watch:site\" \"npm run server\""
},
"author": "shenyi",
diff --git a/tool/format.js b/tool/format.js
new file mode 100644
index 0000000..e9a7325
--- /dev/null
+++ b/tool/format.js
@@ -0,0 +1,14 @@
+const fs = require('fs');
+const path = require('path');
+const {compositeTargets} = require('../editor/common/blockHelper');
+const {parseBlocks} = require('../editor/common/parseBlocks');
+
+for (let lang of ['zh', 'en']) {
+ parseBlocks(path.resolve(__dirname, `../${lang}/option`)).then(function (json) {
+ for (let fileName in json) {
+ const fileTargets = json[fileName];
+ const filePath = path.resolve(__dirname, `../${lang}/option/`, fileName.replace('.', '/')) + '.md';
+ fs.writeFileSync(filePath, compositeTargets(fileTargets), 'utf-8');
+ }
+ });
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org