Builder¶
The Translucent builder.
- class confirm.translucent.builder.Builder(build_dir, components_dir, templates_dir, remove)¶
The builder to build the Translucent UI framework out of the
templates_dir&components_dirdirectories into thebuild_dirdirectory.- Parameters:
build_dir (pathlib.Path) – The path to the builds directory
components_dir (pathlib.Path) – The path to the components directory
templates_dir (pathlib.Path) – The path to the templates directory
remove (bool) – Remove build directory before build
- build()¶
Build the Translucent library by calling all the appropriate
build_*()©_*()methods.This basically wraps the
update_components(),build_generic_files(),build_component_files()©_assets()methods.
- build_component_files()¶
Build the component files of Translucent into the
self.build_dirdirectory.This is achieved by taking the
components/component.jsfile of theself.templates_dirand render it once for each component inself.components_dirviarender_template().
- build_generic_files()¶
Build the generic Translucent files into the
self.build_dirdirectory.These are all files which reside on the root level of the
self.templates_dirdirectory, rendered by Jinja2 throughrender_template().
- copy_assets()¶
Copy the Translucent
assets/directory of theself.templates_dirto theself.build_dirdirectory.
- classmethod get_jinja2_environment(*dirs)¶
Get the Jinja2 environment for the
templates_dirdirectory.- Parameters:
*dirs (str) – The template directories
- Returns:
The Jinja2 Environment
- Return type:
jinja2.Environment
- property icons¶
All available Translucent icons, fetched from the filesystem.
- Returns:
The icons
- Return type:
list
- remove_build_dir()¶
Remove the
self.build_directoryif the path exists and is a directory.
- render_template(template, context, destination=None)¶
Load a template from the
self.templates_dirdirectory, render it through Jinja2 and save it in theself.build_dirdirectory.The
contextis a dict with the context for the rendering.If no py:attr:destination is set, the destination file is named exactly like the
template.- Parameters:
template (str) – The filename of the template
context (dict) – The template context
destination (None or str) – The destination filename
- property themes¶
All available Translucent themes, fetched from the filesystem.
- Returns:
The themes
- Return type:
list
- update_components()¶
Automatically find all components in the
self.components_dirand updateself.componentswith allbuilder.component.Componentinstances.