Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
Add code completion for :Configure() method
Browse files Browse the repository at this point in the history
  • Loading branch information
lrockreal committed Nov 26, 2023
1 parent f71f56a commit 1231165
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions scripts/generatePartDefinitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
import sys
import json

READONLY_PROPERTIES = [
"ClassName",
"Position",
"CFrame",
"GUID"
]

def _parse_list_dict(listdict: list) -> list[tuple]:
data = []
for entry in listdict:
Expand Down Expand Up @@ -44,11 +51,19 @@ def _generate_part(self, part: dict):
# Methods
for method_name, method in part.get("methods", {}).items():
returns = method.get("returns", "()")
arguments: list = method.get("arguments", [])
arguments_code = []
arguments_code.append(f"self: {part['_name']}")
for arg_name, arg_type in _parse_list_dict(arguments):
arguments_code.append(f"{arg_name}: {arg_type}")
if method_name == "Configure":
# Build Configure method
configure_code = []
for property_name, property_value in part.get("properties", {}).items():
if property_name in READONLY_PROPERTIES:
continue
configure_code.append(f"{property_name}: {property_value}?")
arguments_code.append(f"properties: {{{', '.join(configure_code)}}}")
else:
for arg_name, arg_type in _parse_list_dict(method.get("arguments", [])):
arguments_code.append(f"{arg_name}: {arg_type}")
code.append(f"{method_name}: ({', '.join(arguments_code)}) -> {returns}")
# Properties
for property_name, property_value in part.get("properties", {}).items():
Expand Down

0 comments on commit 1231165

Please sign in to comment.