Support table parameters and record types (#37) #38
|
@ -27,20 +27,45 @@ local function extract_item_name(item_name_node: scan.HTMLNode): string
|
|||
end
|
||||
|
||||
local function extract_function_parameters(function_parameters_node: scan.HTMLNode): { Function_Info.Parameter }
|
||||
local current_record_parameter: string = nil
|
||||
|
||||
return scraper_utils.scrape(
|
||||
function_parameters_node:outer_html(),
|
||||
"tr",
|
||||
function(line_node: scan.HTMLNode): Function_Info.Parameter
|
||||
if line_node.attr ~= nil and line_node.attr.class == "see_also_sublist" then
|
||||
log:debug("subtable found, skipping")
|
||||
return nil
|
||||
end
|
||||
|
||||
local query_selectors = {
|
||||
name = "span.parameter",
|
||||
types = "span.types"
|
||||
}
|
||||
|
||||
return scraper_utils.scrape_tuples(
|
||||
function_parameters_node:outer_html(),
|
||||
line_node:outer_html(),
|
||||
{ query_selectors.name, query_selectors.types },
|
||||
function(nodes: { string : scan.HTMLNode | nil }): Function_Info.Parameter
|
||||
local name = extract_node_text(nodes[query_selectors.name] as scan.HTMLNode)
|
||||
local types = parse_parameter_types(extract_node_text(nodes[query_selectors.types] as scan.HTMLNode))
|
||||
|
||||
if types == List({ "table" }) then
|
||||
local record_name = utils.capitalize(name)
|
||||
current_record_parameter = record_name
|
||||
return {
|
||||
name = extract_node_text(nodes[query_selectors.name]),
|
||||
types = parse_parameter_types(extract_node_text(nodes[query_selectors.types])),
|
||||
name = name,
|
||||
types = List({ record_name }),
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
name = name,
|
||||
types = types,
|
||||
}
|
||||
end
|
||||
)[1]
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue