Note

This documentation is for a development version. Click here for the latest stable release (v0.11.1).

API reference

nengo_bones.config

Handles the processing of nengo-bones configuration settings.

nengo_bones.templates

Handles the processing of nengo-bones templates using jinja2.

nengo_bones.config

Handles the processing of nengo-bones configuration settings.

nengo_bones.config.check_list(cfg, key)[source]

Verify that config value is a list.

This is designed to catch the common error of specifying

option:
    value

instead of

option:
    - value
Parameters
cfgdict

Configuration options being checked.

key: str

Name of configuration value to be checked.

Raises
TypeError

If key is in cfg and its value is not a list.

nengo_bones.config.find_config()[source]

Finds the default nengo-bones config file.

Returns
conf_filepathlib.Path

Path to the default config file.

nengo_bones.config.fill_defaults(config)[source]

Fills in default values in a loaded config (in-place).

Parameters
configdict

Dictionary containing configuration values.

nengo_bones.config.validate_black_config(config)[source]

Validates aspects of the config related to Black.

Parameters
configdict

Dictionary containing configuration values.

nengo_bones.config.validate_setup_cfg_config(config)[source]

Validates the setup_cfg section of the config.

Parameters
configdict

Dictionary containing configuration values.

nengo_bones.config.validate_config(config)[source]

Validates a populated config dict.

Parameters
configdict

Dictionary containing configuration values.

nengo_bones.config.validate_ci_config(ci_config)[source]

Validates an entry in the ci_scripts list of a config dict.

Parameters
ci_configdict

Dictionary containing ci_scripts configuration values.

nengo_bones.config.load_config(conf_file=None)[source]

Loads config values from a file and applies defaults/validation.

Parameters
conf_filestr

Filepath for config file (if None, will load the default returned by find_config).

Returns
configdict

Dictionary containing configuration values.

nengo_bones.templates

Handles the processing of nengo-bones templates using jinja2.

class nengo_bones.templates.BonesTemplate(output_file, env)[source]

A templated file known to NengoBones.

The only necessary information is the output filename, relative to the templates directory, which means that the output filename for the Sphinx configuration is docs/conf.py. Other attributes are determined from the output filename.

Parameters
output_filestr

Filename for the rendered output file.

envjinja2.Environment

Initialized jinja environment for loading/rendering templates.

Attributes
envjinja2.Environment

Initialized jinja environment for loading/rendering templates.

output_filestr

Filename for the rendered output file.

sectionstr

The heading for the section in the config file containing config options specific to the template being rendered.

template_filestr

Filename for the input template file.

classmethod add_render_data(filename)[source]

Register functions that add template-specific render data.

For example:

@nengo_bones.templates.BonesTemplate.add_render_data("my_new_template")
def add_my_new_template_data(data):
    data["attr"] = "val"
    ...
get_render_data(config)[source]

Construct the data that will be used to render this template.

This method creates a new dictionary so the original config is not modified. Additionally, certain sections have processing done to them in addition to flattening out the section to the top-level of the config.

Parameters
configdict

Dictionary containing configuration values.

Returns
datadict

A dictionary that can be passed to render and render_to_file.

render(**data)[source]

Render this template to a string.

Parameters
datadict

Will be passed on to the template.render function.

render_to_file(output_dir, output_name=None, **data)[source]

Render a template to file.

Note

Rendered shell scripts (files with the .sh extension) are automatically marked as executable.

Parameters
output_dirstr

Directory in which the rendered file should be placed.

output_namestr, optional

An alternative filename for the rendered file. This overrides the class’s internal output_file attribute.

datadict

Will be passed on to the render function.

nengo_bones.templates.add_docs_conf_py_data(data)[source]

Run checks on the docs/conf.py-specific entries in the ‘data’ dict.

nengo_bones.templates.add_travis_data(data)[source]

Add travis.yml-specific entries to the ‘data’ dict.

nengo_bones.templates.add_manifest_data(data)[source]

Add MANIFEST.in-specific entries to the ‘data’ dict.

nengo_bones.templates.add_setup_py_data(data)[source]

Add setup.py-specific entries to the ‘data’ dict.

nengo_bones.templates.add_setup_cfg_data(data)[source]

Add setup.cfg-specific entries to the ‘data’ dict.

nengo_bones.templates.load_env()[source]

Creates a jinja environment for loading/rendering templates.