Raise on duplicate entries in files in :extras#2226
Merged
josevalim merged 3 commits intoelixir-lang:mainfrom Mar 23, 2026
Merged
Raise on duplicate entries in files in :extras#2226josevalim merged 3 commits intoelixir-lang:mainfrom
josevalim merged 3 commits intoelixir-lang:mainfrom
Conversation
Duplicate entries in :extras silently produced renamed output files
(e.g., readme-1.html and readme-2.html instead of readme.html),
potentially breaking internal links and links from previously
published versions.
Add validation that raises an ArgumentError when duplicate extras
are detected. Each entry is normalized to a {source, resolved_id}
pair, where resolved_id is the :filename option if provided, or the
ID derived from the source path. This means:
- Same file listed twice raises an error
- Same file with different non-:filename options (e.g., :title)
raises an error, since they produce the same output file
- Same file with different :filename options is allowed, since
they produce different output files
- Different files that derive the same ID are not flagged, as
disambiguate_id/2 already handles that case
Closes elixir-lang#2216
362d7ca to
2da0a93
Compare
|
📦 Docs artifacts are ready: https://github.com/elixir-lang/ex_doc/actions/runs/23454052862/artifacts/6065869185 |
josevalim
reviewed
Mar 23, 2026
lib/ex_doc/extras.ex
Outdated
| end | ||
|
|
||
| defp resolve_id(_input, filename) when is_binary(filename), do: filename | ||
| defp resolve_id(input, _filename), do: input |> filename_to_title() |> Utils.text_to_id() |
Member
There was a problem hiding this comment.
This is doing a bit of duplicate work compareed to build_extra. Can't we run this validation after we call build_extra, so we work with well-defined structs? Also, keep in mind that we have URL nodes (and those likely shouldn't be part of this validation).
Contributor
Author
There was a problem hiding this comment.
Done. That simplified things a WHOLE LOT. Thank you for the advice.
josevalim
reviewed
Mar 23, 2026
Duplicate detection logic logis has been simplified considerable. Move duplicate detection to run after build_extra/3 so it operates on ExtraNode structs instead of duplicating input-parsing logic. URLNodes are excluded from the check since they don't produce output files.
Contributor
Author
|
Suggestions applied. |
Member
|
💚 💙 💜 💛 ❤️ |
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.
Duplicate entries in :extras silently produced renamed output files (e.g., readme-1.html and readme-2.html instead of readme.html), potentially breaking internal links and links from previously published versions.
Add validation that raises an
ArgumentErrorwhen duplicate extras are detected. Each entry is normalized to a {source, resolved_id} pair, where resolved_id is the :filename option if provided, or the ID derived from the source path. This means:Closes #2216