@@ -197,13 +197,13 @@ defmodule ExDoc.Retriever do
197
197
groups_for_docs ,
198
198
annotations_for_docs
199
199
) do
200
- { :docs_v1 , _ , _ , content_type , _ , _ , _ } = module_data . docs
200
+ { :docs_v1 , _ , _ , content_type , _ , module_metadata , _ } = module_data . docs
201
201
{ { type , name , arity } , anno , signature , doc_content , metadata } = doc_element
202
202
doc_line = anno_line ( anno )
203
203
204
204
annotations =
205
205
annotations_for_docs . ( metadata ) ++
206
- annotations_from_metadata ( metadata ) ++ function_data . extra_annotations
206
+ annotations_from_metadata ( metadata , module_metadata ) ++ function_data . extra_annotations
207
207
208
208
line = function_data . line || doc_line
209
209
defaults = get_defaults ( name , arity , Map . get ( metadata , :defaults , 0 ) )
@@ -270,7 +270,7 @@ defmodule ExDoc.Retriever do
270
270
defp get_callback ( callback , source , groups_for_docs , module_data , annotations_for_docs ) do
271
271
callback_data = module_data . language . callback_data ( callback , module_data )
272
272
273
- { :docs_v1 , _ , _ , content_type , _ , _ , _ } = module_data . docs
273
+ { :docs_v1 , _ , _ , content_type , _ , module_metadata , _ } = module_data . docs
274
274
{ { kind , name , arity } , anno , _signature , doc , metadata } = callback
275
275
doc_line = anno_line ( anno )
276
276
@@ -279,7 +279,7 @@ defmodule ExDoc.Retriever do
279
279
280
280
annotations =
281
281
annotations_for_docs . ( metadata ) ++
282
- callback_data . extra_annotations ++ annotations_from_metadata ( metadata )
282
+ callback_data . extra_annotations ++ annotations_from_metadata ( metadata , module_metadata )
283
283
284
284
doc_ast = doc_ast ( content_type , doc , file: source . path , line: doc_line + 1 )
285
285
@@ -314,10 +314,10 @@ defmodule ExDoc.Retriever do
314
314
end
315
315
316
316
defp get_type ( type_entry , source , module_data ) do
317
- { :docs_v1 , _ , _ , content_type , _ , _ , _ } = module_data . docs
317
+ { :docs_v1 , _ , _ , content_type , _ , module_metadata , _ } = module_data . docs
318
318
{ { _ , name , arity } , anno , _signature , doc , metadata } = type_entry
319
319
doc_line = anno_line ( anno )
320
- annotations = annotations_from_metadata ( metadata )
320
+ annotations = annotations_from_metadata ( metadata , module_metadata )
321
321
322
322
type_data = module_data . language . type_data ( type_entry , module_data )
323
323
signature = signature ( type_data . signature )
@@ -344,17 +344,13 @@ defmodule ExDoc.Retriever do
344
344
345
345
defp signature ( list ) when is_list ( list ) , do: Enum . join ( list , " " )
346
346
347
- defp annotations_from_metadata ( metadata ) do
348
- annotations = [ ]
349
-
350
- annotations =
351
- if since = metadata [ :since ] do
352
- [ "since #{ since } " | annotations ]
353
- else
354
- annotations
355
- end
356
-
357
- annotations
347
+ defp annotations_from_metadata ( metadata , module_metadata ) do
348
+ # Give precedence to the function/callback/type metadata over the module metadata.
349
+ cond do
350
+ since = metadata [ :since ] -> [ "since #{ since } " ]
351
+ since = module_metadata [ :since ] -> [ "since #{ since } " ]
352
+ true -> [ ]
353
+ end
358
354
end
359
355
360
356
defp anno_line ( line ) when is_integer ( line ) , do: abs ( line )
0 commit comments