Skip to content

context

Context definitions used in templates.

CLASS DESCRIPTION
ChangelogContext

The primary context used when rendering a changelog.

CommitContext

Commit information for the template context.

GroupingContext

A combination of a tuple of the sorted values and a list of the CommitContexts in that group.

VersionContext

Version information for the template context.

Classes

ChangelogContext dataclass

ChangelogContext(
    config: Configuration, versions: List[VersionContext] = list()
)

The primary context used when rendering a changelog.

METHOD DESCRIPTION
as_dict

Safely generate a dict version of this object.

ATTRIBUTE DESCRIPTION
config

The changelog generation configuration.

TYPE: Configuration

group_by

The configured grouping aspects for commits within a version.

TYPE: List[str]

group_depth

The number of levels version commits are grouped by.

TYPE: int

unreleased_label

The configured label used as the version title of the changes since the last valid tag.

TYPE: str

valid_author_tokens

The configured tokens in git commit trailers that indicate authorship.

TYPE: List[str]

versions

The version contexts to render in the changelog.

TYPE: List[VersionContext]

Attributes

config instance-attribute
config: Configuration

The changelog generation configuration.

group_by class-attribute instance-attribute
group_by: List[str] = field(init=False, default_factory=list)

The configured grouping aspects for commits within a version.

group_depth class-attribute instance-attribute
group_depth: int = field(init=False)

The number of levels version commits are grouped by.

unreleased_label class-attribute instance-attribute
unreleased_label: str = field(init=False)

The configured label used as the version title of the changes since the last valid tag.

valid_author_tokens class-attribute instance-attribute
valid_author_tokens: List[str] = field(init=False, default_factory=list)

The configured tokens in git commit trailers that indicate authorship.

versions class-attribute instance-attribute
versions: List[VersionContext] = field(default_factory=list)

The version contexts to render in the changelog.

Functions

as_dict
as_dict() -> dict

Safely generate a dict version of this object.

CommitContext dataclass

CommitContext(
    sha: str,
    commit_datetime: datetime,
    summary: str,
    body: str,
    committer: str,
    grouping: tuple = tuple(),
    metadata: dict = dict(),
    files: set = set(),
)

Commit information for the template context.

METHOD DESCRIPTION
__post_init__

Set the cached author information to None.

ATTRIBUTE DESCRIPTION
author_names

A list of the authors’ names.

TYPE: list

authors

A list of authors’ names and emails.

TYPE: list

body

The commit message sans the first line.

TYPE: str

commit_datetime

The date and time of the commit with timezone offset.

TYPE: datetime

committer

The name and email of the committer as name <email@ex.com>.

TYPE: str

files

The file paths (relative to the repository root) modified by this commit.

TYPE: set

grouping

The values to group this commit based on the group_by configuration.

TYPE: tuple

metadata

Metadata for this commit parsed from the commit message.

TYPE: dict

sha

The full hex SHA of the commit.

TYPE: str

short_sha

The first seven characters of the hex sha.

TYPE: str

summary

The first line of the commit message.

TYPE: str

Attributes

author_names property
author_names: list

A list of the authors’ names.

authors property
authors: list

A list of authors’ names and emails.

RETURNS DESCRIPTION
list

A list of dictionaries with name and email keys.

body instance-attribute
body: str

The commit message sans the first line.

commit_datetime instance-attribute
commit_datetime: datetime

The date and time of the commit with timezone offset.

committer instance-attribute
committer: str

The name and email of the committer as name <email@ex.com>.

files class-attribute instance-attribute
files: set = field(default_factory=set)

The file paths (relative to the repository root) modified by this commit.

grouping class-attribute instance-attribute
grouping: tuple = field(default_factory=tuple)

The values to group this commit based on the group_by configuration.

metadata class-attribute instance-attribute
metadata: dict = field(default_factory=dict)

Metadata for this commit parsed from the commit message.

sha instance-attribute
sha: str

The full hex SHA of the commit.

short_sha property
short_sha: str

The first seven characters of the hex sha.

summary instance-attribute
summary: str

The first line of the commit message.

Functions

__post_init__
__post_init__()

Set the cached author information to None.

GroupingContext dataclass

GroupingContext(grouping: Tuple[str, ...], commits: List[CommitContext])

A combination of a tuple of the sorted values and a list of the CommitContexts in that group.

VersionContext dataclass

VersionContext(
    label: str,
    date_time: Optional[datetime] = None,
    tag: Optional[str] = None,
    previous_tag: Optional[str] = None,
    tagger: Optional[str] = None,
    grouped_commits: List[GroupingContext] = list(),
    metadata: dict = dict(),
)

Version information for the template context.

ATTRIBUTE DESCRIPTION
date_time

The date and time with timezone offset the version was tagged.

TYPE: Optional[datetime]

grouped_commits

The sections that group the commits in this version.

TYPE: List[GroupingContext]

label

The version label.

TYPE: str

metadata

Metadata for this version parsed from commits.

TYPE: dict

previous_tag

The previous tag.

TYPE: Optional[str]

tag

The tag.

TYPE: Optional[str]

tagger

The name and email of the person who tagged this version in name <email@ex.com> format.

TYPE: Optional[str]

Attributes

date_time class-attribute instance-attribute
date_time: Optional[datetime] = None

The date and time with timezone offset the version was tagged.

grouped_commits class-attribute instance-attribute
grouped_commits: List[GroupingContext] = field(default_factory=list)

The sections that group the commits in this version.

label instance-attribute
label: str

The version label.

metadata class-attribute instance-attribute
metadata: dict = field(default_factory=dict)

Metadata for this version parsed from commits.

previous_tag class-attribute instance-attribute
previous_tag: Optional[str] = None

The previous tag.

tag class-attribute instance-attribute
tag: Optional[str] = None

The tag.

tagger class-attribute instance-attribute
tagger: Optional[str] = None

The name and email of the person who tagged this version in name <email@ex.com> format.

Functions