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