semantic_release.changelog.template module

class semantic_release.changelog.template.ComplexDirectorySandboxedEnvironment(*args: Any, **kwargs: Any)[source]

Bases: SandboxedEnvironment

join_path(template: str, parent: str) str[source]

Add support for complex directory structures in the template directory.

This method overrides the default functionality of the SandboxedEnvironment where all ‘include’ keywords expect to be in the same directory as the calling template, however this is unintuitive when using a complex directory structure.

This override simulates the changing of directories when you include the template from a child directory. When the child then includes a template, it will make the path relative to the child directory rather than the top level template directory.

semantic_release.changelog.template.environment(template_dir: Path | str = '.', block_start_string: str = '{%', block_end_string: str = '%}', variable_start_string: str = '{{', variable_end_string: str = '}}', comment_start_string: str = '{#', comment_end_string: str = '#}', line_statement_prefix: str | None = None, line_comment_prefix: str | None = None, trim_blocks: bool = False, lstrip_blocks: bool = False, newline_sequence: Literal['\n', '\r', '\r\n'] = '\n', keep_trailing_newline: bool = False, extensions: Iterable[str] = (), autoescape: bool | str = True) SandboxedEnvironment[source]

Create a jinja2.sandbox.SandboxedEnvironment with certain parameter resrictions.

For example the Loader is fixed to FileSystemLoader, although the searchpath is configurable.

autoescape can be a string in which case it should follow the convention module:attr, in this instance it will be dynamically imported. See https://jinja.palletsprojects.com/en/3.1.x/api/#jinja2.Environment for full parameter descriptions

semantic_release.changelog.template.recursive_render(template_dir: Path, environment: Environment, _root_dir: str | os.PathLike[str] = '.') list[str][source]