From 988dbc56657d3513f37f1948fa531bb6387e16b1 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Mon, 31 Oct 2022 19:17:08 +0100 Subject: [PATCH 1/4] run: make the program try multiple modules --- src/awesomewm.d.tl/init.tl | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/awesomewm.d.tl/init.tl b/src/awesomewm.d.tl/init.tl index 9486a88..743a5ec 100644 --- a/src/awesomewm.d.tl/init.tl +++ b/src/awesomewm.d.tl/init.tl @@ -24,15 +24,35 @@ log:info("Finished Module List scrapping, found " .. #module_infos .. " modules" -- log:info(inspect { items }) -- end -local html = - crawler.fetch(property.base_url .. "/widgets/wibox.widget.textbox.html") -local module_doc = scraper.module_doc.get_doc_from_page(html, "wibox.widget.textbox") --- log:info(inspect { module_doc = module_doc }) +local function do_one_file(url: string, module_name: string, output: string) + local html = crawler.fetch(url) + local module_doc = scraper.module_doc.get_doc_from_page(html, module_name) + filesystem.file_writer.write( + generator.teal_type_definitions.generate_teal(module_doc), + output + ) +end --- -- local items = scraper.get_doc_from_page(page) --- -- log:info(inspect { items }) - -filesystem.file_writer.write( - generator.teal_type_definitions.generate_teal(module_doc), +do_one_file( + property.base_url .. "/widgets/wibox.widget.textbox.html", + "wibox.widget.textbox", 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" +) -- 2.40.1 From 1b02f1b5d70018cd143d8dc07fbb3e6384beb988 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Mon, 31 Oct 2022 19:18:38 +0100 Subject: [PATCH 2/4] fix(entity): initialize Module_Doc List properties --- src/awesomewm.d.tl/entity/Module_Doc.tl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/awesomewm.d.tl/entity/Module_Doc.tl b/src/awesomewm.d.tl/entity/Module_Doc.tl index c964f39..bb50903 100644 --- a/src/awesomewm.d.tl/entity/Module_Doc.tl +++ b/src/awesomewm.d.tl/entity/Module_Doc.tl @@ -18,7 +18,13 @@ end local __Module_Doc: metatable = { __call = function(_: Module_Doc): Module_Doc - return {} + return { + constructors = List(), + methods = List(), + properties = List(), + static_functions = List(), + signals = List(), + } end, } -- 2.40.1 From 49ae0bdc916308011b01827bba7824e2b4ae5b35 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Mon, 31 Oct 2022 19:19:38 +0100 Subject: [PATCH 3/4] fix(scraper): do not fail on missing section_name --- src/awesomewm.d.tl/scraper/module_doc.tl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/awesomewm.d.tl/scraper/module_doc.tl b/src/awesomewm.d.tl/scraper/module_doc.tl index 74b8905..e92e23c 100644 --- a/src/awesomewm.d.tl/scraper/module_doc.tl +++ b/src/awesomewm.d.tl/scraper/module_doc.tl @@ -165,7 +165,7 @@ function module.get_doc_from_page(html: string, module_name: string): Module_Doc elseif section_name == "Signals" then module_doc.signals = List(extract_section_signal(dl_html)) else - error("Unknown section name: " .. section_name) + log:warn("Unknown section name: " .. section_name) end end -- 2.40.1 From 1dd2f741e6d7b7febcfce0171ac468d11e30b098 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Mon, 31 Oct 2022 19:20:16 +0100 Subject: [PATCH 4/4] fix(generator): `0` is not a nullish/falsy value --- src/awesomewm.d.tl/generator/teal_type_definitions.tl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/awesomewm.d.tl/generator/teal_type_definitions.tl b/src/awesomewm.d.tl/generator/teal_type_definitions.tl index 7fa2985..6f3d899 100644 --- a/src/awesomewm.d.tl/generator/teal_type_definitions.tl +++ b/src/awesomewm.d.tl/generator/teal_type_definitions.tl @@ -9,16 +9,16 @@ local tmpl = [[ -- Auto generated file (Do not manually edit this file!) local record $(module.record_name) -# if #module.signals then +# if #module.signals ~= 0 then $(snippets.indent(snippets.render_enum("Signal", module.signals))) # end -- /signals -# if #module.methods then +# if #module.methods ~= 0 then -- Object methods $(snippets.indent(snippets.render_record_functions(module.methods))) # end -- /methods -# if #module.properties then +# if #module.properties ~= 0 then -- Object properties $(snippets.indent(snippets.render_record_properties(module.properties))) # end -- /properties -- 2.40.1