@@ -93,6 +93,9 @@ defmodule ExDoc.Language.Elixir do
93
93
when kind in [ :callback , :macrocallback ] and type != :protocol ->
94
94
callback_data ( entry , module_data )
95
95
96
+ { { :type , _ , _ } , _anon , _sig , _doc , _metadata } ->
97
+ type_data ( entry , module_data )
98
+
96
99
_ ->
97
100
false
98
101
end
@@ -115,15 +118,14 @@ defmodule ExDoc.Language.Elixir do
115
118
default_group: "Functions" ,
116
119
doc_fallback: fn ->
117
120
impl = Map . fetch ( module_data . private . impls , actual_def )
118
-
119
- callback_doc_ast ( name , arity , impl ) ||
120
- delegate_doc_ast ( metadata [ :delegate_to ] )
121
+ callback_doc_ast ( name , arity , impl ) || delegate_doc_ast ( metadata [ :delegate_to ] )
121
122
end ,
122
123
extra_annotations: extra_annotations ,
123
124
signature: signature ,
124
125
source_file: nil ,
125
126
source_line: find_function_line ( module_data , actual_def ) || Source . anno_line ( anno ) ,
126
- specs: specs ( kind , name , actual_def , module_data )
127
+ specs: specs ( kind , name , actual_def , module_data ) ,
128
+ type: kind
127
129
}
128
130
end
129
131
@@ -160,7 +162,8 @@ defmodule ExDoc.Language.Elixir do
160
162
signature: signature ,
161
163
source_file: nil ,
162
164
source_line: line ,
163
- specs: quoted
165
+ specs: quoted ,
166
+ type: kind
164
167
}
165
168
end
166
169
@@ -172,8 +175,7 @@ defmodule ExDoc.Language.Elixir do
172
175
{ :type , num , :fun , [ { :type , num , :product , rest_args } | rest ] }
173
176
end
174
177
175
- @ impl true
176
- def type_data ( entry , module_data ) do
178
+ defp type_data ( entry , module_data ) do
177
179
{ { _kind , name , arity } , _anno , _signature , _doc , _metadata } = entry
178
180
179
181
% { type: type , spec: spec , source_file: source , source_line: line } =
@@ -183,13 +185,15 @@ defmodule ExDoc.Language.Elixir do
183
185
signature = [ get_typespec_signature ( quoted , arity ) ]
184
186
185
187
% {
186
- type: type ,
188
+ id_key: "t:" ,
189
+ default_group: "Types" ,
187
190
doc_fallback: fn -> nil end ,
188
- source_line: line ,
191
+ extra_annotations: [ ] ,
189
192
source_file: source ,
190
- spec: quoted ,
193
+ source_line: line ,
191
194
signature: signature ,
192
- extra_annotations: [ ]
195
+ specs: [ quoted ] ,
196
+ type: type
193
197
}
194
198
end
195
199
@@ -398,10 +402,12 @@ defmodule ExDoc.Language.Elixir do
398
402
end
399
403
400
404
@ impl true
401
- def format_spec_attribute ( % ExDoc.TypeNode { type: type } ) , do: "@#{ type } "
402
- def format_spec_attribute ( % ExDoc.FunctionNode { type: :callback } ) , do: "@callback"
403
- def format_spec_attribute ( % ExDoc.FunctionNode { type: :macrocallback } ) , do: "@macrocallback"
404
- def format_spec_attribute ( % ExDoc.FunctionNode { } ) , do: "@spec"
405
+ def format_spec_attribute ( % { type: :type } ) , do: "@type"
406
+ def format_spec_attribute ( % { type: :opaque } ) , do: "@opaque"
407
+ def format_spec_attribute ( % { type: :nominal } ) , do: "@nominal"
408
+ def format_spec_attribute ( % { type: :callback } ) , do: "@callback"
409
+ def format_spec_attribute ( % { type: :macrocallback } ) , do: "@macrocallback"
410
+ def format_spec_attribute ( % { } ) , do: "@spec"
405
411
406
412
## Module Helpers
407
413
0 commit comments