Define modules init.d.tl
file (#61) #69
|
@ -3,10 +3,12 @@ local filesystem = require "filesystem"
|
|||
local generator = require "generator"
|
||||
local List = require "pl.List"
|
||||
local logger = require "logger"
|
||||
local Map = require "pl.Map"
|
||||
local Module_Doc = require "entity.Module_Doc"
|
||||
local Module_Info = require "entity.Module_Info"
|
||||
local property = require "property"
|
||||
local scraper = require "scraper"
|
||||
local stringx = require "pl.stringx"
|
||||
local utils = require "utils"
|
||||
|
||||
local log = logger.log("main")
|
||||
|
@ -35,6 +37,32 @@ local function module_lists(
|
|||
return all_module_infos, module_infos, global_module_infos
|
||||
end
|
||||
|
||||
local function modules_tree(modules: List<Module_Info.Module_Info>): Map<string, List<string>>
|
||||
local tree: Map<string, List<string>> = Map()
|
||||
for module in modules:iter() do
|
||||
local parent = module.name:gmatch("(.*)%.(.*)$")()
|
||||
if parent then
|
||||
local ancestors = stringx.split(parent, ".")
|
||||
for i = 1, #ancestors - 1 do
|
||||
local ancestor = ancestors:slice(1, i):join(".")
|
||||
if not tree:get(ancestor) then
|
||||
tree:set(ancestor, List())
|
||||
end
|
||||
if not tree:get(ancestor):contains(parent) then
|
||||
tree:get(ancestor):append(parent)
|
||||
end
|
||||
end
|
||||
local parent_node = tree:get(parent)
|
||||
if not parent_node then
|
||||
tree:set(parent, List())
|
||||
parent_node = tree:get(parent)
|
||||
end
|
||||
parent_node:append(module.name)
|
||||
end
|
||||
end
|
||||
return tree
|
||||
end
|
||||
|
||||
local function do_one_file(
|
||||
url: string,
|
||||
record_name: string,
|
||||
|
@ -55,6 +83,7 @@ local all_module_infos, module_infos, global_module_infos = module_lists(
|
|||
List(property.capi_modules),
|
||||
List(property.ignored_modules)
|
||||
)
|
||||
local tree = modules_tree(module_infos)
|
||||
|
||||
log:info(
|
||||
logger.message_with_metadata(
|
||||
|
@ -62,7 +91,8 @@ log:info(
|
|||
{
|
||||
total_module_count = #all_module_infos,
|
||||
module_count = #module_infos,
|
||||
global_module_count = #global_module_infos
|
||||
global_module_count = #global_module_infos,
|
||||
tree_items = tree:len(),
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue