def rst_title_and_table(title, table_titles, table_values): """Generate table in section with title in .rst format.""" doc = [] if title is not None: doc.extend([ title, '-' * len(title), '', ]) doc.extend(mk_rst_table(table_titles, table_values)) return doc
def avail_cfgfile_constants_rst(go_cfg_constants): title = "Constants available (only) in configuration files" doc = [title, '-' * len(title), ''] for section in go_cfg_constants: doc.append('') if section != go_cfg_constants['DEFAULT']: section_title = "only in '%s' section:" % section doc.extend([section_title, '-' * len(section_title), '']) table_titles = ["Constant name", "Constant help", "Constant value"] table_values = [ ['``' + name + '``' for name in go_cfg_constants[section].keys()], [tup[1] for tup in go_cfg_constants[section].values()], ['``' + tup[0] + '``' for tup in go_cfg_constants[section].values()], ] doc.extend(mk_rst_table(table_titles, table_values)) return '\n'.join(doc)