improve reference documentation generator to correctly recognize memb… (#716)

improve reference documentation generator to correctly recognize member constants defined over multiple lines
This commit is contained in:
Arvid Norberg 2016-05-08 20:41:55 -04:00
parent 5cd022cadb
commit debd02ff02
1 changed files with 49 additions and 5 deletions

View File

@ -186,16 +186,44 @@ def html_sanitize(s):
else: ret += i
return ret
def looks_like_variable(line):
def looks_like_namespace(line):
line = line.strip()
if line.startswith('namespace'): return True
return False
def looks_like_blank(line):
line = line.split('//')[0]
line = line.replace('{', '')
line = line.replace('}', '')
line = line.replace('[', '')
line = line.replace(']', '')
line = line.replace(';', '')
line = line.strip()
return len(line) == 0
def looks_like_variable(line):
line = line.split('//')[0]
line = line.strip()
if not line.endswith(';'): return False
if not ' ' in line and not '\t' in line: return False
if line.startswith('friend '): return False
if line.startswith('enum '): return False
if line.startswith(','): return False
if line.startswith(':'): return False
if line.startswith('typedef'): return False
return True
if ' = ' in line: return True
if line.endswith(';'): return True
return False
def looks_like_forward_decl(line):
line = line.split('//')[0]
line = line.strip()
if not line.endswith(';'): return False
if '{' in line: return False
if '}' in line: return False
if line.startswith('friend '): return True
if line.startswith('struct '): return True
if line.startswith('class '): return True
return False
def looks_like_function(line):
if line.startswith('friend'): return False
@ -348,8 +376,10 @@ def parse_class(lno, lines, filename):
continue
if looks_like_variable(l):
if verbose: print 'var %s' % l
if not is_visible(context):
continue
l = l.split('//')[0].strip()
n = l.split(' ')[-1].split(':')[0].split(';')[0]
if context == '' and blanks == 0 and len(fields):
fields[-1]['names'].append(n)
@ -364,6 +394,7 @@ def parse_class(lno, lines, filename):
continue
if l.startswith('enum '):
if verbose: print 'enum %s' % l
if not is_visible(context):
consume_block(lno - 1, lines)
else:
@ -378,7 +409,14 @@ def parse_class(lno, lines, filename):
continue
context = ''
if verbose: print '?? %s' % l
if verbose:
if looks_like_forward_decl(l) \
or looks_like_blank(l) \
or looks_like_namespace(l):
print '-- %s' % l
else:
print '?? %s' % l
if len(name) > 0:
print '\x1b[31mFAILED TO PARSE CLASS\x1b[0m %s\nfile: %s:%d' % (name, filename, lno)
@ -660,7 +698,13 @@ for filename in files:
continue
blanks += 1
if verbose: print '?? %s' % l
if verbose:
if looks_like_forward_decl(l) \
or looks_like_blank(l) \
or looks_like_namespace(l):
print '-- %s' % l
else:
print '?? %s' % l
context = ''
h.close()