@@ -33,14 +33,17 @@ defmodule ExDoc.Retriever.ErlangTest do
3333 erlc ( c , :mod , ~S"""
3434 -module(mod).
3535 -moduledoc("mod docs.").
36- -export([function1/0, function2/0]).
36+ -export([function1/0, function2/1, equiv_function2/ 0]).
3737
3838 -doc("function1/0 docs.").
3939 -spec function1() -> atom().
4040 function1() -> ok.
4141
42- -doc("function2/0 docs.").
43- function2() -> ok.
42+ -doc("function2/1 docs.").
43+ function2(Opts) -> Opts.
44+
45+ -doc #{ equiv => function2([{test, args}]) }.
46+ equiv_function2() -> function2([{test, args}]).
4447 """ )
4548
4649 { [ mod ] , [ ] } = Retriever . docs_from_modules ( [ :mod ] , % ExDoc.Config { } )
@@ -49,7 +52,7 @@ defmodule ExDoc.Retriever.ErlangTest do
4952 deprecated: nil ,
5053 moduledoc_line: 2 ,
5154 moduledoc_file: moduledoc_file ,
52- docs: [ function1 , function2 ] ,
55+ docs: [ equiv_function2 , function1 , function2 ] ,
5356 docs_groups: [ :Types , :Callbacks , :Functions ] ,
5457 group: nil ,
5558 id: "mod" ,
@@ -93,11 +96,18 @@ defmodule ExDoc.Retriever.ErlangTest do
9396 "function1() -> <a href=\" https://www.erlang.org/doc/man/erlang.html#type-atom\" >atom</a>()."
9497
9598 % ExDoc.FunctionNode {
96- id: "function2/0 "
99+ id: "function2/1 "
97100 } = function2
98101
99- assert DocAST . to_string ( function2 . doc ) =~ "function2/0 docs."
102+ assert DocAST . to_string ( function2 . doc ) =~ "function2/1 docs."
100103 assert function2 . specs == [ ]
104+
105+ % ExDoc.FunctionNode {
106+ id: "equiv_function2/0"
107+ } = equiv_function2
108+
109+ assert DocAST . to_string ( equiv_function2 . doc ) =~
110+ ~r' Equivalent to <a href="`function2/1`"><code[^>]+>function2\( \[ \{ test, args\} \] \) .*\. '
101111 end
102112
103113 test "module included files" , c do
@@ -222,6 +232,9 @@ defmodule ExDoc.Retriever.ErlangTest do
222232 -doc("callback1/0 docs.").
223233 -callback callback1() -> atom().
224234
235+ -doc #{ equiv => callback1() }.
236+ -callback equiv_callback1() -> atom().
237+
225238 -doc("optional_callback1/0 docs.").
226239 -callback optional_callback1() -> atom().
227240
@@ -230,7 +243,7 @@ defmodule ExDoc.Retriever.ErlangTest do
230243
231244 config = % ExDoc.Config { source_url_pattern: "%{path}:%{line}" }
232245 { [ mod ] , [ ] } = Retriever . docs_from_modules ( [ :mod ] , config )
233- [ callback1 , optional_callback1 ] = mod . docs
246+ [ callback1 , equiv_callback1 , optional_callback1 ] = mod . docs
234247
235248 assert callback1 . id == "c:callback1/0"
236249 assert callback1 . type == :callback
@@ -242,6 +255,16 @@ defmodule ExDoc.Retriever.ErlangTest do
242255 assert Erlang . autolink_spec ( hd ( callback1 . specs ) , current_kfa: { :callback , :callback1 , 0 } ) ==
243256 "callback1() -> <a href=\" https://www.erlang.org/doc/man/erlang.html#type-atom\" >atom</a>()."
244257
258+ assert equiv_callback1 . id == "c:equiv_callback1/0"
259+ assert equiv_callback1 . type == :callback
260+ assert equiv_callback1 . annotations == [ ]
261+ assert equiv_callback1 . group == :Callbacks
262+
263+ assert DocAST . to_string ( equiv_callback1 . doc ) =~
264+ ~r' Equivalent to <a href="`c:callback1/0`"><code[^>]+>callback1().*\. '
265+
266+ assert Path . basename ( equiv_callback1 . source_url ) == "mod.erl:7"
267+
245268 assert optional_callback1 . id == "c:optional_callback1/0"
246269 assert optional_callback1 . type == :callback
247270 assert optional_callback1 . group == :Callbacks
@@ -251,18 +274,21 @@ defmodule ExDoc.Retriever.ErlangTest do
251274 test "types" , c do
252275 erlc ( c , :mod , ~S"""
253276 -module(mod).
254- -export_type([type1/0, opaque1/0]).
277+ -export_type([type1/0, equiv_type1/0, opaque1/0]).
255278
256279 -doc("type1/0 docs.").
257280 -type type1() :: atom().
258281
282+ -doc #{ equiv => type1/1 }.
283+ -type equiv_type1() :: atom().
284+
259285 -doc("opaque1/0 docs.").
260286 -opaque opaque1() :: atom().
261287 """ )
262288
263289 config = % ExDoc.Config { source_url_pattern: "%{path}:%{line}" }
264290 { [ mod ] , [ ] } = Retriever . docs_from_modules ( [ :mod ] , config )
265- [ opaque1 , type1 ] = mod . typespecs
291+ [ equiv_type1 , opaque1 , type1 ] = mod . typespecs
266292
267293 assert opaque1 . id == "t:opaque1/0"
268294 assert opaque1 . type == :opaque
@@ -281,6 +307,12 @@ defmodule ExDoc.Retriever.ErlangTest do
281307
282308 assert type1 . spec |> Erlang . autolink_spec ( current_kfa: { :type , :type1 , 0 } ) ==
283309 "type1() :: <a href=\" https://www.erlang.org/doc/man/erlang.html#type-atom\" >atom</a>()."
310+
311+ assert equiv_type1 . id == "t:equiv_type1/0"
312+ assert equiv_type1 . type == :type
313+ assert equiv_type1 . group == :Types
314+ assert equiv_type1 . signature == "equiv_type1()"
315+ assert equiv_type1 . doc |> DocAST . to_string ( ) =~ ~r' Equivalent to .*t:type1/1.*\. '
284316 end
285317
286318 test "records" , c do
0 commit comments