diff --git a/src/awesomewm.d.tl/scraper/module_doc.tl b/src/awesomewm.d.tl/scraper/module_doc.tl index e92e23c..e139869 100644 --- a/src/awesomewm.d.tl/scraper/module_doc.tl +++ b/src/awesomewm.d.tl/scraper/module_doc.tl @@ -27,19 +27,44 @@ 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 query_selectors = { - name = "span.parameter", - types = "span.types" - } + local current_record_parameter: string = nil - return scraper_utils.scrape_tuples( + return scraper_utils.scrape( function_parameters_node:outer_html(), - { query_selectors.name, query_selectors.types }, - function(nodes: { string : scan.HTMLNode | nil }): Function_Info.Parameter - return { - name = extract_node_text(nodes[query_selectors.name]), - types = parse_parameter_types(extract_node_text(nodes[query_selectors.types])), + "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( + 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 = name, + types = List({ record_name }), + } + end + + return { + name = name, + types = types, + } + end + )[1] end ) end