def _generate_tables(source, target, list_target): table_data = YamlTable(source) make_parent_dirs(target, list_target) # if not table_data.format or table_data.format is None: # build_all = True list_table = TableBuilder(ListTable(table_data)) list_table.write(list_target) logger.debug('rebuilt rendered table {0}'.format(list_target)) list_table.write(target) logger.debug('rebuilt rendered list table {0}'.format(target)) # if build_all or table_data.format == 'list': # list_table = TableBuilder(ListTable(table_data)) # list_table.write(list_target) # print('[table]: rebuilt {0}'.format(list_target)) # if build_all or table_data.format == 'rst': # # this really ought to be RstTable, but there's a bug there. # rst_table = TableBuilder(ListTable(table_data)) # rst_table.write(target) # print('[table]: rebuilt {0} as (a list table)'.format(target)) logger.info('rebuilt rendered table output for {0}'.format(source))
def render_apiarg_table(r, apiargs): table = TableData() header = [apiargs.field_type()] if apiargs.has_type() is True: header.append('Type') header.append('Description') num_columns = len(header) table.add_header(header) if num_columns == 2: widths = [20, 80] for entry in apiargs.ordering: table.add_row([RstCloth.pre(entry.name), entry.description]) elif num_columns == 3: widths = [20, 20, 80] for entry in apiargs.ordering: table.add_row([ RstCloth.pre(entry.name), entry.type_for_table_output(), entry.description ]) r.content(TableBuilder(ListTable(table, widths=widths)).output, indent=3)
def _generate_toc_tree(fn, fmt, base_name, paths, conf): if fmt == 'spec': logger.debug('generating spec toc {0}'.format(fn)) toc = AggregatedTocTree(fn, conf) fmt = toc._first_source[0:3] toc.build_dfn() toc.build_table() toc.finalize() if fmt == 'ref': outfn = _get_toc_output_name(base_name, 'table', paths) t = TableBuilder(RstTable(toc.table)) t.write(outfn) logger.debug('wrote spec ref-toc: ' + outfn) elif fmt == 'toc': outfn = _get_toc_output_name(base_name, 'dfn-list', paths) toc.dfn.write(outfn) logger.debug('wrote spec toc: ' + outfn) else: logger.debug('generating toc {0}'.format(fn)) toc = CustomTocTree(fn, conf) toc.build_contents() if fmt == 'toc': toc.build_dfn() elif fmt == 'ref': toc.build_table() toc.finalize() outfn = _get_toc_output_name(base_name, 'toc', paths) toc.contents.write(outfn) logger.debug('wrote toc: ' + outfn) if fmt == 'ref': outfn = _get_toc_output_name(base_name, 'table', paths) t = TableBuilder(RstTable(toc.table)) t.write(outfn) logger.debug('wrote ref toc: ' + outfn) elif fmt == 'toc': outfn = _get_toc_output_name(base_name, 'dfn-list', paths) toc.dfn.write(outfn) logger.debug('wrote toc file: ' + outfn)
def render_toc_table(toc_items): table = TableData() table.add_header(['Name', 'Description']) for entry in toc_items: entry.render() if 'name' in entry: table.add_row([entry.name, entry.description]) else: table.add_row([RstCloth.role('doc', entry.file), entry.description]) return TableBuilder(RstTable(table))
def generate_param_table(params): table_data = ParamTable() table_data.set_column_widths(params[0]) table_data.add_header( render_header_row(params[0], table_data.num_rows, table_data.type_column)) for param in params: row = [RstCloth().pre(param['name'])] if table_data.type_column is True: row.append(process_type_cell(param['type'], 'table')) row.append( process_description(param['description'], param['field']['optional'])) table_data.add_row(row) table = TableBuilder(ListTable(table_data, widths=table_data.widths)) return table.output