Skip to content

Autolink references in deprecation messages - #2274

Open
rhcarvalho wants to merge 2 commits into
elixir-lang:mainfrom
praialabs:autolink-deprecated
Open

rhcarvalho wants to merge 2 commits into
elixir-lang:mainfrom
praialabs:autolink-deprecated

Conversation

@rhcarvalho

Copy link
Copy Markdown
Contributor

I was reading about the upcoming deprecation of String.to_atom/1 in Elixir 1.21, and noticed that references in the documentation did not link to the recommended alternative.

At first I thought it might have been an oversight in the Elixir documentation, but then realized that it is actually a deliberate limitation of ExDoc.

After doing some research, I found that the documentation storage and format is described by EEP 48. The Metadata.deprecated field is intentionally a plain text string, not Markdown.

Prior discussions on the topic:

With the constraint of not introducing new syntax, not expecting any changes to how documentation and deprecation messages are written, and avoiding ambiguous cases that could lead to false positives, I found that we can improve the experience for the common case of referring to another function via MFA or FA pattern (which is the dominant pattern in the elixir-lang/elixir repo).

Before

https://elixir.hexdocs.pm/main/String.html#to_atom/1

image

After

image

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

For unambiguous references in Elixir code (functions/macros with arity),
turns them into links to improve the user experience when consuming docs
in HTML and EPUB.

For Erlang code, preserve the existing behavior of simply escaping the
message to avoid HTML injection.

Assisted-by: Antigravity:Gemini 3.8 Flash
@rhcarvalho

Copy link
Copy Markdown
Contributor Author

Rebased to fix conflict after removal of pre-existing dead code via #2275, no changes.

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

(Aware and working on the test failure, an order-dependent flaky test caused by ExDoc.Refs.insert with stdlib modules like String)

ExDoc.Refs.insert affects global state (ETS), and thus we should avoid
referencing modules in the Elixir standard library, and avoid reusing
module names across tests.

Add assertion to cover `action!/1`-shaped references.
Group together assertions related to URL-like references (passthrough).
@rhcarvalho

Copy link
Copy Markdown
Contributor Author

The test failure on Elixir 1.15 was related to a mistake I made in the new tests. It could have failed in any Elixir version, as it was related to scheduling order and who populated an ETS table first.

Pushed a new commit with a fix. All test-related modules start with AutolinkTest and each test use independent module names, preventing collision.

Note this was a change only to tests we are adding in this PR. No changes to existing tests in main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant