fix(entities): implement entities
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/pr/build Pipeline was successful Details

This commit is contained in:
Aire-One 2022-10-04 20:47:46 +02:00
parent 6c5090d6fe
commit bebe4a6901
5 changed files with 40 additions and 13 deletions

View File

@ -8,14 +8,22 @@ end
local record Function_Info
metamethod __call: function(Function_Info): Function_Info
Function_Info: Function_Info
name: string
parameters: List<Parameter>
return_types: List<string>
append_parameter: function(self: Function_Info, parameter: string)
append_parameter: function(self: Function_Info, name: string, type: string)
append_return_type: function(self: Function_Info, return_type: string)
end
local __Function_Info: metatable<Function_Info> = {
__call = function(self: Function_Info): Function_Info
return self
end,
}
function Function_Info:append_parameter(name: string, type: string)
self.parameters:append {
name = name,
@ -27,4 +35,4 @@ function Function_Info:append_return_type(return_type: string)
self.return_types:append(return_type)
end
return Function_Info
return setmetatable({} as Function_Info, __Function_Info)

View File

@ -4,9 +4,18 @@ local List = require "pl.List"
local record Module_Doc
metamethod __call: function(Module_Doc): Module_Doc
constructors: List<Function_Info>
methods: List<Function_Info>
static_functions: List<Function_Info>
Module_Doc: Module_Doc
constructors: List<Function_Info.Function_Info>
methods: List<Function_Info.Function_Info>
static_functions: List<Function_Info.Function_Info>
end
return Module_Doc
local __Module_Doc: metatable<Module_Doc> = {
__call = function(self: Module_Doc): Module_Doc
return self
end,
}
return setmetatable({} as Module_Doc, __Module_Doc)

View File

@ -1,8 +1,18 @@
local record Module_Info
metamethod __call: function(Module_Info, name: string, uri: string): Module_Info
metamethod __call: function(self: Module_Info, name: string, uri: string): Module_Info
Module_Info: Module_Info
name: string
uri: string
end
return Module_Info
local __Module_Info: metatable<Module_Info> = {
__call = function(self: Module_Info, name: string, uri: string): Module_Info
self.name = name
self.uri = uri
return self
end,
}
return setmetatable({} as Module_Info, __Module_Info)

View File

@ -22,7 +22,7 @@ local function extract_function_return_types(function_return_types_node: scan.HT
end)
end
local function extract_section_functions(dl: string): { Function_Info }
local function extract_section_functions(dl: string): { Function_Info.Function_Info }
local query_selectors = {
function_name = "dt a",
function_return_type = "dd ol",
@ -31,7 +31,7 @@ local function extract_section_functions(dl: string): { Function_Info }
return scraper_utils.scrape_tuples(
dl,
{ query_selectors.function_name, query_selectors.function_return_type },
function(nodes: { string : scan.HTMLNode | nil }): Function_Info
function(nodes: { string : scan.HTMLNode | nil }): Function_Info.Function_Info
local function_info = Function_Info()
function_info.name =
@ -49,7 +49,7 @@ end
local module = {}
function module.get_doc_from_page(html: string): Module_Doc
function module.get_doc_from_page(html: string): Module_Doc.Module_Doc
local nodes = scraper_utils.extract_nodes(html, {
"h2.section-header",
"dl.function",

View File

@ -7,7 +7,7 @@ local module = {}
local MODULE_A_TAG_QUERY_SELECTOR = "div#navigation ul li a"
local function extract_module_info(node: scan.HTMLNode): Module_Info
local function extract_module_info(node: scan.HTMLNode): Module_Info.Module_Info
local name = utils.sanitize_string(node:inner_text())
local uri = node.attr.href as string
@ -18,7 +18,7 @@ local function extract_module_info(node: scan.HTMLNode): Module_Info
return Module_Info(name, uri)
end
function module.get_modules_from_index(html: string): { Module_Info }
function module.get_modules_from_index(html: string): { Module_Info.Module_Info }
return scraper_utils.scrape(
html,
MODULE_A_TAG_QUERY_SELECTOR,