How to use the fastr.helpers.rest_generation.create_rest_table function in fastr

To help you get started, we’ve selected a few fastr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MStarmans91 / WORC / WORC / doc / generate_config.py View on Github external
# Per main section, create relevant tables
    for key in unique_keys:
        indices = [i for i, x in enumerate(data[0]) if x == key]
        subkeys = [data[1][i] for i in indices]
        descriptions = [data[2][i] for i in indices]
        defaults = [data[3][i] for i in indices]
        options = [data[4][i] for i in indices]

        # Create description table
        filename = os.path.join(os.path.dirname(__file__),
                                'autogen',
                                'config',
                                f'WORC.config_{key}_description.rst')
        headers_temp = ['Subkey', 'Description']
        data_temp = [subkeys, descriptions]
        table = create_rest_table(data_temp, headers_temp)

        with open(filename, 'w') as fh_out:
            fh_out.write(table)

        # Create defaults and options table
        filename = os.path.join(os.path.dirname(__file__),
                                'autogen',
                                'config',
                                f'WORC.config_{key}_defopts.rst')
        headers_temp = ['Subkey', 'Default', 'Options']
        data_temp = [subkeys, defaults, options]
        table = create_rest_table(data_temp, headers_temp)

        with open(filename, 'w') as fh_out:
            fh_out.write(table)
github MStarmans91 / WORC / WORC / doc / generate_config.py View on Github external
# Create defaults and options table
        filename = os.path.join(os.path.dirname(__file__),
                                'autogen',
                                'config',
                                f'WORC.config_{key}_defopts.rst')
        headers_temp = ['Subkey', 'Default', 'Options']
        data_temp = [subkeys, defaults, options]
        table = create_rest_table(data_temp, headers_temp)

        with open(filename, 'w') as fh_out:
            fh_out.write(table)

    # Create main table
    headers = ['Key', 'Reference']
    data = [unique_keys, [f':ref:`{h} `' for h in unique_keys]]
    table = create_rest_table(data, headers)

    filename = os.path.join(os.path.dirname(__file__),
                            'autogen',
                            f'WORC.config.rst')
    with open(filename, 'w') as fh_out:
        fh_out.write(table)

    print(f'[generate_config.py] Config references saved!')

fastr

Workflow creation and batch execution environment.

Apache-2.0
Latest version published 7 months ago

Package Health Score

44 / 100
Full package analysis