diff --git a/src/awesomewm.d.tl/scraper/module_doc.tl b/src/awesomewm.d.tl/scraper/module_doc.tl index fc015b7..33d14ca 100644 --- a/src/awesomewm.d.tl/scraper/module_doc.tl +++ b/src/awesomewm.d.tl/scraper/module_doc.tl @@ -1,6 +1,7 @@ local Function_Info = require "entity.Function_Info" local List = require "pl.List" local logger = require "logger" +local Map = require "pl.Map" local Module_Doc = require "entity.Module_Doc" local scan = require "web_sanitize.query.scan_html" local scraper_utils = require "scraper.utils" @@ -32,47 +33,65 @@ local function extract_item_name(item_name_node: scan.HTMLNode): string return item_name_node and ((item_name_node.attr.name as string):gsub("^.*[%.:]", "")) end +local function extract_function_parameter_Parameters(tr_node: scan.HTMLNode): { Function_Info.Parameter } + local query_selectors = { + name = "span.parameter", + types = "span.types" + } + + return scraper_utils.scrape_tuples( + tr_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] as scan.HTMLNode), + types = parse_parameter_types(extract_node_text(nodes[query_selectors.types] as scan.HTMLNode)), + } + end) +end + local function extract_function_parameters(function_parameters_node: scan.HTMLNode): { Function_Info.Parameter } - local current_record_parameter: string = nil + local current_record_parameter: Type_Info.Type_Info | nil = 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") + local parameters = extract_function_parameter_Parameters(line_node) + if #parameters == 0 then + return nil + elseif #parameters ~= 1 then + log:error(logger.message_with_metadata("Expected 1 parameter by