@@ -10,7 +10,6 @@ defmodule ExDoc.Language.Elixir do
10
10
@ spec module_data ( atom , any , any ) ::
11
11
false
12
12
| % {
13
- callback_types: [ :callback , ... ] ,
14
13
docs: any ,
15
14
id: binary ,
16
15
language: ExDoc.Language.Erlang ,
@@ -48,6 +47,7 @@ defmodule ExDoc.Language.Elixir do
48
47
49
48
% {
50
49
module: module ,
50
+ default_groups: ~w( Types Callbacks Functions) ,
51
51
docs: docs_chunk ,
52
52
language: __MODULE__ ,
53
53
id: inspect ( module ) ,
@@ -56,7 +56,6 @@ defmodule ExDoc.Language.Elixir do
56
56
source_line: source_line ,
57
57
source_file: source_file ,
58
58
source_basedir: source_basedir ,
59
- callback_types: [ :callback , :macrocallback ] ,
60
59
nesting_info: nesting_info ( title , config . nest_modules_by_prefix ) ,
61
60
private: % {
62
61
abst_code: abst_code ,
@@ -78,17 +77,30 @@ defmodule ExDoc.Language.Elixir do
78
77
end
79
78
80
79
@ impl true
81
- def function_data ( entry , module_data ) do
82
- { { kind , name , arity } , anno , _signature , _doc_content , metadata } = entry
80
+ def doc_data ( entry , % { type: type } = module_data ) do
81
+ case entry do
82
+ { _key , _anno , _sig , :hidden , _metadata } ->
83
+ false
83
84
84
- if doc? ( entry , module_data . type ) do
85
- function_data ( kind , name , arity , anno , metadata , module_data )
86
- else
87
- false
85
+ { { _kind , name , _arity } , _anno , _sig , _doc , _metadata }
86
+ when name in [ :impl_for , :impl_for! ] and type == :protocol ->
87
+ false
88
+
89
+ { { kind , _ , _ } , _anon , _sig , _doc , _metadata } when kind in [ :function , :macro ] ->
90
+ function_data ( entry , module_data )
91
+
92
+ { { kind , _ , _ } , _anon , _sig , _doc , _metadata }
93
+ when kind in [ :callback , :macrocallback ] and type != :protocol ->
94
+ callback_data ( entry , module_data )
95
+
96
+ _ ->
97
+ false
88
98
end
89
99
end
90
100
91
- defp function_data ( kind , name , arity , anno , metadata , module_data ) do
101
+ defp function_data ( entry , module_data ) do
102
+ { { kind , name , arity } , anno , signature , _doc_content , metadata } = entry
103
+
92
104
extra_annotations =
93
105
case { kind , name , arity } do
94
106
{ :macro , _ , _ } -> [ "macro" ]
@@ -99,35 +111,23 @@ defmodule ExDoc.Language.Elixir do
99
111
actual_def = actual_def ( name , arity , kind )
100
112
101
113
% {
114
+ id_key: "" ,
115
+ default_group: "Functions" ,
102
116
doc_fallback: fn ->
103
117
impl = Map . fetch ( module_data . private . impls , actual_def )
104
118
105
119
callback_doc_ast ( name , arity , impl ) ||
106
120
delegate_doc_ast ( metadata [ :delegate_to ] )
107
121
end ,
108
122
extra_annotations: extra_annotations ,
123
+ signature: signature ,
124
+ source_file: nil ,
109
125
source_line: find_function_line ( module_data , actual_def ) || Source . anno_line ( anno ) ,
110
126
specs: specs ( kind , name , actual_def , module_data )
111
127
}
112
128
end
113
129
114
- # We are only interested in functions and macros for now
115
- defp doc? ( { { kind , _ , _ } , _ , _ , _ , _ } , _ ) when kind not in [ :function , :macro ] do
116
- false
117
- end
118
-
119
- # Skip impl_for and impl_for! for protocols
120
- defp doc? ( { { _ , name , _ } , _ , _ , _ , _ } , :protocol ) when name in [ :impl_for , :impl_for! ] do
121
- false
122
- end
123
-
124
- # If content is a map, then it is ok.
125
- defp doc? ( { _ , _ , _ , doc , _ } , _ ) do
126
- doc != :hidden
127
- end
128
-
129
- @ impl true
130
- def callback_data ( entry , module_data ) do
130
+ defp callback_data ( entry , module_data ) do
131
131
{ { kind , name , arity } , anno , _signature , _doc , _metadata } = entry
132
132
actual_def = actual_def ( name , arity , kind )
133
133
@@ -149,16 +149,18 @@ defmodule ExDoc.Language.Elixir do
149
149
end
150
150
151
151
line = Source . anno_line ( anno )
152
-
153
152
quoted = Enum . map ( specs , & Code.Typespec . spec_to_quoted ( name , & 1 ) )
154
153
signature = [ get_typespec_signature ( hd ( quoted ) , arity ) ]
155
154
156
155
% {
157
- source_line: line ,
158
- source_file: nil ,
156
+ id_key: "c:" ,
157
+ default_group: "Callbacks" ,
158
+ doc_fallback: fn -> nil end ,
159
+ extra_annotations: extra_annotations ,
159
160
signature: signature ,
160
- specs: quoted ,
161
- extra_annotations: extra_annotations
161
+ source_file: nil ,
162
+ source_line: line ,
163
+ specs: quoted
162
164
}
163
165
end
164
166
@@ -182,6 +184,7 @@ defmodule ExDoc.Language.Elixir do
182
184
183
185
% {
184
186
type: type ,
187
+ doc_fallback: fn -> nil end ,
185
188
source_line: line ,
186
189
source_file: source ,
187
190
spec: quoted ,
@@ -282,7 +285,7 @@ defmodule ExDoc.Language.Elixir do
282
285
{ :local , :.. }
283
286
284
287
[ "//" , "" , "" ] ->
285
- { :local , :" ..//" }
288
+ { :local , :..// }
286
289
287
290
[ "" , "" ] ->
288
291
{ :local , :. }
0 commit comments