@@ -140,14 +140,16 @@ defmodule ExDoc.Retriever do
140140 group_for_doc = config . group_for_doc
141141 annotations_for_docs = config . annotations_for_docs
142142
143- { docs , docs_groups } = get_docs ( module_data , source , group_for_doc , annotations_for_docs )
143+ { docs , nodes_groups } = get_docs ( module_data , source , group_for_doc , annotations_for_docs )
144+ docs = ExDoc.Utils . natural_sort_by ( docs , & "#{ & 1 . name } /#{ & 1 . arity } " )
144145
145146 moduledoc_groups = Map . get ( metadata , :groups , [ ] )
146147
147148 docs_groups =
148149 get_docs_groups (
149150 moduledoc_groups ++ config . docs_groups ++ module_data . default_groups ,
150- docs_groups
151+ nodes_groups ,
152+ docs
151153 )
152154
153155 metadata = Map . put ( metadata , :kind , module_data . type )
@@ -164,7 +166,7 @@ defmodule ExDoc.Retriever do
164166 type: module_data . type ,
165167 deprecated: metadata [ :deprecated ] ,
166168 docs_groups: docs_groups ,
167- docs: ExDoc.Utils . natural_sort_by ( docs , & " #{ & 1 . name } / #{ & 1 . arity } " ) ,
169+ docs: docs ,
168170 doc_format: format ,
169171 doc: doc ,
170172 source_doc: source_doc ,
@@ -274,13 +276,14 @@ defmodule ExDoc.Retriever do
274276 end )
275277 end
276278
277- defp get_docs_groups ( module_groups , nodes_groups ) do
279+ defp get_docs_groups ( module_groups , nodes_groups , doc_nodes ) do
278280 module_groups = Enum . map ( module_groups , & normalize_group / 1 )
279281
280282 # Doc nodes already have normalized groups
281283 nodes_groups_descriptions = Map . new ( nodes_groups , & { & 1 . title , & 1 . description } )
282284
283285 normal_groups = module_groups ++ nodes_groups
286+ nodes_by_group_title = Enum . group_by ( doc_nodes , & & 1 . group )
284287
285288 { docs_groups , _ } =
286289 Enum . flat_map_reduce ( normal_groups , % { } , fn
@@ -289,14 +292,21 @@ defmodule ExDoc.Retriever do
289292
290293 group , seen ->
291294 seen = Map . put ( seen , group . title , true )
292- group = finalize_group ( group , nodes_groups_descriptions )
293- { [ group ] , seen }
295+
296+ case Map . get ( nodes_by_group_title , group . title , [ ] ) do
297+ [ ] ->
298+ { [ ] , seen }
299+
300+ child_nodes ->
301+ group = finalize_group ( group , child_nodes , nodes_groups_descriptions )
302+ { [ group ] , seen }
303+ end
294304 end )
295305
296306 docs_groups
297307 end
298308
299- defp finalize_group ( group , description_fallbacks ) do
309+ defp finalize_group ( group , doc_nodes , description_fallbacks ) do
300310 description =
301311 case group . description do
302312 nil -> Map . get ( description_fallbacks , group . title )
@@ -313,7 +323,7 @@ defmodule ExDoc.Retriever do
313323 title: group . title ,
314324 description: description ,
315325 doc: doc_ast ,
316- rendered_doc: nil
326+ docs: doc_nodes
317327 }
318328 end
319329
0 commit comments