Last active
August 19, 2019 15:14
-
-
Save Anaminus/725bb048db305a6307d12cab97d7aa18 to your computer and use it in GitHub Desktop.
Useful jq filters for the Roblox API dump.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Select all members, setting Class field to name of members' class. | |
| def SelectMembers: [.Classes[] | .Name as $class | .Members[] | .Class=$class]; | |
| # Display name of resulting member. | |
| def MemberName(m): m.Class + "." + m.Name; | |
| # Get names of all members. | |
| def AllMemberNames: SelectMembers | map(MemberName(.)); | |
| # Select all members containing type t. | |
| def MembersWithType(t): [SelectMembers[] | select( | |
| .ValueType.Name == t or | |
| .ReturnType.Name == t or | |
| has("Parameters") and .Parameters[].Type.Name == t | |
| )]; | |
| # Select all members containing string-like types. | |
| def MembersWithStringTypes: [ | |
| MembersWithType("string") + | |
| MembersWithType("BinaryString") + | |
| MembersWithType("ProtectedString") | | |
| .[] | MemberName(.) | |
| ] | unique; | |
| # Select properties with ValueType of type t. | |
| def ValueWithType(t): [ | |
| SelectMembers[] | |
| | select(.ValueType.Name == t) | |
| | {"Type": .MemberType, "Class": .Class, "Name": .Name} | |
| ]; | |
| # Select functions and callbacks with ReturnType of type t. | |
| def ReturnWithType(t): [ | |
| SelectMembers[] | |
| | select(.ReturnType.Name == t) | |
| | {"Type": .MemberType, "Class": .Class, "Name": .Name} | |
| ]; | |
| # Select functions, callbacks, and events with parameter of type t. | |
| def ParamWithType(t): [ | |
| SelectMembers[] | |
| | .Param = (.Parameters[]? | select(.Type.Name == t)).Name | |
| | {"Type": .MemberType, "Class": .Class, "Name": .Name, "Param": .Param} | |
| ]; | |
| # Format results of WithType functions (use -r). | |
| def FormatWithTypes: [ .[] | | |
| .Type | |
| + " " + .Class | |
| + "." + .Name | |
| + (if has("Param") then (" (" + .Param + ")") else "" end) | |
| ] | unique; | |
| # Print members that have the string type. | |
| def PrintMembersWithType(t): | |
| ValueWithType(t) | |
| + ReturnWithType(t) | |
| + ParamWithType(t) | |
| | FormatWithTypes[]; | |
| PrintMembersWithType("string") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment