Skip to content

Commit

Permalink
docs, feat: collect modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Jul 19, 2018
1 parent 5804005 commit ddc582e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
10 changes: 10 additions & 0 deletions idl/zh-cn/collect.json
@@ -0,0 +1,10 @@
{
"System": ["console", "coroutine", "global", "gui", "os", "process", "registry", "timers", "tty"],
"File System": ["fs", "io", "path", "path_posix", "path_win32"],
"Network": ["dgram", "dns", "http", "mq", "net", "punycode", "querystring", "ssl", "url", "ws", "zmq"],
"Encoding": ["base32", "base64", "base64vlq", "bson", "encoding", "hex", "iconv", "json", "string_decoder"],
"Crypto": ["crypto", "hash"],
"Compress": ["zip", "zlib"],
"Test Suite": ["assert", "profiler", "test"],
"Utility": ["db", "gd", "util", "uuid", "vm", "xml"]
}
28 changes: 23 additions & 5 deletions tools/util/parser.js
Expand Up @@ -406,9 +406,13 @@ function parser_comment(comment) {

module.exports = function (baseFolder, defs) {
var defs1 = {};
var collect = {};

fs.readdir(baseFolder).sort().forEach(f => {
if (path.extname(f) == '.idl') {
if (f === 'collect.json') {
f = path.join(baseFolder, f);
collect = JSON.parse(fs.readTextFile(f));
} else if (path.extname(f) == '.idl') {
f = path.join(baseFolder, f);
var def = parser.parse(fs.readTextFile(f));

Expand All @@ -420,14 +424,28 @@ module.exports = function (baseFolder, defs) {
}
});

var defs2 = {};
for (var g in collect) {
collect[g].forEach(n => {
var def = defs1[n];
def.collect = g;
defs2[n] = def;
delete defs1[n];
});
}

for (var n in defs1) {
defs2[n] = defs1[n];
}

if (defs) {
for (var n in defs) {
defs[n].__skip = true;
defs1[n] = defs[n];
defs2[n] = defs[n];
}

delete defs1['object'].declare.extend;
}

return defs1;
delete defs2['object'].declare.extend;

return defs2;
};
10 changes: 8 additions & 2 deletions tools/util/tmpl/README.md
@@ -1,5 +1,11 @@
# <%-title%>
<% for(var m in defs){
<% var now_collect = '';
for(var m in defs){
if(defs[m].declare.type == type){
%>* [<%-defs[m].declare.name%>](ifs/<%-defs[m].declare.name%>.md) - <%-defs[m].declare.doc.descript%>
if(now_collect !== defs[m].collect)
{
now_collect = defs[m].collect;
if(now_collect){%>* <%-now_collect%>
<%}}
if(now_collect){%> -<%}else{%>*<%}%> [<%-defs[m].declare.name%>](ifs/<%-defs[m].declare.name%>.md) - <%-defs[m].declare.doc.descript%>
<%}}%>
6 changes: 4 additions & 2 deletions tools/util/tmpl/SUMMARY.md
@@ -1,4 +1,6 @@
<% for(var m in defs){
<% var keys = Object.keys(defs);
keys.sort();
keys.forEach(m => {
if(defs[m].declare.type == type){
%>* [<%-defs[m].declare.name%>](ifs/<%-defs[m].declare.name%>.md)
<%}}%>
<%}})%>

0 comments on commit ddc582e

Please sign in to comment.