@@ -64,19 +64,19 @@ defmodule ExDoc.Language.Erlang do
64
64
65
65
@ impl true
66
66
def function_data ( entry , module_data ) do
67
- { { kind , name , arity } , _anno , _signature , doc_content , _metadata } = entry
67
+ { { kind , name , arity } , _anno , _signature , doc_content , metadata } = entry
68
68
69
69
# TODO: Edoc on Erlang/OTP24.1+ includes private functions in
70
70
# the chunk, so we manually yank them out for now.
71
71
if kind == :function and doc_content != :hidden and
72
72
function_exported? ( module_data . module , name , arity ) do
73
- function_data ( name , arity , doc_content , module_data )
73
+ function_data ( name , arity , doc_content , module_data , metadata )
74
74
else
75
75
:skip
76
76
end
77
77
end
78
78
79
- defp function_data ( name , arity , _doc_content , module_data ) do
79
+ defp function_data ( name , arity , _doc_content , module_data , metadata ) do
80
80
specs =
81
81
case Map . fetch ( module_data . private . specs , { name , arity } ) do
82
82
{ :ok , specs } ->
@@ -93,7 +93,26 @@ defmodule ExDoc.Language.Erlang do
93
93
end
94
94
95
95
% {
96
- doc_fallback: fn -> nil end ,
96
+ doc_fallback: fn ->
97
+ case metadata [ :equiv ] do
98
+ nil ->
99
+ nil
100
+
101
+ equiv when is_binary ( equiv ) ->
102
+ ## We try to parse the equiv in order to link to the target
103
+ with { :ok , toks , _ } <- :erl_scan . string ( :unicode . characters_to_list ( equiv <> "." ) ) ,
104
+ { :ok , [ { :call , _ , { :atom , _ , func } , args } ] } <- :erl_parse . parse_exprs ( toks ) do
105
+ "Equivalent to [`#{ equiv } `](`#{ func } /#{ length ( args ) } `)"
106
+ else
107
+ _ -> "Equivalent to `#{ equiv } `"
108
+ end
109
+ |> ExDoc.DocAST . parse! ( "text/markdown" )
110
+
111
+ equiv ->
112
+ IO . warn ( "invalid equiv: #{ inspect ( equiv ) } " , [ ] )
113
+ nil
114
+ end
115
+ end ,
97
116
extra_annotations: [ ] ,
98
117
line: nil ,
99
118
specs: specs
0 commit comments