@@ -33,14 +33,17 @@ defmodule ExDoc.Retriever.ErlangTest do
33
33
erlc ( c , :mod , ~S"""
34
34
-module(mod).
35
35
-moduledoc("mod docs.").
36
- -export([function1/0, function2/0]).
36
+ -export([function1/0, function2/1, equiv_function2/ 0]).
37
37
38
38
-doc("function1/0 docs.").
39
39
-spec function1() -> atom().
40
40
function1() -> ok.
41
41
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}]).
44
47
""" )
45
48
46
49
{ [ mod ] , [ ] } = Retriever . docs_from_modules ( [ :mod ] , % ExDoc.Config { } )
@@ -49,7 +52,7 @@ defmodule ExDoc.Retriever.ErlangTest do
49
52
deprecated: nil ,
50
53
moduledoc_line: 2 ,
51
54
moduledoc_file: moduledoc_file ,
52
- docs: [ function1 , function2 ] ,
55
+ docs: [ equiv_function2 , function1 , function2 ] ,
53
56
docs_groups: [ :Types , :Callbacks , :Functions ] ,
54
57
group: nil ,
55
58
id: "mod" ,
@@ -93,11 +96,18 @@ defmodule ExDoc.Retriever.ErlangTest do
93
96
"function1() -> <a href=\" https://www.erlang.org/doc/man/erlang.html#type-atom\" >atom</a>()."
94
97
95
98
% ExDoc.FunctionNode {
96
- id: "function2/0 "
99
+ id: "function2/1 "
97
100
} = function2
98
101
99
- assert DocAST . to_string ( function2 . doc ) =~ "function2/0 docs."
102
+ assert DocAST . to_string ( function2 . doc ) =~ "function2/1 docs."
100
103
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\} \] \) .*\. '
101
111
end
102
112
103
113
test "module included files" , c do
@@ -222,6 +232,9 @@ defmodule ExDoc.Retriever.ErlangTest do
222
232
-doc("callback1/0 docs.").
223
233
-callback callback1() -> atom().
224
234
235
+ -doc #{ equiv => callback1() }.
236
+ -callback equiv_callback1() -> atom().
237
+
225
238
-doc("optional_callback1/0 docs.").
226
239
-callback optional_callback1() -> atom().
227
240
@@ -230,7 +243,7 @@ defmodule ExDoc.Retriever.ErlangTest do
230
243
231
244
config = % ExDoc.Config { source_url_pattern: "%{path}:%{line}" }
232
245
{ [ mod ] , [ ] } = Retriever . docs_from_modules ( [ :mod ] , config )
233
- [ callback1 , optional_callback1 ] = mod . docs
246
+ [ callback1 , equiv_callback1 , optional_callback1 ] = mod . docs
234
247
235
248
assert callback1 . id == "c:callback1/0"
236
249
assert callback1 . type == :callback
@@ -242,6 +255,16 @@ defmodule ExDoc.Retriever.ErlangTest do
242
255
assert Erlang . autolink_spec ( hd ( callback1 . specs ) , current_kfa: { :callback , :callback1 , 0 } ) ==
243
256
"callback1() -> <a href=\" https://www.erlang.org/doc/man/erlang.html#type-atom\" >atom</a>()."
244
257
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
+
245
268
assert optional_callback1 . id == "c:optional_callback1/0"
246
269
assert optional_callback1 . type == :callback
247
270
assert optional_callback1 . group == :Callbacks
@@ -251,18 +274,21 @@ defmodule ExDoc.Retriever.ErlangTest do
251
274
test "types" , c do
252
275
erlc ( c , :mod , ~S"""
253
276
-module(mod).
254
- -export_type([type1/0, opaque1/0]).
277
+ -export_type([type1/0, equiv_type1/0, opaque1/0]).
255
278
256
279
-doc("type1/0 docs.").
257
280
-type type1() :: atom().
258
281
282
+ -doc #{ equiv => type1/1 }.
283
+ -type equiv_type1() :: atom().
284
+
259
285
-doc("opaque1/0 docs.").
260
286
-opaque opaque1() :: atom().
261
287
""" )
262
288
263
289
config = % ExDoc.Config { source_url_pattern: "%{path}:%{line}" }
264
290
{ [ mod ] , [ ] } = Retriever . docs_from_modules ( [ :mod ] , config )
265
- [ opaque1 , type1 ] = mod . typespecs
291
+ [ equiv_type1 , opaque1 , type1 ] = mod . typespecs
266
292
267
293
assert opaque1 . id == "t:opaque1/0"
268
294
assert opaque1 . type == :opaque
@@ -281,6 +307,12 @@ defmodule ExDoc.Retriever.ErlangTest do
281
307
282
308
assert type1 . spec |> Erlang . autolink_spec ( current_kfa: { :type , :type1 , 0 } ) ==
283
309
"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.*\. '
284
316
end
285
317
286
318
test "records" , c do
0 commit comments