Skip to content

[Feature Request]: Add changelog configuration option for --strip-title-prefix #2932

@lcawl

Description

@lcawl

Prerequisites

  • I have searched existing issues to ensure this feature hasn't already been requested
  • I have tested using the latest version of docs-builder

What problem are you trying to solve?

I don't want to have to remember to set the --strip-title-prefix option when I run the docs-builder changlog add command. I want to "set and forget" it.

Proposed Solution

This plan adds a new extract.strip_title_prefix setting to the changelog configuration file, equivalent to the existing --strip-title-prefix CLI option. The implementation mirrors how extract.issues maps to --no-extract-issues.

Goal

  • Add extract.strip_title_prefix to changelog.yml so users can set the default behavior without passing --strip-title-prefix at the command line
  • When the CLI flag is not specified, use the config value
  • CLI flag overrides the config when explicitly provided
  • Default value in configuration: false (preserves current behavior where stripping is OFF by default)

Precedence Chain

Precedence Source Behavior
1 --strip-title-prefix CLI flag Explicitly enable (override config)
2 extract.strip_title_prefix in changelog.yml Config default
3 Hardcoded default false (when config not set; matches current CLI default)

Implementation Steps

1. Configuration Model and YAML DTO

ExtractConfiguration.cs (Elastic.Documentation.Configuration)

  • Add StripTitlePrefix { get; init; } = false property with XML doc
  • Follow the same pattern as ReleaseNotes and Issues
  • Default is false to preserve current behavior (stripping is OFF by default)

ChangelogConfigurationYaml.cs (ExtractConfigurationYaml internal record)

  • Add bool? StripTitlePrefix { get; set; } to the YAML DTO

2. Configuration Loader

ChangelogConfigurationLoader.cs

  • In the extract configuration parsing block (around line 291), add:
    StripTitlePrefix = yamlConfig.Extract?.StripTitlePrefix ?? false
    

3. Arguments and ApplyConfigDefaults

CreateChangelogArguments (ChangelogCreationService.cs)

  • Change StripTitlePrefix from bool to bool? (nullable, like ExtractIssues)
  • When null, use config default

ChangelogCreationService.ApplyConfigDefaults

  • Add: StripTitlePrefix = input.StripTitlePrefix ?? config.Extract.StripTitlePrefix
  • Include in the input with { ... } block alongside ExtractReleaseNotes, ExtractIssues, etc.

4. GitHub Release Path

CreateChangelogsFromReleaseArguments (GitHubReleaseChangelogService.cs)

  • Change StripTitlePrefix from bool to bool?
  • When null, the service must resolve from config

GitHubReleaseChangelogService.CreateChangelogsFromRelease

  • Before processing PRs, if input.StripTitlePrefix is null, load config and set:
    var stripTitlePrefix = input.StripTitlePrefix ?? config.Extract.StripTitlePrefix
  • The service already loads config via _configLoader.LoadChangelogConfigurationRequired; ensure StripTitlePrefix is resolved there

5. CLI Command Updates

ChangelogCommand.cs

For Create (changelog add):

  • Keep stripTitlePrefix = false parameter default
  • Resolve: when --strip-title-prefix passed → true; otherwise → null
  • Pass StripTitlePrefix = stripTitlePrefix ? true : (bool?)null to CreateChangelogArguments
  • Config default of false applies when input is null

For --release-version path (inside Create):

  • Same resolution; pass to CreateChangelogsFromReleaseArguments

For GitHubRelease (changelog gh-release):

  • Keep stripTitlePrefix = false parameter default
  • Resolve: when --strip-title-prefix passed → true; otherwise → null
  • Pass StripTitlePrefix = stripTitlePrefix ? true : (bool?)null to CreateChangelogsFromReleaseArguments
  • Config default of false applies when input is null

For EvaluatePr (changelog evaluate-pr):

  • Keep stripTitlePrefix = false parameter default
  • Resolve the same way: when --strip-title-prefix passed → true; otherwise → null
  • If config needs to be loaded, apply: input.StripTitlePrefix ?? config.Extract.StripTitlePrefix

6. Config Example File

