@@ -10,7 +10,6 @@ defmodule ExDoc.Language.Elixir do
1010 @ spec module_data ( atom , any , any ) ::
1111 false
1212 | % {
13- callback_types: [ :callback , ... ] ,
1413 docs: any ,
1514 id: binary ,
1615 language: ExDoc.Language.Erlang ,
@@ -48,6 +47,7 @@ defmodule ExDoc.Language.Elixir do
4847
4948 % {
5049 module: module ,
50+ default_groups: ~w( Types Callbacks Functions) ,
5151 docs: docs_chunk ,
5252 language: __MODULE__ ,
5353 id: inspect ( module ) ,
@@ -56,7 +56,6 @@ defmodule ExDoc.Language.Elixir do
5656 source_line: source_line ,
5757 source_file: source_file ,
5858 source_basedir: source_basedir ,
59- callback_types: [ :callback , :macrocallback ] ,
6059 nesting_info: nesting_info ( title , config . nest_modules_by_prefix ) ,
6160 private: % {
6261 abst_code: abst_code ,
@@ -78,17 +77,30 @@ defmodule ExDoc.Language.Elixir do
7877 end
7978
8079 @ 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
8384
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
8898 end
8999 end
90100
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+
92104 extra_annotations =
93105 case { kind , name , arity } do
94106 { :macro , _ , _ } -> [ "macro" ]
@@ -99,35 +111,23 @@ defmodule ExDoc.Language.Elixir do
99111 actual_def = actual_def ( name , arity , kind )
100112
101113 % {
114+ id_key: "" ,
115+ default_group: "Functions" ,
102116 doc_fallback: fn ->
103117 impl = Map . fetch ( module_data . private . impls , actual_def )
104118
105119 callback_doc_ast ( name , arity , impl ) ||
106120 delegate_doc_ast ( metadata [ :delegate_to ] )
107121 end ,
108122 extra_annotations: extra_annotations ,
123+ signature: signature ,
124+ source_file: nil ,
109125 source_line: find_function_line ( module_data , actual_def ) || Source . anno_line ( anno ) ,
110126 specs: specs ( kind , name , actual_def , module_data )
111127 }
112128 end
113129
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
131131 { { kind , name , arity } , anno , _signature , _doc , _metadata } = entry
132132 actual_def = actual_def ( name , arity , kind )
133133
@@ -149,16 +149,18 @@ defmodule ExDoc.Language.Elixir do
149149 end
150150
151151 line = Source . anno_line ( anno )
152-
153152 quoted = Enum . map ( specs , & Code.Typespec . spec_to_quoted ( name , & 1 ) )
154153 signature = [ get_typespec_signature ( hd ( quoted ) , arity ) ]
155154
156155 % {
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 ,
159160 signature: signature ,
160- specs: quoted ,
161- extra_annotations: extra_annotations
161+ source_file: nil ,
162+ source_line: line ,
163+ specs: quoted
162164 }
163165 end
164166
@@ -182,6 +184,7 @@ defmodule ExDoc.Language.Elixir do
182184
183185 % {
184186 type: type ,
187+ doc_fallback: fn -> nil end ,
185188 source_line: line ,
186189 source_file: source ,
187190 spec: quoted ,
@@ -282,7 +285,7 @@ defmodule ExDoc.Language.Elixir do
282285 { :local , :.. }
283286
284287 [ "//" , "" , "" ] ->
285- { :local , :" ..//" }
288+ { :local , :..// }
286289
287290 [ "" , "" ] ->
288291 { :local , :. }
0 commit comments