This commit is contained in:
Aleksey Chichenkov 2018-12-21 18:19:36 +03:00
parent 3c47d6f1c3
commit 0f52f78c10
3 changed files with 65 additions and 16 deletions

View File

@ -18,14 +18,6 @@ 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;
@ -915,6 +907,19 @@ exports.publish = function(taffyData, opts, tutorials) {
console.log("outdir", outdir)
var sih = require("./search_inheritance.js");
var inh_struct = sih.find(env.conf, helper, logger, generate);
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);
// Arch
var html = view.render('arch.tmpl', {
env: env,

View File

@ -12,24 +12,31 @@ var __tree_list = Object.create(null);
var __root;
var map = {};
var destination;
var output;
var helper;
var logger;
var generate;
var find = function (_conf) {
var find = function (_conf, _helper, _logger, _generate) {
helper = _helper;
logger = _logger;
generate = _generate;
__root = new Node();
// console.log("start find");
destination = path.normalize(_conf.source.include_2[0]);
output = path.normalize(_conf.opts.destination);
recursive(destination);
generate_tree();
return __root.get_struct();
generate_files();
var struct = __root.get_struct();
return 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++) {
@ -37,7 +44,6 @@ var recursive = function(_path){
recursive(_path + "/" + name);
}
} else {
// console.log("FILE: ", _path);
parse_file(_path);
}
};
@ -102,7 +108,8 @@ var update_link_file = function (_path) {
var generate_tree = function() {
__root.name = "std.base";
__root.name = "std.class";
__root.path = destination + "/std/class";
for (var path in map) {
var file_info = map[path];
@ -135,6 +142,7 @@ var recursive_tree = function (_file_name, _file_info, _child) {
// console.log(_file_name);
}
node.name = name;
node.path = _file_name;
__tree_list[path] = node;
}
@ -156,6 +164,8 @@ var recursive_tree = function (_file_name, _file_info, _child) {
var Node = function(){
this.children = [];
this.name = "";
this.path = "no_path";
this.link = "#no_link";
this.inherit = "base_class";
};
@ -165,11 +175,44 @@ Node.prototype = {
for(var a = 0; a < this.children.length; a++){
children.push(this.children[a].get_struct());
}
// console.log(this.path);
return {
name: this.name,
path: this.path,
link: this.link,
children: children
}
}
};
var generate_files = function(){
if(!fs.existsSync(output)){
fs.mkdirSync(output);
}
for(var key in __tree_list){
var node = __tree_list[key];
var name = node.path.split("/").splice(6).join("_");
var out_path = output + "/" + name + ".html";
node.link = name + ".html";
// console.log(node.link, node.name);
try {
var source = {
kind: 'source',
code: helper.htmlsafe( fs.readFileSync(node.path, 'utf8') )
};
}
catch (e) {
logger.error('Error while generating source file %s: %s', name, e.message);
}
generate('Source: ' + node.name, [source], out_path, false);
}
};
module.exports.find = find;

View File

@ -168,6 +168,7 @@
// Toggle children on click.
function click(d) {
window.open(d.link);
// if (d.children) {
// d._children = d.children;
// d.children = null;