- ')
self.menu_began = True
self.write('
- ') if link: self.write('') # Write the real menu entry text self.write(name) if link: self.write('') self.write(' ') def end_menu(self): """Ends an opened menu""" if not self.menu_began: raise RuntimeError('No menu had been started in the first place.') self.write('
---') self.write('functions' if tlobject.is_function else 'types') self.write('---\n') # Write the function or type and its ID if tlobject.namespace: self.write(tlobject.namespace) self.write('.') self.write(tlobject.name) self.write('#') self.write(hex(tlobject.id)[2:].rjust(8, '0')) # Write all the arguments (or do nothing if there's none) for arg in tlobject.args: self.write(' ') add_link = not arg.generic_definition and not arg.is_generic # "Opening" modifiers if arg.generic_definition: self.write('{') # Argument name self.write(arg.name) self.write(':') # "Opening" modifiers if arg.is_flag: self.write('flags.%d?' % arg.flag_index) if arg.is_generic: self.write('!') if arg.is_vector: self.write( 'Vector<' % self.type_to_path('vector') ) # Argument type if arg.type: if add_link: self.write('' % self.type_to_path(arg.type)) self.write(arg.type) if add_link: self.write('') else: self.write('#') # "Closing" modifiers if arg.is_vector: self.write('>') if arg.generic_definition: self.write('}') # Now write the resulting type (result from a function/type) self.write(' = ') generic_name = next((arg.name for arg in tlobject.args if arg.generic_definition), None) if tlobject.result == generic_name: # Generic results cannot have any link self.write(tlobject.result) else: if re.search('^vector<', tlobject.result, re.IGNORECASE): # Notice that we don't simply make up the "Vector" part, # because some requests (as of now, only FutureSalts), # use a lower type name for it (see #81) vector, inner = tlobject.result.split('<') inner = inner.strip('>') self.write('%s<' % vector) self.write('%s' % inner) self.write('>') else: self.write('%s' % tlobject.result) self.write('') def begin_table(self, column_count): """Begins a table with the given 'column_count', required to automatically create the right amount of columns when adding items to the rows""" self.table_columns = column_count self.table_columns_left = 0 self.write('
') if bold: self.write('') if link: self.write('') # Finally write the real table data, the given text self.write(text) if link: self.write('') if bold: self.write('') self.write(' | ') self.table_columns_left -= 1 if not self.table_columns_left: self.write('
') self.write(text) self.write('
') def write_copy_button(self, text, text_to_copy): """Writes a button with 'text' which can be used to copy 'text_to_copy' to clipboard when it's clicked.""" self.write_copy_script = True self.write('' .format(text_to_copy, text)) def end_body(self): """Ends the whole document. This should be called the last""" if self.write_copy_script: self.write( '' '') self.write('