How to use the hacking.build_library.build_ansible.jinja2.filters.documented_type function in hacking

To help you get started, we’ve selected a few hacking 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 ansible / ansible / hacking / build_library / build_ansible / command_plugins / plugin_formatter.py View on Github external
env.globals['from_kludge_ns'] = from_kludge_ns
    if 'max' not in env.filters:
        # Jinja < 2.10
        env.filters['max'] = do_max

    if 'tojson' not in env.filters:
        # Jinja < 2.9
        env.filters['tojson'] = json.dumps

    templates = {}
    if typ == 'rst':
        env.filters['rst_ify'] = rst_ify
        env.filters['html_ify'] = html_ify
        env.filters['fmt'] = rst_fmt
        env.filters['xline'] = rst_xline
        env.filters['documented_type'] = documented_type
        env.tests['list'] = test_list
        templates['plugin'] = env.get_template('plugin.rst.j2')
        templates['plugin_deprecation_stub'] = env.get_template('plugin_deprecation_stub.rst.j2')

        if plugin_type == 'module':
            name = 'modules'
        else:
            name = 'plugins'

        templates['category_list'] = env.get_template('%s_by_category.rst.j2' % name)
        templates['support_list'] = env.get_template('%s_by_support.rst.j2' % name)
        templates['list_of_CATEGORY_modules'] = env.get_template('list_of_CATEGORY_%s.rst.j2' % name)
    else:
        raise Exception("Unsupported format type: %s" % typ)

    return templates
github ansible / ansible / hacking / build_library / build_ansible / command_plugins / collection_meta.py View on Github external
def main(args):
        output_dir = os.path.abspath(args.output_dir)
        template_file_full_path = os.path.abspath(os.path.join(args.template_dir, args.template_file))
        template_file = os.path.basename(template_file_full_path)
        template_dir = os.path.dirname(template_file_full_path)

        with open(args.collection_defs) as f:
            options = yaml.safe_load(f)

        normalize_options(options)

        env = Environment(loader=FileSystemLoader(template_dir),
                          variable_start_string="@{",
                          variable_end_string="}@",
                          trim_blocks=True)
        env.filters['documented_type'] = documented_type
        env.filters['rst_ify'] = rst_ify

        template = env.get_template(template_file)
        output_name = os.path.join(output_dir, template_file.replace('.j2', ''))
        temp_vars = {'options': options}

        data = to_bytes(template.render(temp_vars))
        update_file_if_different(output_name, data)

        return 0