@@ -93,6 +93,9 @@ defmodule ExDoc.Language.Elixir do
9393 when kind in [ :callback , :macrocallback ] and type != :protocol ->
9494 callback_data ( entry , module_data )
9595
96+ { { :type , _ , _ } , _anon , _sig , _doc , _metadata } ->
97+ type_data ( entry , module_data )
98+
9699 _ ->
97100 false
98101 end
@@ -115,15 +118,14 @@ defmodule ExDoc.Language.Elixir do
115118 default_group: "Functions" ,
116119 doc_fallback: fn ->
117120 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 ] )
121122 end ,
122123 extra_annotations: extra_annotations ,
123124 signature: signature ,
124125 source_file: nil ,
125126 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
127129 }
128130 end
129131
@@ -160,7 +162,8 @@ defmodule ExDoc.Language.Elixir do
160162 signature: signature ,
161163 source_file: nil ,
162164 source_line: line ,
163- specs: quoted
165+ specs: quoted ,
166+ type: kind
164167 }
165168 end
166169
@@ -172,8 +175,7 @@ defmodule ExDoc.Language.Elixir do
172175 { :type , num , :fun , [ { :type , num , :product , rest_args } | rest ] }
173176 end
174177
175- @ impl true
176- def type_data ( entry , module_data ) do
178+ defp type_data ( entry , module_data ) do
177179 { { _kind , name , arity } , _anno , _signature , _doc , _metadata } = entry
178180
179181 % { type: type , spec: spec , source_file: source , source_line: line } =
@@ -183,13 +185,15 @@ defmodule ExDoc.Language.Elixir do
183185 signature = [ get_typespec_signature ( quoted , arity ) ]
184186
185187 % {
186- type: type ,
188+ id_key: "t:" ,
189+ default_group: "Types" ,
187190 doc_fallback: fn -> nil end ,
188- source_line: line ,
191+ extra_annotations: [ ] ,
189192 source_file: source ,
190- spec: quoted ,
193+ source_line: line ,
191194 signature: signature ,
192- extra_annotations: [ ]
195+ specs: [ quoted ] ,
196+ type: type
193197 }
194198 end
195199
@@ -398,10 +402,12 @@ defmodule ExDoc.Language.Elixir do
398402 end
399403
400404 @ 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"
405411
406412 ## Module Helpers
407413
0 commit comments