run: some play with the entrypoint

This commit is contained in:
Aire-One 2023-01-29 19:22:19 +01:00
parent ab28bf8717
commit 09181259e1
1 changed files with 81 additions and 71 deletions

View File

@ -65,78 +65,88 @@ local function modules_tree(modules: List<Module_Info.Module_Info>): Map<string,
return tree return tree
end end
local function do_one_file( -- local function do_one_file(
url: string, -- url: string,
record_name: string, -- record_name: string,
output_path: string -- output_path: string
) -- )
local html = crawler.fetch(url) -- local html = crawler.fetch(url)
local module_doc = scraper.module_doc.get_doc_from_page(html, record_name) -- local module_doc = scraper.module_doc.get_doc_from_page(html, record_name)
module_doc:fixup() -- module_doc:fixup()
module_doc:populate_requires() -- module_doc:populate_requires()
filesystem.file_writer.write( -- filesystem.file_writer.write(
generator.teal_type_definitions.generate_teal(module_doc), -- generator.teal_type_definitions.generate_teal(module_doc),
output_path -- output_path
) -- )
end -- end
local all_module_infos, module_infos, global_module_infos = module_lists( -- local all_module_infos, module_infos, global_module_infos = module_lists(
property.base_url .. property.index_uri, -- property.base_url .. property.index_uri,
List(property.capi_modules), -- List(property.capi_modules),
List(property.ignored_modules) -- List(property.ignored_modules)
) -- )
local tree = modules_tree(module_infos) -- local tree = modules_tree(module_infos)
log:info( -- log:info(
logger.message_with_metadata( -- logger.message_with_metadata(
"Finished Module List scrapping", -- "Finished Module List scrapping",
{ -- {
total_module_count = #all_module_infos, -- total_module_count = #all_module_infos,
module_count = #module_infos, -- module_count = #module_infos,
global_module_count = #global_module_infos, -- global_module_count = #global_module_infos,
tree_items = tree:len(), -- tree_items = tree:len(),
} -- }
) -- )
-- )
-- for module in module_infos:iter() do
-- do_one_file(
-- property.base_url .. "/" .. module.uri,
-- module.name,
-- property.out_directory .. "/" .. module.name:gsub("%.", "/") .. ".d.tl"
-- )
-- end
-- local global_env_def: List<Module_Doc.Module_Doc> = List()
-- for module in global_module_infos:iter() do
-- if module.name:gmatch(".*%sand%s.*") then
-- do_one_file(
-- property.base_url .. "/" .. module.uri,
-- module.name,
-- property.out_directory .. "/" .. module.name:gsub(".*%sand%s", ""):gsub("%.", "/") .. ".d.tl"
-- )
-- end
-- local html = crawler.fetch(property.base_url .. "/" .. module.uri)
-- local module_doc = scraper.module_doc.get_doc_from_page(html, (module.name:gsub("%sand%s.*", "")))
-- module_doc:fixup()
-- module_doc.record_name = utils.lowercase(module_doc.record_name)
-- global_env_def:append(module_doc)
-- end
-- filesystem.file_writer.write(
-- generator.global_env_def.generate_teal(global_env_def),
-- property.out_directory .. "/global_env.d.tl"
-- )
-- for module, children in tree:iter() do
-- -- TODO : this map should be coupled with the all_module_infos list
-- local requires: Map<string, string> = Map()
-- for child in children:iter() do
-- local name = child:gmatch(".*%.(.*)$")()
-- requires:set(name, child)
-- end
-- filesystem.file_writer.write(
-- generator.module_init_definition.generate_teal(requires),
-- property.out_directory .. "/" .. stringx.split(module, "."):slice(1, -1):join("/") .. "/init.d.tl"
-- )
-- end
local module_ast, other_nodes = scraper.module_doc.get_doc_from_page(
crawler.fetch(property.base_url .. "/widgets/wibox.widget.imagebox.html"),
"awful.tag"
) )
for module in module_infos:iter() do log:info(logger.message_with_metadata("Finished", {
do_one_file( module_ast = module_ast,
property.base_url .. "/" .. module.uri, other_nodes = other_nodes,
module.name, }))
property.out_directory .. "/" .. module.name:gsub("%.", "/") .. ".d.tl"
)
end
local global_env_def: List<Module_Doc.Module_Doc> = List()
for module in global_module_infos:iter() do
if module.name:gmatch(".*%sand%s.*") then
do_one_file(
property.base_url .. "/" .. module.uri,
module.name,
property.out_directory .. "/" .. module.name:gsub(".*%sand%s", ""):gsub("%.", "/") .. ".d.tl"
)
end
local html = crawler.fetch(property.base_url .. "/" .. module.uri)
local module_doc = scraper.module_doc.get_doc_from_page(html, (module.name:gsub("%sand%s.*", "")))
module_doc:fixup()
module_doc.record_name = utils.lowercase(module_doc.record_name)
global_env_def:append(module_doc)
end
filesystem.file_writer.write(
generator.global_env_def.generate_teal(global_env_def),
property.out_directory .. "/global_env.d.tl"
)
for module, children in tree:iter() do
-- TODO : this map should be coupled with the all_module_infos list
local requires: Map<string, string> = Map()
for child in children:iter() do
local name = child:gmatch(".*%.(.*)$")()
requires:set(name, child)
end
filesystem.file_writer.write(
generator.module_init_definition.generate_teal(requires),
property.out_directory .. "/" .. stringx.split(module, "."):slice(1, -1):join("/") .. "/init.d.tl"
)
end