WIP: awesomerc.tl
should work #85
|
@ -181,7 +181,13 @@ describe("Teal type definition Printer", function()
|
|||
token = "enum",
|
||||
},
|
||||
{
|
||||
parameters = {},
|
||||
parameters = {
|
||||
{
|
||||
types = { "Timer" },
|
||||
name = "self",
|
||||
token = "variable",
|
||||
},
|
||||
},
|
||||
return_types = {},
|
||||
name = "timer",
|
||||
metamethod = "__call",
|
||||
|
@ -200,7 +206,7 @@ describe("Teal type definition Printer", function()
|
|||
local record Timer
|
||||
enum Signal
|
||||
end
|
||||
metamethod __call: function()
|
||||
metamethod __call: function(self: Timer)
|
||||
end
|
||||
|
||||
return Timer
|
||||
|
|
|
@ -905,7 +905,13 @@ describe("Scrap documentation", function()
|
|||
token = "enum",
|
||||
},
|
||||
{
|
||||
parameters = {},
|
||||
parameters = {
|
||||
{
|
||||
types = { "Timer" },
|
||||
name = "self",
|
||||
token = "variable",
|
||||
},
|
||||
},
|
||||
return_types = {},
|
||||
name = "timer",
|
||||
metamethod = "__call",
|
||||
|
|
|
@ -221,6 +221,17 @@ local function extract_section_signal(dl: string): { string }
|
|||
return scraper_utils.scrape(dl, selector, extract_node_text)
|
||||
end
|
||||
|
||||
local function add_self_parameter(function_node: Node, record_name: string)
|
||||
local self_parameter = ast.create_node("variable", "self")
|
||||
self_parameter.types = { record_name }
|
||||
table.insert(function_node.parameters, 1, self_parameter)
|
||||
end
|
||||
|
||||
local function transform_to_call_metamethod(function_node: Node)
|
||||
function_node.token = "metamethod"
|
||||
function_node.metamethod = "__call"
|
||||
end
|
||||
|
||||
local enum Section
|
||||
"Constructors"
|
||||
"Static module functions"
|
||||
|
@ -238,8 +249,8 @@ local section_scrapers <total>: { Section : function(html: string, record_name:
|
|||
local constructors <const> = extract_section_functions(html)
|
||||
for _, constructor in ipairs(constructors) do
|
||||
if constructor.token == "function" and constructor.name == utils.lowercase(record_name) then
|
||||
constructor.token = "metamethod"
|
||||
constructor.metamethod = "__call"
|
||||
add_self_parameter(constructor, record_name)
|
||||
transform_to_call_metamethod(constructor)
|
||||
end
|
||||
end
|
||||
return constructors, {}, {}
|
||||
|
@ -256,9 +267,7 @@ local section_scrapers <total>: { Section : function(html: string, record_name:
|
|||
local methods <const> = extract_section_functions(html)
|
||||
for _, method in ipairs(methods) do
|
||||
if method.token == "function" then
|
||||
local self_parameter = ast.create_node("variable", "self")
|
||||
self_parameter.types = { record_name }
|
||||
table.insert(method.parameters, 1, self_parameter)
|
||||
add_self_parameter(method, record_name)
|
||||
end
|
||||
end
|
||||
return methods, {}, {}
|
||||
|
|
Loading…
Reference in New Issue