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_dir
directories into thebuild_dir
directory.- 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_dir
directory.This is achieved by taking the
components/component.js
file of theself.templates_dir
and render it once for each component inself.components_dir
viarender_template()
.
- build_generic_files()¶
Build the generic Translucent files into the
self.build_dir
directory.These are all files which reside on the root level of the
self.templates_dir
directory, rendered by Jinja2 throughrender_template()
.
- copy_assets()¶
Copy the Translucent
assets/
directory of theself.templates_dir
to theself.build_dir
directory.
- classmethod get_jinja2_environment(*dirs)¶
Get the Jinja2 environment for the
templates_dir
directory.- 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_directory
if the path exists and is a directory.
- render_template(template, context, destination=None)¶
Load a template from the
self.templates_dir
directory, render it through Jinja2 and save it in theself.build_dir
directory.The
context
is 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_dir
and updateself.components
with allbuilder.component.Component
instances.