@@ -135,17 +135,18 @@ defmodule ExDoc.Retriever do
135135 { doc_line , doc_file , format , source_doc , doc , metadata } = get_module_docs ( module_data , source )
136136
137137 # TODO: The default function groups must be returned by the language
138+ default_group = config . default_group_for_doc
138139 groups_for_docs = config . groups_for_docs
139140 annotations_for_docs = config . annotations_for_docs
140141
141142 docs_groups =
142- Enum . uniq ( Enum . map ( groups_for_docs , & elem ( & 1 , 0 ) ) ++ [ : Types, : Callbacks, : Functions] )
143+ Enum . uniq ( Enum . map ( groups_for_docs , & elem ( & 1 , 0 ) ) ++ ~w ( Types Callbacks Functions) )
143144
144145 docs =
145- get_docs ( module_data , source , groups_for_docs , annotations_for_docs ) ++
146- get_callbacks ( module_data , source , groups_for_docs , annotations_for_docs )
146+ get_docs ( module_data , source , default_group , groups_for_docs , annotations_for_docs ) ++
147+ get_callbacks ( module_data , source , default_group , groups_for_docs , annotations_for_docs )
147148
148- types = get_types ( module_data , source , groups_for_docs , annotations_for_docs )
149+ types = get_types ( module_data , source , default_group , groups_for_docs , annotations_for_docs )
149150
150151 metadata = Map . put ( metadata , :kind , module_data . type )
151152 group = GroupMatcher . match_module ( config . groups_for_modules , module , module_data . id , metadata )
@@ -195,42 +196,37 @@ defmodule ExDoc.Retriever do
195196
196197 ## Function helpers
197198
198- defp get_docs ( module_data , source , groups_for_docs , annotations_for_docs ) do
199- { :docs_v1 , _ , _ , _ , _ , _ , doc_elements } = module_data . docs
199+ defp get_docs ( module_data , source , default_group , groups_for_docs , annotations_for_docs ) do
200+ { :docs_v1 , _ , _ , _ , _ , _ , docs } = module_data . docs
200201
201202 nodes =
202- Enum . flat_map ( doc_elements , fn doc_element ->
203- case module_data . language . function_data ( doc_element , module_data ) do
204- :skip ->
205- [ ]
206-
207- function_data ->
208- [
209- get_function (
210- doc_element ,
211- function_data ,
212- source ,
213- module_data ,
214- groups_for_docs ,
215- annotations_for_docs
216- )
217- ]
218- end
219- end )
203+ for doc <- docs ,
204+ function_data = module_data . language . function_data ( doc , module_data ) do
205+ get_function (
206+ doc ,
207+ function_data ,
208+ module_data ,
209+ source ,
210+ default_group ,
211+ groups_for_docs ,
212+ annotations_for_docs
213+ )
214+ end
220215
221216 filter_defaults ( nodes )
222217 end
223218
224219 defp get_function (
225- doc_element ,
220+ doc ,
226221 function_data ,
227- source ,
228222 module_data ,
223+ source ,
224+ default_group ,
229225 groups_for_docs ,
230226 annotations_for_docs
231227 ) do
232228 { :docs_v1 , _ , _ , content_type , _ , module_metadata , _ } = module_data . docs
233- { { type , name , arity } , anno , signature , source_doc , metadata } = doc_element
229+ { { type , name , arity } , anno , signature , source_doc , metadata } = doc
234230 doc_file = anno_file ( anno , source )
235231 doc_line = anno_line ( anno )
236232
@@ -252,7 +248,7 @@ defmodule ExDoc.Retriever do
252248 ( source_doc && doc_ast ( content_type , source_doc , file: doc_file , line: doc_line + 1 ) ) ||
253249 function_data . doc_fallback . ( )
254250
255- group = GroupMatcher . match_doc ( groups_for_docs , metadata ) || : Functions
251+ group = GroupMatcher . match_doc ( groups_for_docs , default_group , " Functions" , metadata )
256252
257253 % ExDoc.FunctionNode {
258254 id: nil_or_name ( name , arity ) ,
@@ -296,23 +292,31 @@ defmodule ExDoc.Retriever do
296292 defp get_callbacks (
297293 % { type: :behaviour } = module_data ,
298294 source ,
295+ default_group ,
299296 groups_for_docs ,
300297 annotations_for_docs
301298 ) do
302299 { :docs_v1 , _ , _ , _ , _ , _ , docs } = module_data . docs
303300
304301 for { { kind , _ , _ } , _ , _ , _ , _ } = doc <- docs , kind in module_data . callback_types do
305- get_callback ( doc , source , groups_for_docs , module_data , annotations_for_docs )
302+ get_callback ( doc , module_data , source , default_group , groups_for_docs , annotations_for_docs )
306303 end
307304 end
308305
309- defp get_callbacks ( _ , _ , _ , _ ) , do: [ ]
306+ defp get_callbacks ( _ , _ , _ , _ , _ ) , do: [ ]
310307
311- defp get_callback ( callback , source , groups_for_docs , module_data , annotations_for_docs ) do
312- callback_data = module_data . language . callback_data ( callback , module_data )
308+ defp get_callback (
309+ doc ,
310+ module_data ,
311+ source ,
312+ default_group ,
313+ groups_for_docs ,
314+ annotations_for_docs
315+ ) do
316+ callback_data = module_data . language . callback_data ( doc , module_data )
313317
314318 { :docs_v1 , _ , _ , content_type , _ , module_metadata , _ } = module_data . docs
315- { { kind , name , arity } , anno , _signature , source_doc , metadata } = callback
319+ { { kind , name , arity } , anno , _signature , source_doc , metadata } = doc
316320 doc_file = anno_file ( anno , source )
317321 doc_line = anno_line ( anno )
318322
@@ -335,7 +339,7 @@ defmodule ExDoc.Retriever do
335339 doc_ast ( content_type , source_doc , file: doc_file , line: doc_line + 1 ) ||
336340 doc_fallback ( callback_data )
337341
338- group = GroupMatcher . match_doc ( groups_for_docs , metadata ) || : Callbacks
342+ group = GroupMatcher . match_doc ( groups_for_docs , default_group , " Callbacks" , metadata )
339343
340344 % ExDoc.FunctionNode {
341345 id: "c:" <> nil_or_name ( name , arity ) ,
@@ -357,21 +361,21 @@ defmodule ExDoc.Retriever do
357361
358362 ## Typespecs
359363
360- defp get_types ( module_data , source , groups_for_docs , annotations_for_docs ) do
364+ defp get_types ( module_data , source , default_group , groups_for_docs , annotations_for_docs ) do
361365 { :docs_v1 , _ , _ , _ , _ , _ , docs } = module_data . docs
362366
363367 for { { :type , _ , _ } , _ , _ , content , _ } = doc <- docs , content != :hidden do
364- get_type ( doc , source , groups_for_docs , module_data , annotations_for_docs )
368+ get_type ( doc , module_data , source , default_group , groups_for_docs , annotations_for_docs )
365369 end
366370 end
367371
368- defp get_type ( type_entry , source , groups_for_docs , module_data , annotations_for_docs ) do
372+ defp get_type ( doc , module_data , source , default_group , groups_for_docs , annotations_for_docs ) do
369373 { :docs_v1 , _ , _ , content_type , _ , module_metadata , _ } = module_data . docs
370- { { kind , name , arity } , anno , _signature , source_doc , metadata } = type_entry
374+ { { kind , name , arity } , anno , _signature , source_doc , metadata } = doc
371375 doc_file = anno_file ( anno , source )
372376 doc_line = anno_line ( anno )
373377
374- type_data = module_data . language . type_data ( type_entry , module_data )
378+ type_data = module_data . language . type_data ( doc , module_data )
375379
376380 metadata =
377381 Map . merge (
@@ -392,7 +396,7 @@ defmodule ExDoc.Retriever do
392396 doc_ast ( content_type , source_doc , file: doc_file , line: doc_line + 1 ) ||
393397 doc_fallback ( type_data )
394398
395- group = GroupMatcher . match_doc ( groups_for_docs , metadata ) || : Types
399+ group = GroupMatcher . match_doc ( groups_for_docs , default_group , " Types" , metadata )
396400
397401 % ExDoc.TypeNode {
398402 id: "t:" <> nil_or_name ( name , arity ) ,
0 commit comments