From 776e9acd033d80328d4de52dcf85a2b2e1185f41 Mon Sep 17 00:00:00 2001 From: Aleksey Chichenkov Date: Mon, 10 Dec 2018 11:04:43 +0300 Subject: [PATCH] updates --- conf.json | 3 + docfiles/mainpage/main.js | 5 + templates/initi/publish.js | 63 +++++- templates/initi/search_inheritance.js | 175 ++++++++++++++++ templates/initi/search_inheritance2.js | 194 +++++++++++++++++ templates/initi/search_inheritance_core.js | 172 +++++++++++++++ templates/initi/tmpl/arch.tmpl | 12 +- templates/initi/tmpl/inheritance.tmpl | 182 ++++++++++++++++ templates/initi/tmpl/inheritance2.tmpl | 183 ++++++++++++++++ templates/initi/tmpl/inheritance3.tmpl | 231 +++++++++++++++++++++ 10 files changed, 1214 insertions(+), 6 deletions(-) create mode 100644 templates/initi/search_inheritance.js create mode 100644 templates/initi/search_inheritance2.js create mode 100644 templates/initi/search_inheritance_core.js create mode 100644 templates/initi/tmpl/inheritance.tmpl create mode 100644 templates/initi/tmpl/inheritance2.tmpl create mode 100644 templates/initi/tmpl/inheritance3.tmpl diff --git a/conf.json b/conf.json index 81262cf..fec636f 100644 --- a/conf.json +++ b/conf.json @@ -5,6 +5,9 @@ "recurseDepth": 10, "source": { "include": ["docfiles"], + "include_2": ["../develop/first/gui/js/providers"], + "include_3": ["../develop/first/gui/js"], + "core": ["../develop/first/core"], "includePattern": ".+\\.js(doc|x)?$", "excludePattern": "(^|\\/|\\\\)_" }, diff --git a/docfiles/mainpage/main.js b/docfiles/mainpage/main.js index e0a9c1e..37626cc 100644 --- a/docfiles/mainpage/main.js +++ b/docfiles/mainpage/main.js @@ -23,6 +23,11 @@ /** * ### Содержание: * - #### [Архитектура](./arch.html) + * - #### [Наследование](./inheritance.html) + * - #### [Наследование GUI(деревом)](./gui_tree.html) + * - #### [Наследование GUI(графом)](./gui_graph.html) + * - #### [Наследование CORE(деревом)](./core_tree.html) + * - #### [Наследование CORE(графом)](./core_graph.html) * - #### Виджеты * - #### Датасорсы * - #### Сигнал-Слоты diff --git a/templates/initi/publish.js b/templates/initi/publish.js index 098427d..ee6dd60 100644 --- a/templates/initi/publish.js +++ b/templates/initi/publish.js @@ -1,5 +1,4 @@ 'use strict'; - var doop = require('jsdoc/util/doop'); var env = require('jsdoc/env'); var fs = require('jsdoc/fs'); @@ -19,7 +18,14 @@ var replace_enters_to_br = pct.replace_enters_to_br; var resolveAuthorLinks = helper.resolveAuthorLinks; var hasOwnProp = Object.prototype.hasOwnProperty; +var sih = require("./search_inheritance.js"); +var inh_struct = sih.find(env.conf); +var sih2 = require("./search_inheritance2.js"); +var inh_struct2 = sih2.find(env.conf); + +var sih_core = require("./search_inheritance_core.js"); +var inh_struct_core = sih_core.find(env.conf); var data; @@ -919,6 +925,61 @@ exports.publish = function(taffyData, opts, tutorials) { fs.writeFileSync(outdir + "/arch.html", html, 'utf8'); + // providers tree + var html = view.render('inheritance.tmpl', { + inheritance: inh_struct, + env: env, + title: "", + }); + html = helper.resolveLinks(html); // turn {@link foo} into foo + // fs.createFileSync("/arch.html", html, 'utf8'); + fs.writeFileSync(outdir + "/inheritance.html", html, 'utf8'); + + // gui tree + html = view.render('inheritance2.tmpl', { + inheritance: inh_struct2, + height: 15100, + env: env, + title: "", + }); + html = helper.resolveLinks(html); // turn {@link foo} into foo + // fs.createFileSync("/arch.html", html, 'utf8'); + fs.writeFileSync(outdir + "/gui_tree.html", html, 'utf8'); + + // gui graph + html = view.render('inheritance3.tmpl', { + inheritance: inh_struct2, + height: 1600, + env: env, + title: "", + }); + html = helper.resolveLinks(html); // turn {@link foo} into foo + // fs.createFileSync("/arch.html", html, 'utf8'); + fs.writeFileSync(outdir + "/gui_graph.html", html, 'utf8'); + + + // core tree + html = view.render('inheritance2.tmpl', { + inheritance: inh_struct_core, + height: 10000, + env: env, + title: "", + }); + html = helper.resolveLinks(html); + fs.writeFileSync(outdir + "/core_tree.html", html, 'utf8'); + + + // core graph + html = view.render('inheritance3.tmpl', { + inheritance: inh_struct_core, + height: 800, + env: env, + title: "", + }); + html = helper.resolveLinks(html); + fs.writeFileSync(outdir + "/core_graph.html", html, 'utf8'); + + // set up the lists that we'll use to generate pages classes = taffy(members.classes); modules = taffy(members.modules); diff --git a/templates/initi/search_inheritance.js b/templates/initi/search_inheritance.js new file mode 100644 index 0000000..b02eb6e --- /dev/null +++ b/templates/initi/search_inheritance.js @@ -0,0 +1,175 @@ +/** + * Created by Aleksey Chichenkov on 12/6/18. + */ + +var fs = require("fs"); +var path = require('jsdoc/path'); + +var rx_class_declarator_std = /var *(.*?)(?:| )=(?:| ) std.class\(\[(.*?)\]/im; +var rx_requires = /var {1,}?(.*?) {1,}?= {1,}?require\("(.*?)"\)/i; + +var __tree_list = Object.create(null); +var __root; +var map = {}; +var destination; + + +var find = function (_conf) { + __root = new Node(); + + // console.log("start find"); + + destination = path.normalize(_conf.source.include_2[0]); + recursive(destination); + generate_tree(); + return __root.get_struct(); +}; + +var recursive = function(_path){ + + if(fs.lstatSync(_path).isDirectory()) { + // console.log("DIRECTORY: ",_path); + + var arr = fs.readdirSync(_path); + + for (var a = 0; a < arr.length; a++) { + var name = arr[a]; + recursive(_path + "/" + name); + } + } else { + // console.log("FILE: ", _path); + parse_file(_path); + } +}; + + +var parse_file = function(_path){ + let info = Object.create(null); + info.requires = Object.create(null); + info.classes = Object.create(null); + + var file = fs.readFileSync(_path, "utf8"); + var requires = exec_all(rx_requires, file); + if(requires.length > 0) { + for(var a = 0; a < requires.length; a++){ + info.requires[requires[a].subs[0]] = update_link_file(requires[a].subs[1]) + } + } + + var classes = exec_all(rx_class_declarator_std, file); + if(classes.length > 0) { + for(var a = 0; a < classes.length; a++){ + info.classes[classes[a].subs[0]] = classes[a].subs[1] + } + } + + map[_path] = info; +}; + + +var exec_all = function(_rx, _string){ + var out = []; + var result; + while(result = _string.match(_rx)){ + + result = convert_result(result); + // console.log("result", result); + + _string = _string.substring(result.index + result.match.length, _string.length); + out.push(result); + } + return out +}; + +var convert_result = function(_exec_result) { + var info = Object.create(null); + info.index = _exec_result.index; + info.match = _exec_result[0]; + info.subs = []; + + for (var a = 1; a < _exec_result.length; a++) { + info.subs.push(_exec_result[a]); + } + + return info; +}; + +var update_link_file = function (_path) { + var arr = destination.split("/"); + arr.pop(); + return arr.join("/") + "/" + _path + ".js" +}; + + +var generate_tree = function() { + __root.name = "std.base"; + + for (var path in map) { + var file_info = map[path]; + recursive_tree(path, file_info); + } + + for(var name in __tree_list){ + var n = __tree_list[name]; + if(n.inherit === "base_class"){ + __root.children.push(n); + } + } +}; + +var recursive_tree = function (_file_name, _file_info, _child) { + if(!_file_info){ + console.log("ERROR: ", _file_name); + return; + } + + var classes = _file_info.classes; + var requires = _file_info.requires; + + for(var name in classes){ + var path = _file_name + ":" + name; + var node = __tree_list[path]; + if(!node){ + node = new Node(); + if(name == "data"){ + // console.log(_file_name); + } + node.name = name; + __tree_list[path] = node; + } + + var inheritance = classes[name]; + + var req = requires[inheritance]; + if(req){ + if(_child && node.children.indexOf(_child) === -1){ + _child.inherit = name; + node.children.push(_child); + } + + var fi = map[req]; + recursive_tree(req, fi, node); + } + } +}; + +var Node = function(){ + this.children = []; + this.name = ""; + this.inherit = "base_class"; +}; + +Node.prototype = { + get_struct: function () { + var children = []; + for(var a = 0; a < this.children.length; a++){ + children.push(this.children[a].get_struct()); + } + return { + name: this.name, + children: children + } + } +}; + +module.exports.find = find; \ No newline at end of file diff --git a/templates/initi/search_inheritance2.js b/templates/initi/search_inheritance2.js new file mode 100644 index 0000000..b604ee3 --- /dev/null +++ b/templates/initi/search_inheritance2.js @@ -0,0 +1,194 @@ +/** + * Created by Aleksey Chichenkov on 12/6/18. + */ + +var fs = require("fs"); +var path = require('jsdoc/path'); + +var rx_class_declarator_std = /var {1,}?(.*?) {1,}?= {1,}?(.*?)\.inherit\(\{/i; +var rx_requires = /var {1,}?(.*?) {1,}?= {1,}?require\("(.*?)"\)/i; + +var __tree_list = Object.create(null); +var __root; +var map = {}; +var destination; + + +var find = function (_conf) { + __root = new Node(); + + // console.log("start find"); + + destination = path.normalize(_conf.source.include_3[0]); + + // console.log("================="); + // console.log("===== START ====="); + // console.log("================="); + // console.log("================="); + // console.log("====== END ======"); + // console.log("================="); + + recursive(destination); + + + // console.log("================================================="); + // console.log("var map = JSON.parse('%s');", JSON.stringify(map)); + // console.log("================================================="); + + generate_tree(); + + // console.log("================================================="); + // console.log("JSON.parse('%s');", JSON.stringify(__tree_list)); + // console.log("================================================="); + + return __root.get_struct(); +}; + +var recursive = function(_path){ + + if(fs.lstatSync(_path).isDirectory()) { + // console.log("DIRECTORY: ",_path); + + var arr = fs.readdirSync(_path); + + for (var a = 0; a < arr.length; a++) { + var name = arr[a]; + recursive(_path + "/" + name); + } + } else { + // console.log("FILE: ", _path); + parse_file(_path); + } +}; + + +var parse_file = function(_path){ + let info = Object.create(null); + info.requires = Object.create(null); + info.classes = Object.create(null); + + var file = fs.readFileSync(_path, "utf8"); + var requires = exec_all(rx_requires, file); + if(requires.length > 0) { + for(var a = 0; a < requires.length; a++){ + info.requires[requires[a].subs[0]] = update_link_file(requires[a].subs[1]) + } + } + + var classes = exec_all(rx_class_declarator_std, file); + if(classes.length > 0) { + for(var a = 0; a < classes.length; a++){ + info.classes[classes[a].subs[0]] = classes[a].subs[1] + } + } + + map[_path] = info; +}; + + +var exec_all = function(_rx, _string){ + var out = []; + var result; + while(result = _string.match(_rx)){ + + result = convert_result(result); + // console.log("result", result); + + _string = _string.substring(result.index + result.match.length, _string.length); + out.push(result); + } + return out +}; + +var convert_result = function(_exec_result) { + var info = Object.create(null); + info.index = _exec_result.index; + info.match = _exec_result[0]; + info.subs = []; + + for (var a = 1; a < _exec_result.length; a++) { + info.subs.push(_exec_result[a]); + } + + return info; +}; + +var update_link_file = function (_path) { + var arr = destination.split("/"); + // arr.pop(); + return arr.join("/") + "/" + _path + ".js" +}; + + +var generate_tree = function() { + __root.name = "BaseClass"; + + for (var path in map) { + var file_info = map[path]; + recursive_tree(path, file_info); + } + + for(var name in __tree_list){ + var n = __tree_list[name]; + if(n.inherit === "base_class"){ + __root.children.push(n); + } + } +}; + +var recursive_tree = function (_file_name, _file_info, _child) { + if(!_file_info){ + // console.log("ERROR: ", _file_name); + return; + } + + var classes = _file_info.classes; + var requires = _file_info.requires; + + for(var name in classes){ + var path = _file_name + ":" + name; + var node = __tree_list[path]; + if(!node){ + node = new Node(); + node.name = name; + __tree_list[path] = node; + } + + var inheritance = classes[name]; + + var req = requires[inheritance]; + + // console.log("CLASS: %s, REQUIRE: %s", name, req); + + if(req){ + if(_child && node.children.indexOf(_child) === -1){ + _child.inherit = name; + node.children.push(_child); + } + + var fi = map[req]; + recursive_tree(req, fi, node); + } + } +}; + +var Node = function(){ + this.children = []; + this.name = ""; + this.inherit = "base_class"; +}; + +Node.prototype = { + get_struct: function () { + var children = []; + for(var a = 0; a < this.children.length; a++){ + children.push(this.children[a].get_struct()); + } + return { + name: this.name, + children: children + } + } +}; + +module.exports.find = find; \ No newline at end of file diff --git a/templates/initi/search_inheritance_core.js b/templates/initi/search_inheritance_core.js new file mode 100644 index 0000000..b1f3f0c --- /dev/null +++ b/templates/initi/search_inheritance_core.js @@ -0,0 +1,172 @@ +/** + * Created by Aleksey Chichenkov on 12/6/18. + */ + +var fs = require("fs"); +var path = require('jsdoc/path'); + +var rx_match_modelType = /ModelType {1,}?([A-Za-z]{1,}?)\(@(.*)?\)/i; + +var __tree_list = Object.create(null); +var __root; +var map = { + "mObject": "" +}; +var destination; + +var ignore = { + ".git": true +}; + +var avail_format = { + "xxc": true +}; + +var find = function (_conf) { + __root = new Node(); + destination = path.normalize(_conf.source.core[0]); + recursive(destination); + generate_tree(); + return __root.get_struct(); +}; + +var recursive = function(_path){ + + if(fs.lstatSync(_path).isDirectory()) { + // console.log("DIRECTORY: ",_path); + + var arr = fs.readdirSync(_path); + + for (var a = 0; a < arr.length; a++) { + var name = arr[a]; + if (!ignore[name]) { + recursive(_path + "/" + name); + } + } + } else { + console.log("FILE: ", _path); + var extenstion = _path.split(".").pop(); + if (avail_format[extenstion]) { + parse_file(_path); + } + } +}; + +var parse_file = function(_path){ + let info = Object.create(null); + info.requires = Object.create(null); + info.classes = Object.create(null); + + var file = fs.readFileSync(_path, "utf8"); + var classes = exec_all(rx_match_modelType, file); + if(classes.length > 0) { + for(var a = 0; a < classes.length; a++){ + map[classes[a].subs[0]] = classes[a].subs[1]; + } + } +}; + +var exec_all = function(_rx, _string){ + var out = []; + var result; + while(result = _string.match(_rx)){ + result = convert_result(result); + _string = _string.substring(result.index + result.match.length, _string.length); + out.push(result); + } + return out +}; + +var convert_result = function(_exec_result) { + var info = Object.create(null); + info.index = _exec_result.index; + info.match = _exec_result[0]; + info.subs = []; + + for (var a = 1; a < _exec_result.length; a++) { + info.subs.push(_exec_result[a]); + } + + return info; +}; + +var generate_tree = function() { + __root.name = "BaseClass"; + + for (var type in map) { + var inherit = map[type]; + recursive_tree(type, inherit); + } + +}; + +var recursive_tree = function (_type_name, _inherit, _child) { + if(_type_name === "mObject"){ + console.log("create mObject"); + var n = new Node(); + n.name = _type_name; + n.inherit = __root.name; + __root.children.push(n); + __tree_list[_type_name] = n; + return; + } + + if(_type_name !== "mObject" && !_type_name){ + console.log("ERROR: TYPE %s, INHERIT: %s, ChildName: %s", _type_name, _inherit, _child.name); + process.exit(1); + } else { + console.log("CLASS: %s, INHERIT: %s", _type_name, _inherit); + } + + + var node = __tree_list[_type_name]; + if(!node){ + node = new Node(); + node.name = _type_name; + __tree_list[_type_name] = node; + + if(_child && node.children.indexOf(_child) === -1){ + _child.inherit = _type_name; + node.children.push(_child); + } + } + + var parent = __tree_list[_inherit]; + if(parent){ + if(parent.children.indexOf(node) === -1) { + node.inherit = _inherit; + parent.children.push(node); + } + } else { + var inh = map[_inherit]; + if(inh) { + recursive_tree(_inherit, inh, node); + } else { + if(__root.children.indexOf(node) === -1) { + __root.children.push(node); + node.inherit = __root.name; + } + } + } +}; + +var Node = function(){ + this.children = []; + this.name = ""; + this.inherit = "base_class"; +}; + +Node.prototype = { + get_struct: function () { + var children = []; + for(var a = 0; a < this.children.length; a++){ + children.push(this.children[a].get_struct()); + } + return { + name: this.name, + children: children + } + } +}; + +module.exports.find = find; \ No newline at end of file diff --git a/templates/initi/tmpl/arch.tmpl b/templates/initi/tmpl/arch.tmpl index 397a2c9..24903c5 100644 --- a/templates/initi/tmpl/arch.tmpl +++ b/templates/initi/tmpl/arch.tmpl @@ -80,9 +80,6 @@ { name: "Node", children: [ - { - name: "Children", - }, { name: "Scheme", children: [ @@ -125,10 +122,15 @@ ] }, { - name: "global_tree", + name: "GlobalTree", children: [ { - name: "Node" + name: "Node", + children: [ + { + name: "Children", + } + ] }, { name: "NodeTypes", diff --git a/templates/initi/tmpl/inheritance.tmpl b/templates/initi/tmpl/inheritance.tmpl new file mode 100644 index 0000000..cb14879 --- /dev/null +++ b/templates/initi/tmpl/inheritance.tmpl @@ -0,0 +1,182 @@ + + + + + + +
+
+
+ + + + + + diff --git a/templates/initi/tmpl/inheritance2.tmpl b/templates/initi/tmpl/inheritance2.tmpl new file mode 100644 index 0000000..4a80336 --- /dev/null +++ b/templates/initi/tmpl/inheritance2.tmpl @@ -0,0 +1,183 @@ + + + + + + +
+
+
+ + + + + + diff --git a/templates/initi/tmpl/inheritance3.tmpl b/templates/initi/tmpl/inheritance3.tmpl new file mode 100644 index 0000000..1290ce5 --- /dev/null +++ b/templates/initi/tmpl/inheritance3.tmpl @@ -0,0 +1,231 @@ + + + + + + +
+
+
+ + + + + +