Repository navigation
Autolink references in deprecation messages - #2274
rhcarvalho wants to merge 2 commits into
Conversation
|
📦 Docs artifacts are ready: https://github.com/elixir-lang/ex_doc/actions/runs/38260781787/artifacts/11752318389 |
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
98e47cd to
54aa4e5
Compare
|
Rebased to fix conflict after removal of pre-existing dead code via #2275, no changes. |
|
(Aware and working on the test failure, an order-dependent flaky test caused by |
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).
|
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 Note this was a change only to tests we are adding in this PR. No changes to existing tests in |
I was reading about the upcoming deprecation of
String.to_atom/1in 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.deprecatedfield is intentionally a plain text string, not Markdown.Prior discussions on the topic:
OP tried to use Markdown, José explained why not and suggested links can be part of the docstring instead:
In the case of
String.to_atom/1, it has been effectively renamed toString.to_unsafe_atom/1and the documentation moved there. Duplicating the documentation just to repeat the deprecation notice and add a link doesn't really improve the UX.Refused proposal for an additional autolink syntax (in docstrings):
[code]#1663With 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/elixirrepo).Before
https://elixir.hexdocs.pm/main/String.html#to_atom/1
After