@@ -141,14 +141,16 @@ defmodule ExDoc.Retriever do
141
141
group_for_doc = config . group_for_doc
142
142
annotations_for_docs = config . annotations_for_docs
143
143
144
- { docs , docs_groups } = get_docs ( module_data , source , group_for_doc , annotations_for_docs )
144
+ { docs , nodes_groups } = get_docs ( module_data , source , group_for_doc , annotations_for_docs )
145
+ docs = ExDoc.Utils . natural_sort_by ( docs , & "#{ & 1 . name } /#{ & 1 . arity } " )
145
146
146
147
moduledoc_groups = Map . get ( metadata , :groups , [ ] )
147
148
148
149
docs_groups =
149
150
get_docs_groups (
150
151
moduledoc_groups ++ config . docs_groups ++ module_data . default_groups ,
151
- docs_groups
152
+ nodes_groups ,
153
+ docs
152
154
)
153
155
154
156
metadata = Map . put ( metadata , :kind , module_data . type )
@@ -165,8 +167,9 @@ defmodule ExDoc.Retriever do
165
167
type: module_data . type ,
166
168
deprecated: metadata [ :deprecated ] ,
167
169
docs_groups: docs_groups ,
168
- docs: ExDoc.Utils . natural_sort_by ( docs , & "#{ & 1 . name } /#{ & 1 . arity } " ) ,
169
- doc: normalize_doc_ast ( doc_ast , "module-" ) ,
170
+ docs: docs ,
171
+ doc_format: format ,
172
+ doc: doc ,
170
173
source_doc: source_doc ,
171
174
source_format: format ,
172
175
moduledoc_line: doc_line ,
@@ -281,13 +284,14 @@ defmodule ExDoc.Retriever do
281
284
end )
282
285
end
283
286
284
- defp get_docs_groups ( module_groups , nodes_groups ) do
287
+ defp get_docs_groups ( module_groups , nodes_groups , doc_nodes ) do
285
288
module_groups = Enum . map ( module_groups , & normalize_group / 1 )
286
289
287
290
# Doc nodes already have normalized groups
288
291
nodes_groups_descriptions = Map . new ( nodes_groups , & { & 1 . title , & 1 . description } )
289
292
290
293
normal_groups = module_groups ++ nodes_groups
294
+ nodes_by_group_title = Enum . group_by ( doc_nodes , & & 1 . group )
291
295
292
296
{ docs_groups , _ } =
293
297
Enum . flat_map_reduce ( normal_groups , % { } , fn
@@ -296,14 +300,21 @@ defmodule ExDoc.Retriever do
296
300
297
301
group , seen ->
298
302
seen = Map . put ( seen , group . title , true )
299
- group = finalize_group ( group , nodes_groups_descriptions )
300
- { [ group ] , seen }
303
+
304
+ case Map . get ( nodes_by_group_title , group . title , [ ] ) do
305
+ [ ] ->
306
+ { [ ] , seen }
307
+
308
+ child_nodes ->
309
+ group = finalize_group ( group , child_nodes , nodes_groups_descriptions )
310
+ { [ group ] , seen }
311
+ end
301
312
end )
302
313
303
314
docs_groups
304
315
end
305
316
306
- defp finalize_group ( group , description_fallbacks ) do
317
+ defp finalize_group ( group , doc_nodes , description_fallbacks ) do
307
318
description =
308
319
case group . description do
309
320
nil -> Map . get ( description_fallbacks , group . title )
@@ -320,7 +331,7 @@ defmodule ExDoc.Retriever do
320
331
title: group . title ,
321
332
description: description ,
322
333
doc: doc_ast ,
323
- rendered_doc: nil
334
+ docs: doc_nodes
324
335
}
325
336
end
326
337
0 commit comments