-
Notifications
You must be signed in to change notification settings - Fork 38
Description
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_prefixtochangelog.ymlso users can set the default behavior without passing--strip-title-prefixat 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; } = falseproperty with XML doc - Follow the same pattern as
ReleaseNotesandIssues - Default is
falseto 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
StripTitlePrefixfrombooltobool?(nullable, likeExtractIssues) - When
null, use config default
ChangelogCreationService.ApplyConfigDefaults
- Add:
StripTitlePrefix = input.StripTitlePrefix ?? config.Extract.StripTitlePrefix - Include in the
input with { ... }block alongsideExtractReleaseNotes,ExtractIssues, etc.
4. GitHub Release Path
CreateChangelogsFromReleaseArguments (GitHubReleaseChangelogService.cs)
- Change
StripTitlePrefixfrombooltobool? - When
null, the service must resolve from config
GitHubReleaseChangelogService.CreateChangelogsFromRelease
- Before processing PRs, if
input.StripTitlePrefixisnull, load config and set:
var stripTitlePrefix = input.StripTitlePrefix ?? config.Extract.StripTitlePrefix - The service already loads config via
_configLoader.LoadChangelogConfigurationRequired; ensureStripTitlePrefixis resolved there
5. CLI Command Updates
ChangelogCommand.cs
For Create (changelog add):
- Keep
stripTitlePrefix = falseparameter default - Resolve: when
--strip-title-prefixpassed →true; otherwise →null - Pass
StripTitlePrefix = stripTitlePrefix ? true : (bool?)nulltoCreateChangelogArguments - Config default of
falseapplies when input isnull
For --release-version path (inside Create):
- Same resolution; pass to
CreateChangelogsFromReleaseArguments
For GitHubRelease (changelog gh-release):
- Keep
stripTitlePrefix = falseparameter default - Resolve: when
--strip-title-prefixpassed →true; otherwise →null - Pass
StripTitlePrefix = stripTitlePrefix ? true : (bool?)nulltoCreateChangelogsFromReleaseArguments - Config default of
falseapplies when input isnull
For EvaluatePr (changelog evaluate-pr):
- Keep
stripTitlePrefix = falseparameter default - Resolve the same way: when
--strip-title-prefixpassed →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 (afterissues:):# 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-prefixdescription to mention: "By default, the behavior is determined by theextract.strip_title_prefixchangelog configuration setting (which defaults tofalse)."
docs/cli/release/changelog-gh-release.md
- Update
--strip-title-prefixto reference config fallback: "By default, the behavior is determined byextract.strip_title_prefixin changelog.yml (defaults tofalse)."
docs/contribute/changelog.md
- Add
extract.strip_title_prefixto the configuration section - Document the fallback chain: CLI
--strip-title-prefix>extract.strip_title_prefixconfig >false(default)
docs/syntax/changelog.md (if it documents the extract schema)
- Add
strip_title_prefixto the extract configuration schema
8. Tests
ChangelogConfigurationTests.cs
- Add test: loading changelog.yml with
extract.strip_title_prefix: trueyields the expected value - Add test: when missing, default is
false
Create/TitleProcessingTests.cs or new Create/StripTitlePrefixConfigTests.cs
- Test that when
StripTitlePrefixisnullon input and config hasextract.strip_title_prefix: false, prefix is NOT stripped - Test that when
StripTitlePrefixisnulland config hasextract.strip_title_prefix: true, prefix IS stripped - Test that explicit CLI
--strip-title-prefix(true) overrides configfalse - Test that when neither CLI nor config is set, default
falseapplies (prefix not stripped)
GitHubReleaseChangelogService (if there are existing tests)
- Add tests for config resolution when
CreateChangelogsFromReleaseArguments.StripTitlePrefixisnull
Optional: Future Enhancement
To allow users to disable stripping via CLI when the config has it enabled:
- Add
--no-strip-title-prefixtochangelog add,changelog add --release-version, andchangelog gh-release - This would allow overriding
extract.strip_title_prefix: trueto temporarily disable stripping - Not required for the MVP; the current
--strip-title-prefixflag 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.StripTitlePrefix → bool?; add to ApplyConfigDefaults |
src/services/Elastic.Changelog/GithubRelease/GitHubReleaseChangelogService.cs |
CreateChangelogsFromReleaseArguments.StripTitlePrefix → bool?; 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 buildsucceeds -
./build.sh unit-testpasses -
dotnet formatapplied -
changelog add --prs <url>without--strip-title-prefixdoes NOT strip (uses config default offalse) -
changelog add --prs <url> --strip-title-prefixstrips the prefix -
changelog gh-release <repo> <version>without--strip-title-prefixdoes NOT strip (uses config default offalse) -
changelog gh-release <repo> <version> --strip-title-prefixstrips the prefix - Config with
extract.strip_title_prefix: truecauses stripping by default (without CLI flag) - CLI
--strip-title-prefixoverrides configfalseto enable stripping -
changelog initor 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