Ejemplo n.º 1
0
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)
    print('[table]: rebuilt {0}'.format(list_target))

    list_table.write(target)
    print('[table]: rebuilt {0} as (a list table)'.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))

    print('[table]: rebuilt table output for {0}'.format(source))
Ejemplo n.º 2
0
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':
            if toc.table is not None:
                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)
Ejemplo n.º 3
0
def _generate_toc_tree(fn, fmt, base_name, paths):
    print('[toc]: generating {0} toc'.format(fn))
    if fmt == 'spec':
        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)
                print('[toc-spec]: wrote: ' + outfn)
        elif fmt == 'toc':
            outfn = _get_toc_output_name(base_name, 'dfn-list', paths)
            toc.dfn.write(outfn)
            print('[toc-spec]: wrote: ' + outfn)

    else:
        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)
        print('[toc]: wrote: ' + outfn)

        if fmt == 'ref':
            outfn = _get_toc_output_name(base_name, 'table', paths)
            t = TableBuilder(RstTable(toc.table))
            t.write(outfn)
            print('[ref-toc]: wrote: ' + outfn)
        elif fmt == 'toc':
            outfn = _get_toc_output_name(base_name, 'dfn-list', paths)
            toc.dfn.write(outfn)
            print('[toc]: wrote: ' + outfn)

    print('[toc]: compiled toc output for {0}'.format(fn))
Ejemplo n.º 4
0
def _generate_toc_tree(fn, fmt, base_name, paths, conf):
    print('[toc]: generating {0} toc'.format(fn))

    if fmt == 'spec':
        toc = AggregatedTocTree(fn, conf)
        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)
                print('[toc-spec]: wrote: '  + outfn)
        elif fmt == 'toc':
            outfn = _get_toc_output_name(base_name, 'dfn-list', paths)
            toc.dfn.write(outfn)
            print('[toc-spec]: wrote: '  + outfn)

    else:
        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)
        print('[toc]: wrote: '  + outfn)

        if fmt == 'ref':
            outfn = _get_toc_output_name(base_name, 'table', paths)
            t = TableBuilder(RstTable(toc.table))
            t.write(outfn)
            print('[ref-toc]: wrote: '  + outfn)
        elif fmt == 'toc':
            outfn = _get_toc_output_name(base_name, 'dfn-list', paths)
            toc.dfn.write(outfn)
            print('[toc]: wrote: '  + outfn)

    print('[toc]: compiled toc output for {0}'.format(fn))
Ejemplo n.º 5
0
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":
            if toc.table is not None:
                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)
Ejemplo n.º 6
0
def _generate_toc_tree(fn, fmt, base_name, paths):
    print("[toc]: generating {0} toc".format(fn))
    if fmt == "spec":
        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)
                print("[toc-spec]: wrote: " + outfn)
        elif fmt == "toc":
            outfn = _get_toc_output_name(base_name, "dfn-list", paths)
            toc.dfn.write(outfn)
            print("[toc-spec]: wrote: " + outfn)

    else:
        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)
        print("[toc]: wrote: " + outfn)

        if fmt == "ref":
            outfn = _get_toc_output_name(base_name, "table", paths)
            t = TableBuilder(RstTable(toc.table))
            t.write(outfn)
            print("[ref-toc]: wrote: " + outfn)
        elif fmt == "toc":
            outfn = _get_toc_output_name(base_name, "dfn-list", paths)
            toc.dfn.write(outfn)
            print("[toc]: wrote: " + outfn)

    print("[toc]: compiled toc output for {0}".format(fn))
Ejemplo n.º 7
0
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