Make the program try multiple modules #35

Merged
Aire-One merged 4 commits from feat/init-try-multiple-modules into master 2022-10-31 19:28:54 +01:00
4 changed files with 40 additions and 14 deletions

View File

@ -18,7 +18,13 @@ end
local __Module_Doc: metatable<Module_Doc> = { local __Module_Doc: metatable<Module_Doc> = {
__call = function(_: Module_Doc): Module_Doc __call = function(_: Module_Doc): Module_Doc
return {} return {
constructors = List(),
methods = List(),
properties = List(),
static_functions = List(),
signals = List(),
}
end, end,
} }

View File

@ -9,16 +9,16 @@ local tmpl = [[
-- Auto generated file (Do not manually edit this file!) -- Auto generated file (Do not manually edit this file!)
local record $(module.record_name) local record $(module.record_name)
# if #module.signals then # if #module.signals ~= 0 then
$(snippets.indent(snippets.render_enum("Signal", module.signals))) $(snippets.indent(snippets.render_enum("Signal", module.signals)))
# end -- /signals # end -- /signals
# if #module.methods then # if #module.methods ~= 0 then
-- Object methods -- Object methods
$(snippets.indent(snippets.render_record_functions(module.methods))) $(snippets.indent(snippets.render_record_functions(module.methods)))
# end -- /methods # end -- /methods
# if #module.properties then # if #module.properties ~= 0 then
-- Object properties -- Object properties
$(snippets.indent(snippets.render_record_properties(module.properties))) $(snippets.indent(snippets.render_record_properties(module.properties)))
# end -- /properties # end -- /properties

View File

@ -24,15 +24,35 @@ log:info("Finished Module List scrapping, found " .. #module_infos .. " modules"
-- log:info(inspect { items }) -- log:info(inspect { items })
-- end -- end
local html = local function do_one_file(url: string, module_name: string, output: string)
crawler.fetch(property.base_url .. "/widgets/wibox.widget.textbox.html") local html = crawler.fetch(url)
local module_doc = scraper.module_doc.get_doc_from_page(html, "wibox.widget.textbox") local module_doc = scraper.module_doc.get_doc_from_page(html, module_name)
-- log:info(inspect { module_doc = module_doc }) filesystem.file_writer.write(
-- -- local items = scraper.get_doc_from_page(page)
-- -- log:info(inspect { items })
filesystem.file_writer.write(
generator.teal_type_definitions.generate_teal(module_doc), generator.teal_type_definitions.generate_teal(module_doc),
output
)
end
do_one_file(
property.base_url .. "/widgets/wibox.widget.textbox.html",
"wibox.widget.textbox",
property.out_directory .. "/textbox.d.tl" property.out_directory .. "/textbox.d.tl"
) )
do_one_file(
property.base_url .. "/popups_and_bars/wibox.html",
"wibox",
property.out_directory .. "/wibox.d.tl"
)
do_one_file(
property.base_url .. "/widget_layouts/wibox.layout.fixed.html",
"wibox.layout.fixed",
property.out_directory .. "/fixed.d.tl"
)
do_one_file(
property.base_url .. "/core_components/client.html",
"client",
property.out_directory .. "/client.d.tl"
)

View File

@ -165,7 +165,7 @@ function module.get_doc_from_page(html: string, module_name: string): Module_Doc
elseif section_name == "Signals" then elseif section_name == "Signals" then
module_doc.signals = List(extract_section_signal(dl_html)) module_doc.signals = List(extract_section_signal(dl_html))
else else
error("Unknown section name: " .. section_name) log:warn("Unknown section name: " .. section_name)
end end
end end