diff --git a/docs/gen_reference_doc.py b/docs/gen_reference_doc.py index 62cd11018..34aec8b15 100644 --- a/docs/gen_reference_doc.py +++ b/docs/gen_reference_doc.py @@ -68,6 +68,15 @@ def categorize_symbol(name, filename): return 'Core' +def first_item(itr): + for i in itr: + return i + return None + +def highlight_signature(s): + name = s.split('(')[0].split(' ')[-1].strip() + return s.replace(name, '' + name + '') + def html_sanitize(s): ret = '' for i in s: @@ -130,7 +139,7 @@ def parse_function(lno, lines, filename): lno = consume_block(lno - 1, lines) signature += ';' - return [{ 'file': filename[11:], 'overloads': [{'signature': signature, 'name': signature.split('(')[0].split(' ')[-1].strip()}]}, lno] + return [{ 'file': filename[11:], 'signatures': set([ signature ]), 'names': set([ signature.split('(')[0].split(' ')[-1].strip()])}, lno] if len(signature) > 0: print '\x1b[31mFAILED TO PARSE FUNCTION\x1b[0m %s\nline: %d\nfile: %s' % (signature, lno, filename) return [None, lno] @@ -214,7 +223,8 @@ def parse_class(lno, lines, filename): current_fun, lno = parse_function(lno - 1, lines, filename) if current_fun != None: if context == '' and blanks == 0 and len(funs): - funs[-1]['overloads'] += current_fun['overloads'] + funs[-1]['signatures'].update(current_fun['signatures']) + funs[-1]['names'].update(current_fun['names']) else: current_fun['desc'] = context funs.append(current_fun) @@ -223,8 +233,14 @@ def parse_class(lno, lines, filename): continue if looks_like_variable(l): - fields.append({ 'signature': l, 'name': l.split(' ')[-1].split(':')[0].split(';')[0], 'desc': context}) + n = l.split(' ')[-1].split(':')[0].split(';')[0] + if context == '' and blanks == 0 and len(fields): + fields[-1]['names'].append(n) + fields[-1]['signatures'].append(l) + else: + fields.append({'signatures': [l], 'names': [n], 'desc': context}) context = '' + blanks = 0 continue if l.startswith('enum '): @@ -398,7 +414,8 @@ for filename in files: current_fun, lno = parse_function(lno - 1, lines, filename) if current_fun != None: if context == '' and blanks == 0 and len(functions): - functions[-1]['overloads'] += current_fun['overloads'] + functions[-1]['signatures'].update(current_fun['signatures']) + functions[-1]['names'].update(current_fun['names']) else: current_fun['desc'] = context functions.append(current_fun) @@ -434,13 +451,14 @@ if dump: for c in classes: print '\x1b[4m%s\x1b[0m %s\n{' % (c['type'], c['name']) for f in c['fun']: - for o in f['overloads']: - print ' %s' % o['signature'].replace('\n', '\n ') + for s in f['signatures']: + print ' %s' % s.replace('\n', '\n ') if len(c['fun']) > 0 and len(c['fields']) > 0: print '' for f in c['fields']: - print ' %s' % f['signature'] + for s in f['signatures']: + print ' %s' % s if len(c['fields']) > 0 and len(c['enums']) > 0: print '' @@ -470,11 +488,11 @@ for c in classes: symbols[c['name']] = categories[cat]['filename'] + '#' + html_sanitize(c['name']) for f in functions: - cat = categorize_symbol(f['overloads'][0]['name'], f['file']) + cat = categorize_symbol(first_item(f['names']), f['file']) if not cat in categories: categories[cat] = { 'classes': [], 'functions': [], 'enums': [], 'filename': 'reference-%s.html' % cat.replace(' ', '_')} - for o in f['overloads']: - symbols[o['name']] = categories[cat]['filename'] + '#' + html_sanitize(o['name']) + for n in f['names']: + symbols[n] = categories[cat]['filename'] + '#' + html_sanitize(n) categories[cat]['functions'].append(f) for e in enums: @@ -486,8 +504,6 @@ for e in enums: out = open('reference.html', 'w+') out.write('''
- -