@@ -108,9 +108,15 @@ defmodule ExDoc.Retriever do
108108 config . groups_for_functions ++
109109 [ Callbacks: & ( & 1 [ :__doc__ ] == :callback ) , Functions: fn _ -> true end ]
110110
111+ annotations_for_docs = config . annotations_for_docs
112+
111113 docs_groups = Enum . map ( groups_for_functions , & elem ( & 1 , 0 ) )
112- function_docs = get_docs ( module_data , source , groups_for_functions )
113- docs = function_docs ++ get_callbacks ( module_data , source , groups_for_functions )
114+ function_docs = get_docs ( module_data , source , groups_for_functions , annotations_for_docs )
115+
116+ docs =
117+ function_docs ++
118+ get_callbacks ( module_data , source , groups_for_functions , annotations_for_docs )
119+
114120 types = get_types ( module_data , source )
115121
116122 metadata = Map . put ( metadata , :__doc__ , module_data . type )
@@ -157,7 +163,7 @@ defmodule ExDoc.Retriever do
157163
158164 ## Function helpers
159165
160- defp get_docs ( module_data , source , groups_for_functions ) do
166+ defp get_docs ( module_data , source , groups_for_functions , annotations_for_docs ) do
161167 { :docs_v1 , _ , _ , _ , _ , _ , doc_elements } = module_data . docs
162168
163169 nodes =
@@ -167,18 +173,38 @@ defmodule ExDoc.Retriever do
167173 [ ]
168174
169175 function_data ->
170- [ get_function ( doc_element , function_data , source , module_data , groups_for_functions ) ]
176+ [
177+ get_function (
178+ doc_element ,
179+ function_data ,
180+ source ,
181+ module_data ,
182+ groups_for_functions ,
183+ annotations_for_docs
184+ )
185+ ]
171186 end
172187 end )
173188
174189 filter_defaults ( nodes )
175190 end
176191
177- defp get_function ( doc_element , function_data , source , module_data , groups_for_functions ) do
192+ defp get_function (
193+ doc_element ,
194+ function_data ,
195+ source ,
196+ module_data ,
197+ groups_for_functions ,
198+ annotations_for_docs
199+ ) do
178200 { :docs_v1 , _ , _ , content_type , _ , _ , _ } = module_data . docs
179201 { { type , name , arity } , anno , signature , doc_content , metadata } = doc_element
180202 doc_line = anno_line ( anno )
181- annotations = annotations_from_metadata ( metadata ) ++ function_data . extra_annotations
203+
204+ annotations =
205+ annotations_for_docs . ( metadata ) ++
206+ annotations_from_metadata ( metadata ) ++ function_data . extra_annotations
207+
182208 line = function_data . line || doc_line
183209 defaults = get_defaults ( name , arity , Map . get ( metadata , :defaults , 0 ) )
184210
@@ -226,17 +252,22 @@ defmodule ExDoc.Retriever do
226252
227253 ## Callback helpers
228254
229- defp get_callbacks ( % { type: :behaviour } = module_data , source , groups_for_functions ) do
255+ defp get_callbacks (
256+ % { type: :behaviour } = module_data ,
257+ source ,
258+ groups_for_functions ,
259+ annotations_for_docs
260+ ) do
230261 { :docs_v1 , _ , _ , _ , _ , _ , docs } = module_data . docs
231262
232263 for { { kind , _ , _ } , _ , _ , _ , _ } = doc <- docs , kind in module_data . callback_types do
233- get_callback ( doc , source , groups_for_functions , module_data )
264+ get_callback ( doc , source , groups_for_functions , module_data , annotations_for_docs )
234265 end
235266 end
236267
237- defp get_callbacks ( _ , _ , _ ) , do: [ ]
268+ defp get_callbacks ( _ , _ , _ , _ ) , do: [ ]
238269
239- defp get_callback ( callback , source , groups_for_functions , module_data ) do
270+ defp get_callback ( callback , source , groups_for_functions , module_data , annotations_for_docs ) do
240271 callback_data = module_data . language . callback_data ( callback , module_data )
241272
242273 { :docs_v1 , _ , _ , content_type , _ , _ , _ } = module_data . docs
@@ -245,7 +276,11 @@ defmodule ExDoc.Retriever do
245276
246277 signature = signature ( callback_data . signature )
247278 specs = callback_data . specs
248- annotations = callback_data . extra_annotations ++ annotations_from_metadata ( metadata )
279+
280+ annotations =
281+ annotations_for_docs . ( metadata ) ++
282+ callback_data . extra_annotations ++ annotations_from_metadata ( metadata )
283+
249284 doc_ast = doc_ast ( content_type , doc , file: source . path , line: doc_line + 1 )
250285
251286 metadata = Map . put ( metadata , :__doc__ , :callback )
0 commit comments