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_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_tables(source, target, list_target): table_data = YamlTable(source) build_all = False if not table_data.format or table_data.format is None: build_all = True if build_all or table_data.format == 'list': list_table = TableBuilder(ListTable(table_data)) list_table.write(list_target) puts('[table]: rebuilt {0}'.format(list_target)) list_table.write(target) puts('[table]: rebuilt {0} as (a list table)'.format(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) # puts('[table]: rebuilt {0} as (a list table)'.format(target)) puts('[table]: rebuilt table output for {0}'.format(source))
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 _generate_toc_tree(fn, fmt, base_name, paths): puts('[toc]: generating {0} toc'.format(fn)) if fmt == 'spec': spec = True toc = AggregatedTocTree(fn) fmt = toc._first_source[0:3] toc.build_dfn() toc.build_table() toc.finalize() if fmt == 'ref': if toc.table is not None: outfn = _get_toc_output_name(base_name, 'table', paths) t = TableBuilder(RstTable(toc.table)) t.write(outfn) puts('[toc-spec]: wrote: ' + outfn) elif fmt == 'toc': outfn = _get_toc_output_name(base_name, 'dfn-list', paths) toc.dfn.write(outfn) puts('[toc-spec]: wrote: ' + outfn) else: spec = False toc = CustomTocTree(fn) 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) puts('[toc]: wrote: ' + outfn) if fmt == 'ref': outfn = _get_toc_output_name(base_name, 'table', paths) t = TableBuilder(RstTable(toc.table)) t.write(outfn) puts('[ref-toc]: wrote: ' + outfn) elif fmt == 'toc': outfn = _get_toc_output_name(base_name, 'dfn-list', paths) toc.dfn.write(outfn) puts('[toc]: wrote: ' + outfn) puts('[toc]: compiled toc output for {0}'.format(fn))
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