config/changelog.example.yml

  • Under extract:, add (after issues:):
    # Remove square-bracket prefixes from PR titles (default: false)
    # When enabled (true or via --strip-title-prefix), titles like "[ES|QL] Fix bug" become "Fix bug".
    # Can be overridden by CLI --strip-title-prefix
    strip_title_prefix: false

7. Documentation Updates

docs/cli/release/changelog-add.md

  • Update --strip-title-prefix description to mention: "By default, the behavior is determined by the extract.strip_title_prefix changelog configuration setting (which defaults to false)."

docs/cli/release/changelog-gh-release.md

  • Update --strip-title-prefix to reference config fallback: "By default, the behavior is determined by extract.strip_title_prefix in changelog.yml (defaults to false)."

docs/contribute/changelog.md

  • Add extract.strip_title_prefix to the configuration section
  • Document the fallback chain: CLI --strip-title-prefix > extract.strip_title_prefix config > false (default)

docs/syntax/changelog.md (if it documents the extract schema)

  • Add strip_title_prefix to the extract configuration schema

8. Tests

ChangelogConfigurationTests.cs

  • Add test: loading changelog.yml with extract.strip_title_prefix: true yields the expected value
  • Add test: when missing, default is false

Create/TitleProcessingTests.cs or new Create/StripTitlePrefixConfigTests.cs

  • Test that when StripTitlePrefix is null on input and config has extract.strip_title_prefix: false, prefix is NOT stripped
  • Test that when StripTitlePrefix is null and config has extract.strip_title_prefix: true, prefix IS stripped
  • Test that explicit CLI --strip-title-prefix (true) overrides config false
  • Test that when neither CLI nor config is set, default false applies (prefix not stripped)

GitHubReleaseChangelogService (if there are existing tests)

  • Add tests for config resolution when CreateChangelogsFromReleaseArguments.StripTitlePrefix is null

Optional: Future Enhancement

To allow users to disable stripping via CLI when the config has it enabled:

  • Add --no-strip-title-prefix to changelog add, changelog add --release-version, and changelog gh-release
  • This would allow overriding extract.strip_title_prefix: true to temporarily disable stripping
  • Not required for the MVP; the current --strip-title-prefix flag covers the main use case of enabling stripping when config doesn't have it set

Files to Modify

File Changes
src/Elastic.Documentation.Configuration/Changelog/ExtractConfiguration.cs Add StripTitlePrefix property
src/services/Elastic.Changelog/Serialization/ChangelogConfigurationYaml.cs Add StripTitlePrefix to ExtractConfigurationYaml
src/services/Elastic.Changelog/Configuration/ChangelogConfigurationLoader.cs Parse StripTitlePrefix from YAML
src/services/Elastic.Changelog/Creation/ChangelogCreationService.cs CreateChangelogArguments.StripTitlePrefixbool?; add to ApplyConfigDefaults
src/services/Elastic.Changelog/GithubRelease/GitHubReleaseChangelogService.cs CreateChangelogsFromReleaseArguments.StripTitlePrefixbool?; resolve from config when null
src/tooling/docs-builder/Commands/ChangelogCommand.cs Pass bool?; add --no-strip-title-prefix (optional); resolve precedence
config/changelog.example.yml Add strip_title_prefix: true under extract
docs/cli/release/changelog-add.md Update option docs
docs/cli/release/changelog-gh-release.md Update option docs
docs/contribute/changelog.md Document extract.strip_title_prefix
docs/syntax/changelog.md Add to extract schema (if applicable)
tests/Elastic.Changelog.Tests/ Add configuration and creation tests

Verification Checklist

  • dotnet build succeeds
  • ./build.sh unit-test passes
  • dotnet format applied
  • changelog add --prs <url> without --strip-title-prefix does NOT strip (uses config default of false)
  • changelog add --prs <url> --strip-title-prefix strips the prefix
  • changelog gh-release <repo> <version> without --strip-title-prefix does NOT strip (uses config default of false)
  • changelog gh-release <repo> <version> --strip-title-prefix strips the prefix
  • Config with extract.strip_title_prefix: true causes stripping by default (without CLI flag)
  • CLI --strip-title-prefix overrides config false to enable stripping
  • changelog init or scaffold does not need changes (config example covers the new field)

Examples and Research

No response

Alternative Solutions

No response

Additional Context

No response

How important is this feature to you?

Nice to have

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions