Skip to content

Improve hexdoc handling of duplicate patterns when allow_duplicates is enabled#1007

Merged
Robotgiggle merged 2 commits into
mainfrom
fix-hexdoc-duplicate-patterns-again
May 10, 2026
Merged

Improve hexdoc handling of duplicate patterns when allow_duplicates is enabled#1007
Robotgiggle merged 2 commits into
mainfrom
fix-hexdoc-duplicate-patterns-again

Conversation

@object-Object
Copy link
Copy Markdown
Member

In #911, we added an allow_duplicates option to [extra.hexcasting] in hexdoc.toml. The goal of this feature was to allow users the option to prevent their hexdoc build from failing if they add a pattern with a duplicate signature (mainly for HexBug). However, the implementation in #911 is flawed: duplicate patterns are not added to self.patterns, resulting in a later validation failure for pages that use the duplicate patterns.

This PR changes the logic as follows:

  • Always raise an exception if a duplicate pattern ID is detected, since there's no valid reason for that to happen and we need pattern IDs to be unique in order to look up patterns for hexcasting:pattern pages
  • If a duplicate pattern signature is detected and allow_duplicates is enabled, still add the pattern to self.patterns so we can look it up when loading pattern pages
  • Improve the formatting of the error messages for duplicate patterns

These changes have been tested in HexBug and seem to work fine.

Copy link
Copy Markdown
Member

@Robotgiggle Robotgiggle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Robotgiggle Robotgiggle added this pull request to the merge queue May 10, 2026
Merged via the queue into main with commit 5f39cd9 May 10, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from 📋 Backlog to ✅ Done in Hex Casting May 10, 2026
@object-Object object-Object deleted the fix-hexdoc-duplicate-patterns-again branch May 24, 2026 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants