Move plugins to Sol (#5622)
Co-authored-by: Nerixyz <nerixdev@outlook.de> Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -196,7 +196,7 @@ def write_func(path: Path, line: int, comments: list[str], out: TextIOWrapper):
|
||||
if not comments[0].startswith("@"):
|
||||
out.write(f"--- {comments[0]}\n---\n")
|
||||
comments = comments[1:]
|
||||
params = []
|
||||
params: list[str] = []
|
||||
for comment in comments[:-1]:
|
||||
if not comment.startswith("@lua"):
|
||||
panic(path, line, f"Invalid function specification - got '{comment}'")
|
||||
@@ -209,7 +209,7 @@ def write_func(path: Path, line: int, comments: list[str], out: TextIOWrapper):
|
||||
panic(path, line, f"Invalid function exposure - got '{comments[-1]}'")
|
||||
name = comments[-1].split(" ", 1)[1]
|
||||
printmsg(path, line, f"function {name}")
|
||||
lua_params = ", ".join(params)
|
||||
lua_params = ", ".join(p.removesuffix("?") for p in params)
|
||||
out.write(f"function {name}({lua_params}) end\n\n")
|
||||
|
||||
|
||||
@@ -242,13 +242,21 @@ def read_file(path: Path, out: TextIOWrapper):
|
||||
)
|
||||
name = header[0].split(" ", 1)[1]
|
||||
printmsg(path, reader.line_no(), f"enum {name}")
|
||||
out.write(f"---@alias {name} integer\n")
|
||||
variants = reader.read_enum_variants()
|
||||
|
||||
vtypes = []
|
||||
for variant in variants:
|
||||
vtype = f'{name}.{variant}'
|
||||
vtypes.append(vtype)
|
||||
out.write(f'---@alias {vtype} "{vtype}"\n')
|
||||
|
||||
out.write(f"---@alias {name} {'|'.join(vtypes)}\n")
|
||||
if header_comment:
|
||||
out.write(f"--- {header_comment}\n")
|
||||
out.write("---@type { ")
|
||||
out.write(
|
||||
", ".join(
|
||||
[f"{variant}: {name}" for variant in reader.read_enum_variants()]
|
||||
[f"{variant}: {typ}" for variant, typ in zip(variants,vtypes)]
|
||||
)
|
||||
)
|
||||
out.write(" }\n")
|
||||
|
||||
Reference in New Issue
Block a user