Instance level methods should have a self
parameter (#26) #28
|
@ -6,6 +6,8 @@ local record Module_Doc
|
|||
|
||||
Module_Doc: Module_Doc
|
||||
|
||||
record_name: string
|
||||
|
||||
constructors: List<Function_Info.Function_Info>
|
||||
methods: List<Function_Info.Function_Info>
|
||||
static_functions: List<Function_Info.Function_Info>
|
||||
|
|
|
@ -8,7 +8,7 @@ local snippets = require "generator.snippets"
|
|||
local tmpl = [[
|
||||
-- Auto generated file (Do not manually edit this file!)
|
||||
|
||||
local record $(mod_name)
|
||||
local record $(module.record_name)
|
||||
# if #module.signals then
|
||||
$(snippets.indent(snippets.render_enum("Signal", module.signals)))
|
||||
|
||||
|
@ -19,15 +19,14 @@ $(snippets.indent(snippets.render_record_functions(module.methods)))
|
|||
# end -- /methods
|
||||
end
|
||||
|
||||
return $(mod_name)
|
||||
return $(module.record_name)
|
||||
]]
|
||||
|
||||
local module = {}
|
||||
|
||||
function module.generate_teal(mod: string, data: Module_Doc.Module_Doc): string
|
||||
function module.generate_teal(data: Module_Doc.Module_Doc): string
|
||||
local tmpl_args = {
|
||||
ipairs = ipairs,
|
||||
mod_name = mod,
|
||||
module = data,
|
||||
snippets = snippets,
|
||||
}
|
||||
|
|
|
@ -26,14 +26,13 @@ log:info("Finished Module List scrapping, found " .. #module_infos .. " modules"
|
|||
|
||||
local html =
|
||||
crawler.fetch(property.base_url .. "/widgets/wibox.widget.textbox.html")
|
||||
local module_doc = scraper.module_doc.get_doc_from_page(html)
|
||||
local module_doc = scraper.module_doc.get_doc_from_page(html, "wibox.widget.textbox")
|
||||
-- log:info(inspect { module_doc = module_doc })
|
||||
|
||||
-- -- local items = scraper.get_doc_from_page(page)
|
||||
-- -- log:info(inspect { items })
|
||||
|
||||
local mod = "textbox"
|
||||
filesystem.file_writer.write(
|
||||
generator.teal_type_definitions.generate_teal(mod, module_doc),
|
||||
property.out_directory .. "/" .. mod .. ".d.tl"
|
||||
generator.teal_type_definitions.generate_teal(module_doc),
|
||||
property.out_directory .. "/textbox.d.tl"
|
||||
)
|
||||
|
|
|
@ -90,7 +90,7 @@ end
|
|||
|
||||
local module = {}
|
||||
|
||||
function module.get_doc_from_page(html: string): Module_Doc.Module_Doc
|
||||
function module.get_doc_from_page(html: string, module_name: string): Module_Doc.Module_Doc
|
||||
local nodes = scraper_utils.extract_nodes(html, {
|
||||
"h2.section-header",
|
||||
"dl.function",
|
||||
|
@ -101,6 +101,7 @@ function module.get_doc_from_page(html: string): Module_Doc.Module_Doc
|
|||
end
|
||||
|
||||
local module_doc = Module_Doc()
|
||||
module_doc.record_name = module_name:gsub(".*%.", ""):gsub("^%l", string.upper)
|
||||
|
||||
for i = 1, #nodes:get("h2.section-header") do
|
||||
local h2 = nodes:get("h2.section-header")[i]
|
||||
|
@ -116,7 +117,13 @@ function module.get_doc_from_page(html: string): Module_Doc.Module_Doc
|
|||
elseif section_name == "Deprecated object properties" then
|
||||
log:warn("Not implemented: Deprecated object properties")
|
||||
elseif section_name == "Object methods" then
|
||||
module_doc.methods = List(extract_section_functions(dl_html))
|
||||
module_doc.methods = List(extract_section_functions(dl_html)):map(function(method: Function_Info.Function_Info): Function_Info.Function_Info
|
||||
method.parameters:insert(1, {
|
||||
name = "self",
|
||||
types = List({ module_doc.record_name }),
|
||||
})
|
||||
return method
|
||||
end)
|
||||
elseif section_name == "Signals" then
|
||||
module_doc.signals = List(extract_section_signal(dl_html))
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue