Fix changelog directive and render command subsections with publishing rules#2752
Merged
Fix changelog directive and render command subsections with publishing rules#2752
Conversation
tests/Elastic.Documentation.Configuration.Tests/ReleaseNotes/PublishBlockerExtensionsTests.cs
Fixed
Show fixed
Hide fixed
🔍 Preview links for changed docs |
tests/Elastic.Documentation.Configuration.Tests/ReleaseNotes/PublishBlockerExtensionsTests.cs
Dismissed
Show dismissed
Hide dismissed
Mpdreamz
approved these changes
Feb 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2751
The following summary comes from the AI plan that was implemented to address that issue.
Problem
GetComponentalways returnsentry.Areas[0], regardless of whether that area is excluded or not the preferred area under the active publish rules. This means entries can appear under an area that contradicts the configured rules.Desired behavior
Given
areas: [Search, Monitoring, Security]and a publish rule:include_areas: [Security, Monitoring]→ group underMonitoring(first area that is in the include list)exclude_areas: [Search]→ group underMonitoring(first area not in the exclude list)Search(current behavior, unchanged)Architecture overview
flowchart TD entry["ChangelogEntry\n(areas: [Search, Monitoring, Security])"] blocker["PublishBlocker\n(Areas, AreasMode)"] getPreferred["GetPreferredArea(entry, blocker)"] groupBy["GroupBy key"] entry --> getPreferred blocker --> getPreferred getPreferred --> groupByChanges
1.
src/Elastic.Documentation/ReleaseNotes/PublishBlockerExtensions.csAdd a new
GetPreferredAreaextension method. This is the core logic shared by both the directive and the CLI renderer:2.
src/Elastic.Markdown/Myst/Directives/Changelog/ChangelogInlineRenderer.csThe directive already has a single resolved
block.PublishBlocker— thread it through the call chain:GetComponent(ChangelogEntry entry)→GetComponent(ChangelogEntry entry, PublishBlocker? publishBlocker), which delegates topublishBlocker.GetPreferredArea(entry)RenderEntriesByArea(...)→ addPublishBlocker? publishBlockerparameter, pass toGetComponentRenderDetailedEntries(...)→ addPublishBlocker? publishBlockerparameter, pass toGetComponent(used whengroupBySubtype == false)GenerateMarkdown(...)→ addPublishBlocker? publishBlockerparameter, pass to both render methods aboveRenderSingleBundle(...)→ already haspublishBlocker, pass toGenerateMarkdown3.
src/services/Elastic.Changelog/Rendering/ChangelogRenderUtilities.csGetComponent(ChangelogEntry entry)withGetComponent(ChangelogEntry entry, ChangelogRenderContext? context = null): whencontextis null, returnentry.Areas?[0] ?? ""(current behavior); whencontextis provided, resolve the per-entry blocker via privateGetPublishBlockerForEntry(entry, context)and returnblocker.GetPreferredArea(entry). KeepGetPublishBlockerForProductprivate.4. CLI renderers (all use
GetComponentfor area grouping)Update all call sites from
GroupBy(ChangelogRenderUtilities.GetComponent)toGroupBy(e => ChangelogRenderUtilities.GetComponent(e, context)):IndexMarkdownRenderer.csHighlightsMarkdownRenderer.cs,HighlightsAsciidocRenderer.csKnownIssuesMarkdownRenderer.cs,KnownIssuesAsciidocRenderer.csDeprecationsMarkdownRenderer.cs,DeprecationsAsciidocRenderer.csBreakingChangesMarkdownRenderer.cs,BreakingChangesAsciidocRenderer.csEntriesByAreaAsciidocRenderer.cs5. Tests
Add a new test class in
tests/Elastic.Markdown.Tests/Directives/ChangelogSubsectionsTests.cs(or a companion file) covering:include_areasrule → groups under first included areaexclude_areasrule → groups under first non-excluded areaAreas[0]behavior)Areas[0]Add matching tests in
tests/Elastic.Documentation.Configuration.Tests/ReleaseNotes/PublishBlockerExtensionsTests.csfor the newGetPreferredAreamethod directly.6. Verification
After implementation:
dotnet buildto ensure no compilation failures./build.sh unit-testto validate testsdotnet formatif the output contains formatting issues7. Documentation
docs/syntax/changelog.md— expand the:subsections:option description (currently a single sentence) to explain area selectiondocs/contribute/changelog.md— add a note after thepublishrules example near theinclude_areas/exclude_areascoverage (~line 419) to explain that these rules also affect subsection display grouping when:subsections:or--subsectionsis enabled.docs/cli/release/changelog-render.md— expand the--subsectionsoption description to also note that when publish rules withinclude_areasorexclude_areasare configured, the area used for grouping is the first area from the entry's list that aligns with those rules (first included area, or first non-excluded area).Screenshots
These screenshots show the behaviour with the content from elastic/docs-content#4880 which has the following info in the changelog configuration file:
Before
You can see some other areas appearing in the output, in particular for changelogs that had multiple areas:
After
The changelogs now show up in the desired areas:
Generative AI disclosure
Tool(s) and model(s) used: composer-1.5, claude-4.6-sonnet-medium