Merge pull request #14914 from fodinabor/fix13254
Enum members now also link to the corresponding class in the webdocs
This commit is contained in:
commit
913777b773
1 changed files with 43 additions and 2 deletions
|
@ -276,6 +276,15 @@ def make_type(t):
|
||||||
return ':ref:`' + t + '<class_' + t.lower() + '>`'
|
return ':ref:`' + t + '<class_' + t.lower() + '>`'
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
def make_enum(t):
|
||||||
|
global class_names
|
||||||
|
p = t.find(".")
|
||||||
|
if p >= 0:
|
||||||
|
c = t[0:p]
|
||||||
|
e = t[p+1:]
|
||||||
|
if c in class_names:
|
||||||
|
return ':ref:`' + e + '<enum_' + c.lower() + '_' + e.lower() + '>`'
|
||||||
|
return t
|
||||||
|
|
||||||
def make_method(
|
def make_method(
|
||||||
f,
|
f,
|
||||||
|
@ -470,6 +479,9 @@ def make_rst_class(node):
|
||||||
# Leading two spaces necessary to prevent breaking the <ul>
|
# Leading two spaces necessary to prevent breaking the <ul>
|
||||||
f.write(" .. _class_" + name + "_" + c.attrib['name'] + ":\n\n")
|
f.write(" .. _class_" + name + "_" + c.attrib['name'] + ":\n\n")
|
||||||
s = '- '
|
s = '- '
|
||||||
|
if 'enum' in c.attrib:
|
||||||
|
s += make_enum(c.attrib['enum']) + ' '
|
||||||
|
else:
|
||||||
s += make_type(c.attrib['type']) + ' '
|
s += make_type(c.attrib['type']) + ' '
|
||||||
s += '**' + c.attrib['name'] + '**'
|
s += '**' + c.attrib['name'] + '**'
|
||||||
if c.text.strip() != '':
|
if c.text.strip() != '':
|
||||||
|
@ -478,9 +490,20 @@ def make_rst_class(node):
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
|
|
||||||
constants = node.find('constants')
|
constants = node.find('constants')
|
||||||
|
consts = []
|
||||||
|
enum_names = set()
|
||||||
|
enums = []
|
||||||
if constants != None and len(list(constants)) > 0:
|
if constants != None and len(list(constants)) > 0:
|
||||||
f.write(make_heading('Numeric Constants', '-'))
|
|
||||||
for c in list(constants):
|
for c in list(constants):
|
||||||
|
if 'enum' in c.attrib:
|
||||||
|
enum_names.add(c.attrib['enum'])
|
||||||
|
enums.append(c)
|
||||||
|
else:
|
||||||
|
consts.append(c)
|
||||||
|
|
||||||
|
if len(consts) > 0:
|
||||||
|
f.write(make_heading('Numeric Constants', '-'))
|
||||||
|
for c in list(consts):
|
||||||
s = '- '
|
s = '- '
|
||||||
s += '**' + c.attrib['name'] + '**'
|
s += '**' + c.attrib['name'] + '**'
|
||||||
if 'value' in c.attrib:
|
if 'value' in c.attrib:
|
||||||
|
@ -490,6 +513,24 @@ def make_rst_class(node):
|
||||||
f.write(s + '\n')
|
f.write(s + '\n')
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
|
|
||||||
|
if len(enum_names) > 0:
|
||||||
|
f.write(make_heading('Enums', '-'))
|
||||||
|
for e in enum_names:
|
||||||
|
f.write(" .. _enum_" + name + "_" + e + ":\n\n")
|
||||||
|
f.write("enum **" + e + "**\n\n")
|
||||||
|
for c in enums:
|
||||||
|
if c.attrib['enum'] != e:
|
||||||
|
continue
|
||||||
|
s = '- '
|
||||||
|
s += '**' + c.attrib['name'] + '**'
|
||||||
|
if 'value' in c.attrib:
|
||||||
|
s += ' = **' + c.attrib['value'] + '**'
|
||||||
|
if c.text.strip() != '':
|
||||||
|
s += ' --- ' + rstize_text(c.text.strip(), name)
|
||||||
|
f.write(s + '\n')
|
||||||
|
f.write('\n')
|
||||||
|
f.write('\n')
|
||||||
|
|
||||||
descr = node.find('description')
|
descr = node.find('description')
|
||||||
if descr != None and descr.text.strip() != '':
|
if descr != None and descr.text.strip() != '':
|
||||||
f.write(make_heading('Description', '-'))
|
f.write(make_heading('Description', '-'))
|
||||||
|
|
Loading…
Reference in a new issue