@@ -108,9 +108,15 @@ defmodule ExDoc.Retriever do
108
108
config . groups_for_functions ++
109
109
[ Callbacks: & ( & 1 [ :__doc__ ] == :callback ) , Functions: fn _ -> true end ]
110
110
111
+ annotations_for_docs = config . annotations_for_docs
112
+
111
113
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
+
114
120
types = get_types ( module_data , source )
115
121
116
122
metadata = Map . put ( metadata , :__doc__ , module_data . type )
@@ -157,7 +163,7 @@ defmodule ExDoc.Retriever do
157
163
158
164
## Function helpers
159
165
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
161
167
{ :docs_v1 , _ , _ , _ , _ , _ , doc_elements } = module_data . docs
162
168
163
169
nodes =
@@ -167,18 +173,38 @@ defmodule ExDoc.Retriever do
167
173
[ ]
168
174
169
175
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
+ ]
171
186
end
172
187
end )
173
188
174
189
filter_defaults ( nodes )
175
190
end
176
191
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
178
200
{ :docs_v1 , _ , _ , content_type , _ , _ , _ } = module_data . docs
179
201
{ { type , name , arity } , anno , signature , doc_content , metadata } = doc_element
180
202
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
+
182
208
line = function_data . line || doc_line
183
209
defaults = get_defaults ( name , arity , Map . get ( metadata , :defaults , 0 ) )
184
210
@@ -226,17 +252,22 @@ defmodule ExDoc.Retriever do
226
252
227
253
## Callback helpers
228
254
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
230
261
{ :docs_v1 , _ , _ , _ , _ , _ , docs } = module_data . docs
231
262
232
263
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 )
234
265
end
235
266
end
236
267
237
- defp get_callbacks ( _ , _ , _ ) , do: [ ]
268
+ defp get_callbacks ( _ , _ , _ , _ ) , do: [ ]
238
269
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
240
271
callback_data = module_data . language . callback_data ( callback , module_data )
241
272
242
273
{ :docs_v1 , _ , _ , content_type , _ , _ , _ } = module_data . docs
@@ -245,7 +276,11 @@ defmodule ExDoc.Retriever do
245
276
246
277
signature = signature ( callback_data . signature )
247
278
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
+
249
284
doc_ast = doc_ast ( content_type , doc , file: source . path , line: doc_line + 1 )
250
285
251
286
metadata = Map . put ( metadata , :__doc__ , :callback )
0 commit comments