diff --git a/lib/ex_doc/autolink.ex b/lib/ex_doc/autolink.ex
index 389f1f8de..f5af58bd2 100644
--- a/lib/ex_doc/autolink.ex
+++ b/lib/ex_doc/autolink.ex
@@ -430,7 +430,7 @@ defmodule ExDoc.Autolink do
case {kind, visibility} do
{_kind, :public} ->
- fragment(tool(module, config), kind, name, arity)
+ fragment(kind, name, arity)
{:function, _visibility} ->
case config.language.try_autoimported_function(name, arity, mode, config, original_text) do
@@ -464,22 +464,14 @@ defmodule ExDoc.Autolink do
end
end
- def fragment(tool, kind, nil, arity) do
- fragment(tool, kind, "nil", arity)
+ def fragment(kind, nil, arity) do
+ fragment(kind, "nil", arity)
end
- def fragment(:ex_doc, kind, name, arity) do
+ def fragment(kind, name, arity) do
"#" <> prefix(kind) <> "#{encode_fragment_name(name)}/#{arity}"
end
- def fragment(:otp, kind, name, arity) do
- case kind do
- :function -> "##{encode_fragment_name(name)}-#{arity}"
- :callback -> "#Module:#{encode_fragment_name(name)}-#{arity}"
- :type -> "#type-#{encode_fragment_name(name)}"
- end
- end
-
defp encode_fragment_name(name) when is_atom(name) do
encode_fragment_name(Atom.to_string(name))
end
@@ -503,10 +495,10 @@ defmodule ExDoc.Autolink do
tool = tool(module, config)
if same_module? do
- fragment(tool, kind, name, arity)
+ fragment(kind, name, arity)
else
url = string_app_module_url(original_text, tool, module, nil, config)
- url && url <> fragment(tool, kind, name, arity)
+ url && url <> fragment(kind, name, arity)
end
{:regular_link, module_visibility, :undefined}
diff --git a/lib/ex_doc/language/erlang.ex b/lib/ex_doc/language/erlang.ex
index 6302e4b9e..4e4342b61 100644
--- a/lib/ex_doc/language/erlang.ex
+++ b/lib/ex_doc/language/erlang.ex
@@ -431,12 +431,12 @@ defmodule ExDoc.Language.Erlang do
end
defp final_url({kind, name, arity}, _config) do
- Autolink.fragment(:ex_doc, kind, name, arity)
+ Autolink.fragment(kind, name, arity)
end
defp final_url({kind, module, name, arity}, config) do
tool = Autolink.tool(module, config)
- Autolink.app_module_url(tool, module, Autolink.fragment(tool, kind, name, arity), config)
+ Autolink.app_module_url(tool, module, Autolink.fragment(kind, name, arity), config)
end
@impl true
diff --git a/test/ex_doc/formatter/html/erlang_test.exs b/test/ex_doc/formatter/html/erlang_test.exs
index df5d883c4..5ef9d6aaf 100644
--- a/test/ex_doc/formatter/html/erlang_test.exs
+++ b/test/ex_doc/formatter/html/erlang_test.exs
@@ -36,10 +36,10 @@ defmodule ExDoc.Formatter.HTML.ErlangTest do
~s|-spec foo(t()) -> t().|
assert html =~
- ~s|-type t() :: atom().|
+ ~s|-type t() :: atom().|
assert html =~
- ~s|-type t2() :: #rec{k1 :: uri_string:uri_string(), k2 :: uri_string:uri_string() \| undefined}.|
+ ~s|-type t2() :: #rec{k1 :: uri_string:uri_string(), k2 :: uri_string:uri_string() \| undefined}.|
end
defp generate_docs(c) do
diff --git a/test/ex_doc/language/elixir_test.exs b/test/ex_doc/language/elixir_test.exs
index e1789d3c7..7685d871c 100644
--- a/test/ex_doc/language/elixir_test.exs
+++ b/test/ex_doc/language/elixir_test.exs
@@ -99,7 +99,7 @@ defmodule ExDoc.Language.ElixirTest do
test "erlang stdlib function" do
assert autolink_doc("`:lists.all/2`") ==
- ~s|:lists.all/2
|
+ ~s|:lists.all/2
|
end
test "local function" do
@@ -150,7 +150,7 @@ defmodule ExDoc.Language.ElixirTest do
test "erlang callback" do
assert autolink_doc("`c::gen_server.handle_call/3`") ==
- ~s|:gen_server.handle_call/3
|
+ ~s|:gen_server.handle_call/3
|
end
test "elixir type" do
@@ -171,7 +171,7 @@ defmodule ExDoc.Language.ElixirTest do
test "erlang type" do
assert autolink_doc("`t::array.array/0`") ==
- ~s|:array.array/0
|
+ ~s|:array.array/0
|
end
test "special forms" do
@@ -207,7 +207,7 @@ defmodule ExDoc.Language.ElixirTest do
~s|custom text|
assert autolink_doc("[custom text](`:lists.all/2`)") ==
- ~s|custom text|
+ ~s|custom text|
end
test "mix task" do
@@ -450,7 +450,7 @@ defmodule ExDoc.Language.ElixirTest do
test "Erlang stdlib types" do
assert autolink_spec(quote(do: t() :: :sets.set())) ==
- ~s[t() :: :sets.set()]
+ ~s[t() :: :sets.set()]
end
test "escape special HTML characters" do
diff --git a/test/ex_doc/language/erlang_test.exs b/test/ex_doc/language/erlang_test.exs
index f30ee7b5c..888bdf1f8 100644
--- a/test/ex_doc/language/erlang_test.exs
+++ b/test/ex_doc/language/erlang_test.exs
@@ -84,7 +84,7 @@ defmodule ExDoc.Language.ErlangTest do
test "OTP function", c do
assert autolink_edoc("{@link array:new/0}", c) ==
- ~s|array:new/0
|
+ ~s|array:new/0
|
end
test "OTP function when generating OTP docs", c do
@@ -99,12 +99,12 @@ defmodule ExDoc.Language.ErlangTest do
test "ERTS function", c do
assert autolink_edoc("{@link zlib:gunzip/1}", c) ==
- ~s|zlib:gunzip/1
|
+ ~s|zlib:gunzip/1
|
end
test "app function", c do
assert autolink_edoc("{@link //stdlib/array:new/0}", c) ==
- ~s|array:new/0
|
+ ~s|array:new/0
|
end
test "external function", c do
@@ -124,12 +124,12 @@ defmodule ExDoc.Language.ErlangTest do
test "OTP type", c do
assert autolink_edoc("{@link array:array()}", c) ==
- ~s|array:array()
|
+ ~s|array:array()
|
end
test "app type", c do
assert autolink_edoc("{@link //stdlib/array:array()}", c) ==
- ~s|array:array()
|
+ ~s|array:array()
|
end
@myList (if :erlang.system_info(:otp_release) >= ~c"27" do
@@ -310,7 +310,7 @@ defmodule ExDoc.Language.ErlangTest do
test "function in module autoimport using slash", c do
assert autolink_doc("`node/0`", c) ==
- ~s|node/0
|
+ ~s|node/0
|
end
test "type in module autoimport", c do
@@ -320,7 +320,7 @@ defmodule ExDoc.Language.ErlangTest do
test "type in module autoimport using slash", c do
assert autolink_doc("`t:integer/0`", c) ==
- ~s|integer/0
|
+ ~s|integer/0
|
end
test "bad function in module code", c do
@@ -335,7 +335,7 @@ defmodule ExDoc.Language.ErlangTest do
test "linking to auto-imported nil works", c do
assert autolink_doc("[`[]`](`t:nil/0`)", c) ==
- ~s|[]
|
+ ~s|[]
|
end
test "linking to local nil works", c do
@@ -543,7 +543,7 @@ defmodule ExDoc.Language.ErlangTest do
test "OTP function", c do
assert autolink_extra("`lists:reverse/1`", c) ==
- ~s|lists:reverse/1
|
+ ~s|lists:reverse/1
|
end
test "type", c do
@@ -553,7 +553,7 @@ defmodule ExDoc.Language.ErlangTest do
test "OTP type", c do
assert autolink_extra("`t:array:array/0`", c) ==
- ~s|array:array/0
|
+ ~s|array:array/0
|
end
test "module", c do
@@ -684,9 +684,9 @@ defmodule ExDoc.Language.ErlangTest do
test "spec when fun is called record", c do
assert autolink_spec("-spec record(module()) -> [[{module(), atom()}]].", c) ==
- ~s|record(module())| <>
- ~s| -> [[{module(),| <>
- ~s| atom()}]].|
+ ~s|record(module())| <>
+ ~s| -> [[{module(),| <>
+ ~s| atom()}]].|
end
test "callback", c do
@@ -724,7 +724,7 @@ defmodule ExDoc.Language.ErlangTest do
~S"-spec foo() -> #{atom() := sets:set(integer()), float() => t()}.",
c
) ==
- ~S|foo() -> #{atom() := sets:set(integer()), float() => t()}.|
+ ~S|foo() -> #{atom() := sets:set(integer()), float() => t()}.|
end
test "vars", c do
@@ -744,12 +744,12 @@ defmodule ExDoc.Language.ErlangTest do
test "record - one field", c do
assert autolink_spec(~s"-spec foo() -> #x{x :: atom()} | t().", c) ==
- ~s[foo() -> #x{x :: atom()} | t().]
+ ~s[foo() -> #x{x :: atom()} | t().]
end
test "record - two fields", c do
assert autolink_spec(~s"-spec foo() -> #x{x :: atom(), y :: sets:set(integer())} | t().", c) ==
- ~s[foo() -> #x{x :: atom(), y :: sets:set(integer())} | t().]
+ ~s[foo() -> #x{x :: atom(), y :: sets:set(integer())} | t().]
end
test "record - two fields, known types", c do
@@ -789,12 +789,12 @@ defmodule ExDoc.Language.ErlangTest do
test "OTP type", c do
assert autolink_spec(~S"-spec foo() -> sets:set().", c) ==
- ~s|foo() -> sets:set().|
+ ~s|foo() -> sets:set().|
end
test "OTP private type", c do
assert autolink_spec(~S"-spec foo() -> array:array_indx().", c) ==
- ~s|foo() -> array:array_indx().|
+ ~s|foo() -> array:array_indx().|
end
test "skip typespec name", c do
@@ -820,7 +820,7 @@ defmodule ExDoc.Language.ErlangTest do
test "bad remote type", c do
assert warn(fn ->
assert autolink_spec(~S"-spec foo() -> bad:bad(atom()).", c, warnings: :send) ==
- ~s|foo() -> bad:bad(atom()).|
+ ~s|foo() -> bad:bad(atom()).|
end) =~ ~s|references type "bad:bad/1" but it is undefined or private|
end
end
diff --git a/test/ex_doc/retriever/erlang_test.exs b/test/ex_doc/retriever/erlang_test.exs
index 083bf6c43..6075d60ae 100644
--- a/test/ex_doc/retriever/erlang_test.exs
+++ b/test/ex_doc/retriever/erlang_test.exs
@@ -415,7 +415,7 @@ defmodule ExDoc.Retriever.ErlangTest do
assert DocAST.to_string(function1.doc) =~ "function1/0 docs."
assert Erlang.autolink_spec(hd(function1.specs), current_kfa: {:function, :function1, 0}) ==
- "function1() -> atom()."
+ "function1() -> atom()."
%ExDoc.FunctionNode{
id: "function2/0"
@@ -463,7 +463,7 @@ defmodule ExDoc.Retriever.ErlangTest do
assert Path.basename(callback1.source_url) == "mod.erl:4"
assert Erlang.autolink_spec(hd(callback1.specs), current_kfa: {:callback, :callback1, 0}) ==
- "callback1() -> atom()."
+ "callback1() -> atom()."
assert optional_callback1.id == "c:optional_callback1/0"
assert optional_callback1.type == :callback
@@ -501,7 +501,7 @@ defmodule ExDoc.Retriever.ErlangTest do
assert type1.doc |> DocAST.to_string() =~ "type1/0 docs."
assert type1.spec |> Erlang.autolink_spec(current_kfa: {:type, :type1, 0}) ==
- "type1() :: atom()."
+ "type1() :: atom()."
end
end
end