mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-01 19:49:11 +08:00
add tool completion gen
This commit is contained in:
parent
b1836163df
commit
4ddc59c7eb
8
tools/completion_gen/README.md
Normal file
8
tools/completion_gen/README.md
Normal file
@ -0,0 +1,8 @@
|
||||
# 用于生成编辑器智能提示的数据
|
||||
|
||||
运行:
|
||||
|
||||
```
|
||||
node index.js
|
||||
```
|
||||
|
1535
tools/completion_gen/awtk.json
Normal file
1535
tools/completion_gen/awtk.json
Normal file
File diff suppressed because it is too large
Load Diff
46
tools/completion_gen/index.js
Normal file
46
tools/completion_gen/index.js
Normal file
@ -0,0 +1,46 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
let inputIDL = path.normalize(path.join(__dirname, '../idl_gen/idl.json'));
|
||||
|
||||
if(process.argv.length >= 3) {
|
||||
inputIDL = process.argv[2] || inputIDL;
|
||||
}
|
||||
|
||||
if(inputIDL === '-h' || inputIDL === '--help') {
|
||||
console.log('Usage: node index.js inputIDL');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
|
||||
function genCompletion(json) {
|
||||
widgets = json.filter((iter) => {
|
||||
return iter.annotation && iter.annotation.widget;
|
||||
});
|
||||
|
||||
let result = {}
|
||||
result.widgets = widgets.map((iter) => {
|
||||
let w = {}
|
||||
w.name = iter.name.replace(/_t$/, '');
|
||||
w.desc = iter.desc.split('\n')[0].trim('\r\n ');
|
||||
|
||||
let props = iter.properties.filter((iter) => {
|
||||
return iter.annotation && iter.annotation.design;
|
||||
});
|
||||
|
||||
w.props = props.map(iter => {
|
||||
delete iter.annotation;
|
||||
return iter;
|
||||
});
|
||||
|
||||
return w;
|
||||
});
|
||||
|
||||
let str = JSON.stringify(result, null, '\t');
|
||||
fs.writeFileSync("awtk_ui.json", str);
|
||||
|
||||
console.log(str);
|
||||
}
|
||||
|
||||
genCompletion(JSON.parse(fs.readFileSync(inputIDL).toString()));
|
||||
|
Loading…
Reference in New Issue
Block a user