Skip to content

Conversation

@lcawl
Copy link
Contributor

@lcawl lcawl commented Jan 15, 2026

Impetus

In elastic/docs-content#4627 it becomes obvious that a lot of PR titles have prefixes that we've been automatically or manually removing from release notes. We should have an option for cleaning this up when the changelogs are created.

Overview

Added a new --strip-title-prefix option to the docs-builder changelog add command that automatically removes square bracket prefixes from PR titles when creating changelogs.

Changes Made

1. Core Implementation

ChangelogInput Class

  • File: src/services/Elastic.Documentation.Services/Changelog/ChangelogInput.cs
  • Change: Added StripTitlePrefix boolean property to track whether prefix stripping should be applied

ChangelogCommand Class

  • File: src/tooling/docs-builder/Commands/ChangelogCommand.cs
  • Changes:
    • Added --strip-title-prefix parameter to the Create method
    • Added XML documentation describing the option
    • Passed the parameter value to ChangelogInput.StripTitlePrefix

ChangelogService Class

  • File: src/services/Elastic.Documentation.Services/ChangelogService.cs
  • Changes:
    • Added StripSquareBracketPrefix() helper method that:
      • Checks if title starts with [
      • Finds the matching ]
      • Removes the brackets and content within them
      • Trims leading whitespace from the result
    • Applied prefix stripping logic when PR title is used (line ~251)
    • Ensured StripTitlePrefix property is copied when processing multiple PRs

2. Functionality

The --strip-title-prefix option:

  • Works only with the --prs option
  • Only applies when the title is derived from the PR (when --title is not explicitly provided)
  • Removes square brackets and text within them from the beginning of PR titles
  • Example transformation:
    • Input: "[Inference API] Include rerank in supported tasks for IBM watsonx integration"
    • Output: "Include rerank in supported tasks for IBM watsonx integration"

3. Documentation Updates

Updated docs/cli/release/changelog-add.md and docs/contribute/changelog.md.

Usage Example

./docs-builder changelog add \
  --prs https://github.com/elastic/kibana/pull/247965 \
  --products "kibana 9.3.0" \
  --config /path/to/kibana/docs/changelog.yml \
  --strip-title-prefix

The PR title is "[Attack discovery] Improves Attack discovery hallucination detection" but the changelog contains the following information:

pr: https://github.com/elastic/kibana/pull/247965
type: enhancement
products:
- product: kibana
  target: 9.3.0
areas:
- Elastic Security solution
title: Improves Attack discovery hallucination detection

Technical Details

Implementation Logic

The StripSquareBracketPrefix() method:

  1. Returns the title unchanged if it's null or whitespace
  2. Returns the title unchanged if it doesn't start with [
  3. Searches for the matching ] character starting from position 1
  4. If no matching ] is found, returns the title unchanged
  5. Extracts everything after the closing bracket and trims leading whitespace

Edge Cases Handled

  • Titles without square brackets: returned unchanged
  • Titles with unmatched brackets: returned unchanged (no ] found)
  • Empty titles: returned unchanged
  • Titles with multiple bracket pairs: only the first prefix is removed

Testing

  • Build verification: All changes compile successfully with no errors or warnings
  • Code analysis: Fixed CA1865 warning by using StartsWith('[') instead of StartsWith("[", StringComparison.Ordinal)

Files Modified

  1. src/services/Elastic.Documentation.Services/Changelog/ChangelogInput.cs
  2. src/tooling/docs-builder/Commands/ChangelogCommand.cs
  3. src/services/Elastic.Documentation.Services/ChangelogService.cs
  4. docs/cli/release/changelog-add.md
  5. docs/contribute/changelog.md

Backward Compatibility

This change is fully backward compatible:

  • The option defaults to false if not specified
  • Existing workflows continue to work without modification
  • Only affects behavior when explicitly enabled with --strip-title-prefix

Generative AI disclosure

  1. Did you use a generative AI (GenAI) tool to assist in creating this contribution?
  • Yes
  • No
  1. If you answered "Yes" to the previous question, please specify the tool(s) and model(s) used (e.g., Google Gemini, OpenAI ChatGPT-4, etc.).

Tool(s) and model(s) used: composer-1

@github-actions
Copy link

🔍 Preview links for changed docs

@lcawl lcawl marked this pull request as ready for review January 15, 2026 18:46
@lcawl lcawl requested review from a team as code owners January 15, 2026 18:46
@lcawl lcawl requested a review from Mpdreamz January 15, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants