mirror of
https://github.com/godotengine/godot.git
synced 2025-02-02 12:11:35 +00:00
Makes doc methods display enums.
This commit is contained in:
parent
81b1d3c846
commit
331b0e8526
37
doc/tools/makerst.py
Normal file → Executable file
37
doc/tools/makerst.py
Normal file → Executable file
@ -106,6 +106,7 @@ def make_class_list(class_list, columns):
|
|||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
def rstize_text(text, cclass):
|
def rstize_text(text, cclass):
|
||||||
# Linebreak + tabs in the XML should become two line breaks unless in a "codeblock"
|
# Linebreak + tabs in the XML should become two line breaks unless in a "codeblock"
|
||||||
pos = 0
|
pos = 0
|
||||||
@ -156,7 +157,7 @@ def rstize_text(text, cclass):
|
|||||||
|
|
||||||
# Escape * character to avoid interpreting it as emphasis
|
# Escape * character to avoid interpreting it as emphasis
|
||||||
pos = 0
|
pos = 0
|
||||||
next_brac_pos = text.find('[');
|
next_brac_pos = text.find('[')
|
||||||
while True:
|
while True:
|
||||||
pos = text.find('*', pos, next_brac_pos)
|
pos = text.find('*', pos, next_brac_pos)
|
||||||
if pos == -1:
|
if pos == -1:
|
||||||
@ -258,15 +259,17 @@ def rstize_text(text, cclass):
|
|||||||
elif cmd == 'code':
|
elif cmd == 'code':
|
||||||
tag_text = '``'
|
tag_text = '``'
|
||||||
inside_code = True
|
inside_code = True
|
||||||
|
elif cmd.startswith('enum '):
|
||||||
|
tag_text = make_enum(cmd[5:])
|
||||||
else:
|
else:
|
||||||
tag_text = make_type(tag_text)
|
tag_text = make_type(tag_text)
|
||||||
escape_post = True
|
escape_post = True
|
||||||
|
|
||||||
# Properly escape things like `[Node]s`
|
# Properly escape things like `[Node]s`
|
||||||
if escape_post and post_text and post_text[0].isalnum(): # not punctuation, escape
|
if escape_post and post_text and post_text[0].isalnum(): # not punctuation, escape
|
||||||
post_text = '\ ' + post_text
|
post_text = '\ ' + post_text
|
||||||
|
|
||||||
next_brac_pos = post_text.find('[',0)
|
next_brac_pos = post_text.find('[', 0)
|
||||||
iter_pos = 0
|
iter_pos = 0
|
||||||
while not inside_code:
|
while not inside_code:
|
||||||
iter_pos = post_text.find('*', iter_pos, next_brac_pos)
|
iter_pos = post_text.find('*', iter_pos, next_brac_pos)
|
||||||
@ -286,7 +289,6 @@ def rstize_text(text, cclass):
|
|||||||
else:
|
else:
|
||||||
iter_pos += 1
|
iter_pos += 1
|
||||||
|
|
||||||
|
|
||||||
text = pre_text + tag_text + post_text
|
text = pre_text + tag_text + post_text
|
||||||
pos = len(pre_text) + len(tag_text)
|
pos = len(pre_text) + len(tag_text)
|
||||||
|
|
||||||
@ -299,16 +301,27 @@ def make_type(t):
|
|||||||
return ':ref:`' + t + '<class_' + t.lower() + '>`'
|
return ':ref:`' + t + '<class_' + t.lower() + '>`'
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
|
||||||
def make_enum(t):
|
def make_enum(t):
|
||||||
global class_names
|
global class_names
|
||||||
p = t.find(".")
|
p = t.find(".")
|
||||||
|
# Global enums such as Error are relative to @GlobalScope.
|
||||||
if p >= 0:
|
if p >= 0:
|
||||||
c = t[0:p]
|
c = t[0:p]
|
||||||
e = t[p+1:]
|
e = t[p + 1:]
|
||||||
if c in class_names:
|
# Variant enums live in GlobalScope but still use periods.
|
||||||
return ':ref:`' + e + '<enum_' + c.lower() + '_' + e.lower() + '>`'
|
if c == "Variant":
|
||||||
|
c = "@GlobalScope"
|
||||||
|
e = "Variant." + e
|
||||||
|
else:
|
||||||
|
# Things in GlobalScope don't have a period.
|
||||||
|
c = "@GlobalScope"
|
||||||
|
e = t
|
||||||
|
if c in class_names:
|
||||||
|
return ':ref:`' + e + '<enum_' + c.lower() + '_' + e.lower() + '>`'
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
|
||||||
def make_method(
|
def make_method(
|
||||||
f,
|
f,
|
||||||
name,
|
name,
|
||||||
@ -340,7 +353,10 @@ def make_method(
|
|||||||
|
|
||||||
if not event:
|
if not event:
|
||||||
if -1 in mdata['argidx']:
|
if -1 in mdata['argidx']:
|
||||||
t += make_type(mdata[-1].attrib['type'])
|
if 'enum' in mdata[-1].attrib:
|
||||||
|
t += make_enum(mdata[-1].attrib['enum'])
|
||||||
|
else:
|
||||||
|
t += make_type(mdata[-1].attrib['type'])
|
||||||
else:
|
else:
|
||||||
t += 'void'
|
t += 'void'
|
||||||
t += ' '
|
t += ' '
|
||||||
@ -362,7 +378,10 @@ def make_method(
|
|||||||
else:
|
else:
|
||||||
s += ' '
|
s += ' '
|
||||||
|
|
||||||
s += make_type(arg.attrib['type'])
|
if 'enum' in arg.attrib:
|
||||||
|
s += make_enum(arg.attrib['enum'])
|
||||||
|
else:
|
||||||
|
s += make_type(arg.attrib['type'])
|
||||||
if 'name' in arg.attrib:
|
if 'name' in arg.attrib:
|
||||||
s += ' ' + arg.attrib['name']
|
s += ' ' + arg.attrib['name']
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user