Skip to content

Conversation

@SteffenDE
Copy link
Contributor

Idea by @Gazler

This is similar to ExDoc autolinking, but only works for the simple Elixir Module.function/arity format.

Before:
image

After:
image

@SteffenDE
Copy link
Contributor Author

Note that this requires a change in LiveView to actually emit that warning:

diff --git a/lib/phoenix_live_view/live_stream.ex b/lib/phoenix_live_view/live_stream.ex
index a88bef15..a445c56f 100644
--- a/lib/phoenix_live_view/live_stream.ex
+++ b/lib/phoenix_live_view/live_stream.ex
@@ -44,7 +44,7 @@ defmodule Phoenix.LiveView.LiveStream do
     raise ArgumentError, """
     expected stream :#{dom_prefix} to be a struct or map with :id key, got: #{inspect(other)}
 
-    If you would like to generate custom DOM id's based on other keys, use stream_configure/3 with the :dom_id option beforehand.
+    If you would like to generate custom DOM id's based on other keys, use `Phoenix.LiveView.stream_configure/3` with the :dom_id option beforehand.
     """
   end

defp maybe_format_function_reference(text), do: h(text)

defp function_reference?(text) do
Regex.match?(~r/^[A-Z][A-Za-z0-9_.]+\.[a-z][A-Za-z0-9_!?]*\/\d+$/, text)
Copy link
Member

Choose a reason for hiding this comment

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

We should probably merge this regex into the previous one, so we only parse ... that already match this form?

@josevalim josevalim merged commit 587f365 into elixir-plug:main Feb 27, 2025
2 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants