diff --git a/lib/ex_doc/formatter/html/autolink.ex b/lib/ex_doc/formatter/html/autolink.ex
index 7d6bded0d..fcb8416d1 100644
--- a/lib/ex_doc/formatter/html/autolink.ex
+++ b/lib/ex_doc/formatter/html/autolink.ex
@@ -337,7 +337,7 @@ defmodule ExDoc.Formatter.HTML.Autolink do
will get translated to the new href of the function.
"""
def local_doc(bin, locals, aliases \\ [], extension \\ ".html", lib_dirs \\ elixir_lib_dirs()) when is_binary(bin) do
- fun_re = Regex.source(~r{(([ct]:)?([a-z_]+[A-Za-z_\d]*[\\?\\!]?|[\{\}=&\\|\\.<>~*^@\\+\\%\\!-]+)/\d+)})
+ fun_re = Regex.source(~r{(([ct]:)?([a-z_]+[A-Za-z_\d]*[\\?\\!]?|[\{\}=&\\|\\.<>~*^@\\+\\%\\!-\/]+)/\d+)})
regex = ~r{(?~*^@\\+\\%\\!-]+)/\d+)})
+ fun_re = Regex.source(~r{([ct]:)?(#{module_re}(([a-z_]+[A-Za-z_\d]*[\\?\\!]?)|[\{\}=&\\|\\.<>~*^@\\+\\%\\!-\/]+)/\d+)})
@custom_re ~r{\[(.*?)\]\(`(#{fun_re})`\)}
@normal_re ~r{(? String.replace(~r{([^\.])\.}, "\\1 ") # this handles the case of the ".." function
@@ -498,6 +500,9 @@ defmodule ExDoc.Formatter.HTML.Autolink do
|> Enum.split(-1)
{"", Enum.join(mod, "."), hd(name), arity}
end
+ defp split_function([modules, "", arity]) do # handles "/" function
+ split_function([modules <> "/", arity])
+ end
@doc """
Create links to Erlang functions in code blocks.
diff --git a/test/ex_doc/formatter/html/autolink_test.exs b/test/ex_doc/formatter/html/autolink_test.exs
index c36fb9f3d..d3424e700 100644
--- a/test/ex_doc/formatter/html/autolink_test.exs
+++ b/test/ex_doc/formatter/html/autolink_test.exs
@@ -20,6 +20,7 @@ defmodule ExDoc.Formatter.HTML.AutolinkTest do
assert Autolink.local_doc("`funny_name\?/1` and `funny_name!/2`",
["funny_name\?/1", "funny_name!/2"]) ==
"[`funny_name\?/1`](#funny_name\?/1) and [`funny_name!/2`](#funny_name!/2)"
+ assert Autolink.local_doc("`//2`", ["//2"]) == "[`//2`](#//2)"
end
test "autolink to local callbacks" do
@@ -143,6 +144,9 @@ defmodule ExDoc.Formatter.HTML.AutolinkTest do
assert Autolink.elixir_functions("[`f`](`Foo.foo/1`), [`f`](`Foo.foo/1`)", ["Foo.foo/1"]) ==
"[`f`](Foo.html#foo/1), [`f`](Foo.html#foo/1)"
+
+ assert Autolink.elixir_functions("[`foo`](`Foo.//2`)", ["Foo.//2"]) ==
+ "[`foo`](Foo.html#//2)"
end
test "autolink functions to types in the project" do