mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-01-22 07:32:07 -05:00
Autogen documentation for vec types (#609)
This commit is contained in:
parent
adcd730d5d
commit
85b51fd02a
3 changed files with 117 additions and 12 deletions
|
@ -144,9 +144,13 @@ override_allowed_structs = {
|
|||
sLuaManuallyDefinedStructs = [{
|
||||
'path': 'n/a',
|
||||
'structs': [
|
||||
'struct Vec3f { float x; float y; float z; }',
|
||||
'struct Vec3s { s16 x; s16 y; s16 z; }',
|
||||
'struct Color { u8 r; u8 g; u8 b; }'
|
||||
'struct %s { %s }' % (
|
||||
type_name,
|
||||
' '.join([
|
||||
'%s %s;' % (vec_type['field_c_type'], lua_field)
|
||||
for lua_field in vec_type['fields_mapping'].keys()
|
||||
])
|
||||
) for type_name, vec_type in VEC_TYPES.items()
|
||||
]
|
||||
}]
|
||||
|
||||
|
@ -254,7 +258,7 @@ def table_to_string(table):
|
|||
|
||||
############################################################################
|
||||
|
||||
def parse_struct(struct_str):
|
||||
def parse_struct(struct_str, sortFields = True):
|
||||
struct = {}
|
||||
identifier = struct_str.split(' ')[1]
|
||||
struct['identifier'] = identifier
|
||||
|
@ -291,15 +295,16 @@ def parse_struct(struct_str):
|
|||
if identifier == 'Object':
|
||||
struct['fields'] += extract_object_fields()
|
||||
|
||||
struct['fields'] = sorted(struct['fields'], key=lambda d: d['identifier'])
|
||||
if sortFields:
|
||||
struct['fields'] = sorted(struct['fields'], key=lambda d: d['identifier'])
|
||||
|
||||
return struct
|
||||
|
||||
def parse_structs(extracted):
|
||||
def parse_structs(extracted, sortFields = True):
|
||||
structs = []
|
||||
for e in extracted:
|
||||
for struct in e['structs']:
|
||||
parsed = parse_struct(struct)
|
||||
parsed = parse_struct(struct, sortFields)
|
||||
if e['path'] in override_allowed_structs:
|
||||
if parsed['identifier'] not in override_allowed_structs[e['path']]:
|
||||
continue
|
||||
|
@ -647,7 +652,7 @@ def doc_struct(struct):
|
|||
return s
|
||||
|
||||
def doc_structs(structs):
|
||||
structs.extend(parse_structs(sLuaManuallyDefinedStructs))
|
||||
structs.extend(parse_structs(sLuaManuallyDefinedStructs, False)) # Don't sort fields for vec types in the documentation
|
||||
structs = sorted(structs, key=lambda d: d['identifier'])
|
||||
|
||||
s = '## [:rewind: Lua Reference](lua.md)\n\n'
|
||||
|
|
|
@ -2344,20 +2344,54 @@
|
|||
--- @field public unk00 integer
|
||||
--- @field public unk02 integer
|
||||
|
||||
--- @class Vec2f
|
||||
--- @field public x number
|
||||
--- @field public y number
|
||||
|
||||
--- @class Vec3f
|
||||
--- @field public x number
|
||||
--- @field public y number
|
||||
--- @field public z number
|
||||
|
||||
--- @class Vec4f
|
||||
--- @field public x number
|
||||
--- @field public y number
|
||||
--- @field public z number
|
||||
--- @field public w number
|
||||
|
||||
--- @class Vec3s
|
||||
--- @field public x integer
|
||||
--- @field public y integer
|
||||
--- @field public z integer
|
||||
|
||||
--- @class Vec4s
|
||||
--- @field public x integer
|
||||
--- @field public y integer
|
||||
--- @field public z integer
|
||||
--- @field public w integer
|
||||
|
||||
--- @class Mat4
|
||||
--- @field public m00 number
|
||||
--- @field public m01 number
|
||||
--- @field public m02 number
|
||||
--- @field public m03 number
|
||||
--- @field public m10 number
|
||||
--- @field public m11 number
|
||||
--- @field public m12 number
|
||||
--- @field public m13 number
|
||||
--- @field public m20 number
|
||||
--- @field public m21 number
|
||||
--- @field public m22 number
|
||||
--- @field public m23 number
|
||||
--- @field public m30 number
|
||||
--- @field public m31 number
|
||||
--- @field public m32 number
|
||||
--- @field public m33 number
|
||||
|
||||
--- @class Color
|
||||
--- @field public b integer
|
||||
--- @field public g integer
|
||||
--- @field public r integer
|
||||
--- @field public g integer
|
||||
--- @field public b integer
|
||||
|
||||
--- @class Pointer_integer
|
||||
--- @class Pointer_Trajectory
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
- [MarioAnimation](#MarioAnimation)
|
||||
- [MarioBodyState](#MarioBodyState)
|
||||
- [MarioState](#MarioState)
|
||||
- [Mat4](#Mat4)
|
||||
- [Mod](#Mod)
|
||||
- [ModAudio](#ModAudio)
|
||||
- [ModAudioSampleCopies](#ModAudioSampleCopies)
|
||||
|
@ -103,8 +104,11 @@
|
|||
- [TransitionInfo](#TransitionInfo)
|
||||
- [UnusedArea28](#UnusedArea28)
|
||||
- [VblankHandler](#VblankHandler)
|
||||
- [Vec2f](#Vec2f)
|
||||
- [Vec3f](#Vec3f)
|
||||
- [Vec3s](#Vec3s)
|
||||
- [Vec4f](#Vec4f)
|
||||
- [Vec4s](#Vec4s)
|
||||
- [WallCollisionData](#WallCollisionData)
|
||||
- [WarpNode](#WarpNode)
|
||||
- [WarpTransition](#WarpTransition)
|
||||
|
@ -759,9 +763,9 @@
|
|||
|
||||
| Field | Type | Access |
|
||||
| ----- | ---- | ------ |
|
||||
| b | `integer` | |
|
||||
| g | `integer` | |
|
||||
| r | `integer` | |
|
||||
| g | `integer` | |
|
||||
| b | `integer` | |
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
|
@ -1793,6 +1797,31 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [Mat4](#Mat4)
|
||||
|
||||
| Field | Type | Access |
|
||||
| ----- | ---- | ------ |
|
||||
| m00 | `number` | |
|
||||
| m01 | `number` | |
|
||||
| m02 | `number` | |
|
||||
| m03 | `number` | |
|
||||
| m10 | `number` | |
|
||||
| m11 | `number` | |
|
||||
| m12 | `number` | |
|
||||
| m13 | `number` | |
|
||||
| m20 | `number` | |
|
||||
| m21 | `number` | |
|
||||
| m22 | `number` | |
|
||||
| m23 | `number` | |
|
||||
| m30 | `number` | |
|
||||
| m31 | `number` | |
|
||||
| m32 | `number` | |
|
||||
| m33 | `number` | |
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [Mod](#Mod)
|
||||
|
||||
| Field | Type | Access |
|
||||
|
@ -3088,6 +3117,17 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [Vec2f](#Vec2f)
|
||||
|
||||
| Field | Type | Access |
|
||||
| ----- | ---- | ------ |
|
||||
| x | `number` | |
|
||||
| y | `number` | |
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [Vec3f](#Vec3f)
|
||||
|
||||
| Field | Type | Access |
|
||||
|
@ -3112,6 +3152,32 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [Vec4f](#Vec4f)
|
||||
|
||||
| Field | Type | Access |
|
||||
| ----- | ---- | ------ |
|
||||
| x | `number` | |
|
||||
| y | `number` | |
|
||||
| z | `number` | |
|
||||
| w | `number` | |
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [Vec4s](#Vec4s)
|
||||
|
||||
| Field | Type | Access |
|
||||
| ----- | ---- | ------ |
|
||||
| x | `integer` | |
|
||||
| y | `integer` | |
|
||||
| z | `integer` | |
|
||||
| w | `integer` | |
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [WallCollisionData](#WallCollisionData)
|
||||
|
||||
| Field | Type | Access |
|
||||
|
|
Loading…
Reference in a new issue