fix(luals-meta): Use opaque enum values and correct HTTP types (#5682)
This commit is contained in:
Regular → Executable
+9
-14
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
This script generates docs/plugin-meta.lua. It accepts no arguments
|
||||
|
||||
@@ -242,25 +243,19 @@ def read_file(path: Path, out: TextIOWrapper):
|
||||
)
|
||||
name = header[0].split(" ", 1)[1]
|
||||
printmsg(path, reader.line_no(), f"enum {name}")
|
||||
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(f"---@enum {name}\n")
|
||||
out.write(f"{name} = {{\n")
|
||||
out.write(
|
||||
", ".join(
|
||||
[f"{variant}: {typ}" for variant, typ in zip(variants,vtypes)]
|
||||
"\n".join(
|
||||
[
|
||||
f" {variant} = {{}}, ---@type {name}.{variant}"
|
||||
for variant in reader.read_enum_variants()
|
||||
]
|
||||
)
|
||||
)
|
||||
out.write(" }\n")
|
||||
out.write(f"{name} = {{}}\n\n")
|
||||
out.write("\n}\n\n")
|
||||
continue
|
||||
|
||||
# class
|
||||
|
||||
Reference in New Issue
Block a user