app.domain.titles

ADR file names, filename dates and display-title derivation.

Public API: ADR_FILENAME_RE, is_adr_filename(), filename_date(), derive_title(), erratum_title().

app.domain.titles.ADR_FILENAME_RE = re.compile('^\\d{4}-\\d{2}-\\d{2}-(.*)\\.md$')

Legacy discovery pattern for ADR filenames (applied to the basename).

app.domain.titles.is_adr_filename(name)

Tell whether a file name matches the legacy ADR discovery pattern.

Parameters:

name (str) – File name or repository path; only the basename counts.

Return type:

bool

Returns:

True for names like 2024-12-24-use-postgresql.md.

app.domain.titles.filename_date(name)

Extract the date prefix of an ADR file name.

Parameters:

name (str) – File name or repository path.

Return type:

date | None

Returns:

The date if the basename starts with a valid YYYY-MM-DD- prefix, else None.

app.domain.titles.derive_title(explicit, body, filename)

Choose the display title: frontmatter, first H1, then filename.

Parameters:
  • explicit (str | None) – Validated frontmatter title, if any.

  • body (str) – Markdown body.

  • filename (str) – File name or repository path.

Return type:

tuple[str, TitleSource]

Returns:

The title and where it came from.

app.domain.titles.erratum_title(section, filename)

Build the fallback title of an erratum without an explicit title.

Parameters:
  • section (str | None) – Validated section field, if any.

  • filename (str) – File name or repository path.

Return type:

tuple[str, TitleSource]

Returns:

"Erratum: <section>" (from the frontmatter), else "Erratum: <humanised filename slug>".