mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-12-22 16:30:23 +00:00
Update Lua documentation autogeneration
This commit is contained in:
parent
e740529776
commit
e4f72105a3
6 changed files with 2429 additions and 2425 deletions
|
@ -115,38 +115,42 @@ def translate_type_to_lot(ptype):
|
|||
|
||||
def translate_type_to_lua(ptype):
|
||||
if ptype.startswith('struct '):
|
||||
return ptype.split(' ')[1].replace('*', ''), True
|
||||
ptype = ptype.split(' ')[1].replace('*', '')
|
||||
return ptype, 'structs.md#%s' % ptype
|
||||
|
||||
if ptype == 'const char*':
|
||||
return 'string', False
|
||||
return '`string`', None
|
||||
|
||||
if ptype == 'char*' or ('char' in ptype and '[' in ptype):
|
||||
return 'string', False
|
||||
return '`string`', None
|
||||
|
||||
if 'Vec3' in ptype:
|
||||
return ptype, True
|
||||
return ptype, 'structs.md#%s' % ptype
|
||||
|
||||
if ptype.startswith('enum '):
|
||||
return 'integer', False
|
||||
return ptype, 'constants.md#%s' % ptype.replace(' ', '-')
|
||||
|
||||
if ptype in usf_types:
|
||||
if ptype.startswith('f'):
|
||||
return 'number', False
|
||||
return '`number`', None
|
||||
else:
|
||||
return 'integer', False
|
||||
return '`integer`', None
|
||||
|
||||
if 'void' == ptype:
|
||||
return None, False
|
||||
return None, None
|
||||
|
||||
if ptype == 'LuaFunction':
|
||||
return 'LuaFunction()', False
|
||||
return '`Lua Function` ()', None
|
||||
|
||||
if ptype.count('*') == 1 and '???' not in translate_type_to_lvt(ptype):
|
||||
ptype = ptype.replace('const', '').replace('*', '').strip()
|
||||
s = 'Pointer <%s>' % translate_type_to_lua(ptype)[0]
|
||||
return s, False
|
||||
s = '`Pointer` <%s>' % translate_type_to_lua(ptype)[0]
|
||||
return s, None
|
||||
|
||||
return ptype, False
|
||||
if not ptype.startswith('`'):
|
||||
ptype = '`' + ptype + '`'
|
||||
|
||||
return ptype, None
|
||||
|
||||
def gen_comment_header(f):
|
||||
comment_h = "// " + f + " //"
|
||||
|
|
|
@ -432,7 +432,7 @@ def doc_lua_func_param(param):
|
|||
lfp_type, lfp_link = translate_type_to_lua(lfp_type)
|
||||
|
||||
if lfp_link:
|
||||
s += '[%s](structs.md#%s)' % (lfp_type, lfp_type)
|
||||
s += '[%s](%s)' % (lfp_type, lfp_link)
|
||||
else:
|
||||
s += lfp_type
|
||||
|
||||
|
@ -469,7 +469,7 @@ def doc_function(function):
|
|||
ptype = doc_lua_func_param(param)
|
||||
|
||||
if plink:
|
||||
s += '| %s | [%s](structs.md#%s) |\n' % (pid, ptype, ptype)
|
||||
s += '| %s | [%s](%s) |\n' % (pid, ptype, plink)
|
||||
continue
|
||||
|
||||
s += '| %s | %s |\n' % (pid, ptype)
|
||||
|
@ -480,7 +480,7 @@ def doc_function(function):
|
|||
s += '\n### Returns\n'
|
||||
if rtype != None:
|
||||
if rlink:
|
||||
s += '[%s](structs.md#%s)\n' % (rtype, rtype)
|
||||
s += '[%s](%s)\n' % (rtype, rlink)
|
||||
else:
|
||||
s += '- %s\n' % rtype
|
||||
else:
|
||||
|
|
|
@ -315,15 +315,15 @@ def doc_struct_field(struct, field):
|
|||
if '???' in lvt or '???' in lot:
|
||||
return ''
|
||||
|
||||
ftype, do_link = translate_type_to_lua(ftype)
|
||||
ftype, flink = translate_type_to_lua(ftype)
|
||||
|
||||
restrictions = ('', 'read-only')[fimmutable == 'true']
|
||||
|
||||
global total_fields
|
||||
total_fields += 1
|
||||
|
||||
if do_link:
|
||||
return '| %s | [%s](#%s) | %s |\n' % (fid, ftype, ftype, restrictions)
|
||||
if flink:
|
||||
return '| %s | [%s](%s) | %s |\n' % (fid, ftype, flink, restrictions)
|
||||
|
||||
return '| %s | %s | %s |\n' % (fid, ftype, restrictions)
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -21,8 +21,8 @@ Hooks are a way for SM64 to trigger Lua code, whereas the functions listed in [f
|
|||
| ----- | ---- | ----- |
|
||||
| behaviorId | [enum BehaviorId](constants.md#enum-BehaviorId) | Set to `0` to create a new behavior |
|
||||
| objectList | [enum ObjectList](constants.md#enum-ObjectList) | |
|
||||
| initFunction([Object](structs.md#Object) obj) | Lua Function | Runs once per object |
|
||||
| loopFunction([Object](structs.md#Object) obj) | Lua Function | Runs once per frame per object |
|
||||
| initFunction | `Lua Function` ([Object](structs.md#Object) obj) | Runs once per object |
|
||||
| loopFunction | `Lua Function` ([Object](structs.md#Object) obj) | Runs once per frame per object |
|
||||
|
||||
### Returns
|
||||
- [enum BehaviorId](constants.md#enum-BehaviorId)
|
||||
|
@ -53,9 +53,9 @@ id_bhvExample = hook_behavior(0, OBJ_LIST_DEFAULT, bhv_example_init, bhv_example
|
|||
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| command | string |
|
||||
| description | string |
|
||||
| func(`string` message) -> `bool` | Lua Function |
|
||||
| command | `string` |
|
||||
| description | `string` |
|
||||
| func | `Lua Function` (`string` message) -> `bool` |
|
||||
|
||||
### Lua Example
|
||||
|
||||
|
@ -101,7 +101,7 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh
|
|||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| hook_event_type | [HookEventType](#Hook-Event-Types) |
|
||||
| func(`...`) | Lua Function |
|
||||
| func | `Lua Function` (`...`) |
|
||||
|
||||
### Lua Example
|
||||
|
||||
|
@ -125,8 +125,8 @@ hook_event(HOOK_MARIO_UPDATE, mario_update)
|
|||
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| action_id | integer |
|
||||
| func([MarioState](structs.md#MarioState) m) | Lua Function |
|
||||
| action_id | `integer` |
|
||||
| func | `Lua Function` ([MarioState](structs.md#MarioState) m) |
|
||||
| interaction_type | [enum InteractionFlag](constants.md#enum-InteractionFlag) <optional> |
|
||||
|
||||
### Lua Example
|
||||
|
@ -204,10 +204,10 @@ hook_mario_action(ACT_WALL_SLIDE, act_wall_slide)
|
|||
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| syncTable | SyncTable |
|
||||
| field | value |
|
||||
| tag | value |
|
||||
| func(`value` tag, `value` oldValue, `value` newValue) | Lua Function |
|
||||
| syncTable | `SyncTable` |
|
||||
| field | `value` |
|
||||
| tag | `value` |
|
||||
| func | `Lua Function` (`value` tag, `value` oldValue, `value` newValue) |
|
||||
|
||||
### Lua Example
|
||||
|
||||
|
|
2602
docs/lua/structs.md
2602
docs/lua/structs.md
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue