@@ -250,8 +250,8 @@ defmodule IEx.Introspection do
250250 case Code . ensure_loaded ( module ) do
251251 { :module , _ } ->
252252 case Code . fetch_docs ( module ) do
253- { :docs_v1 , _ , _ , _ , % { } = doc , _ , _ } ->
254- print_doc ( inspect ( module ) , [ ] , doc )
253+ { :docs_v1 , _ , _ , _ , % { } = doc , metadata , _ } ->
254+ print_doc ( inspect ( module ) , [ ] , doc , metadata )
255255
256256 { :docs_v1 , _ , _ , _ , _ , _ , _ } ->
257257 docs_not_found ( inspect ( module ) )
@@ -376,7 +376,7 @@ defmodule IEx.Introspection do
376376
377377 is_nil ( docs ) and spec != [ ] ->
378378 message = % { "en" => "Module was compiled without docs. Showing only specs." }
379- print_doc ( "#{ inspect ( mod ) } .#{ fun } /#{ arity } " , spec , message )
379+ print_doc ( "#{ inspect ( mod ) } .#{ fun } /#{ arity } " , spec , message , % { } )
380380 :ok
381381
382382 is_nil ( docs ) ->
@@ -449,7 +449,7 @@ defmodule IEx.Introspection do
449449 defp has_content? ( { { _ , name , _ } , _ , _ , :none , _ } ) , do: hd ( Atom . to_charlist ( name ) ) != ?_
450450 defp has_content? ( { _ , _ , _ , _ , _ } ) , do: true
451451
452- defp print_fun ( mod , { { kind , fun , arity } , _line , signature , doc , _meta } , spec ) do
452+ defp print_fun ( mod , { { kind , fun , arity } , _line , signature , doc , metadata } , spec ) do
453453 if callback_module = doc == :none and callback_module ( mod , fun , arity ) do
454454 filter = & match? ( { _ , ^ fun , ^ arity } , elem ( & 1 , 0 ) )
455455
@@ -458,7 +458,7 @@ defmodule IEx.Introspection do
458458 _ -> nil
459459 end
460460 else
461- print_doc ( "#{ kind_to_def ( kind ) } #{ Enum . join ( signature , " " ) } " , spec , doc )
461+ print_doc ( "#{ kind_to_def ( kind ) } #{ Enum . join ( signature , " " ) } " , spec , doc , metadata )
462462 end
463463 end
464464
@@ -513,7 +513,7 @@ defmodule IEx.Introspection do
513513 { :ok , docs } ->
514514 docs
515515 |> add_optional_callback_docs ( mod )
516- |> Enum . each ( fn { definition , _ } -> IO . puts ( definition ) end )
516+ |> Enum . each ( fn { definition , _ , _ } -> IO . puts ( definition ) end )
517517 end
518518
519519 dont_display_result ( )
@@ -565,12 +565,12 @@ defmodule IEx.Introspection do
565565 docs
566566 |> Enum . filter ( filter )
567567 |> Enum . map ( fn
568- { { :macrocallback , fun , arity } , _ , _ , doc , _ } ->
568+ { { :macrocallback , fun , arity } , _ , _ , doc , metadata } ->
569569 macro = { :"MACRO-#{ fun } " , arity + 1 }
570- { format_callback ( :macrocallback , fun , macro , callbacks ) , doc }
570+ { format_callback ( :macrocallback , fun , macro , callbacks ) , doc , metadata }
571571
572- { { kind , fun , arity } , _ , _ , doc , _ } ->
573- { format_callback ( kind , fun , { fun , arity } , callbacks ) , doc }
572+ { { kind , fun , arity } , _ , _ , doc , metadata } ->
573+ { format_callback ( kind , fun , { fun , arity } , callbacks ) , doc , metadata }
574574 end )
575575
576576 { :ok , docs }
@@ -588,7 +588,7 @@ defmodule IEx.Introspection do
588588 if optional_callbacks == [ ] do
589589 docs
590590 else
591- docs ++ [ { format_optional_callbacks ( optional_callbacks ) , "" } ]
591+ docs ++ [ { format_optional_callbacks ( optional_callbacks ) , "" , % { } } ]
592592 end
593593 end
594594
@@ -637,8 +637,8 @@ defmodule IEx.Introspection do
637637 { :ok , types } ->
638638 printed =
639639 for { _ , { ^ type , _ , args } } = typespec <- types do
640- doc = { format_type ( typespec ) , type_doc ( module , type , length ( args ) ) }
641- print_typespec ( doc )
640+ type_doc ( module , type , length ( args ) , typespec )
641+ |> print_typespec ( )
642642 end
643643
644644 if printed == [ ] do
@@ -657,8 +657,8 @@ defmodule IEx.Introspection do
657657 { :ok , types } ->
658658 printed =
659659 for { _ , { ^ type , _ , args } } = typespec <- types , length ( args ) == arity do
660- doc = { format_type ( typespec ) , type_doc ( module , type , arity ) }
661- print_typespec ( doc )
660+ type_doc ( module , type , arity , typespec )
661+ |> print_typespec ( )
662662 end
663663
664664 if printed == [ ] do
@@ -674,12 +674,12 @@ defmodule IEx.Introspection do
674674 dont_display_result ( )
675675 end
676676
677- defp type_doc ( module , type , arity ) do
677+ defp type_doc ( module , type , arity , typespec ) do
678678 if docs = get_docs ( module , [ :type ] ) do
679- { _ , _ , _ , content , _ } = Enum . find ( docs , & match? ( { :type , ^ type , ^ arity } , elem ( & 1 , 0 ) ) )
680- content
679+ { _ , _ , _ , content , metadata } = Enum . find ( docs , & match? ( { :type , ^ type , ^ arity } , elem ( & 1 , 0 ) ) )
680+ { format_type ( typespec ) , content , metadata }
681681 else
682- :none
682+ { format_type ( typespec ) , :none , % { } }
683683 end
684684 end
685685
@@ -717,27 +717,31 @@ defmodule IEx.Introspection do
717717 IEx . color ( :doc_inline_code , left ) <> " " <> right
718718 end
719719
720- defp print_doc ( heading , types , doc ) do
720+ defp print_doc ( heading , types , doc , metadata ) do
721721 doc = translate_doc ( doc ) || ""
722722
723723 if opts = IEx.Config . ansi_docs ( ) do
724724 IO.ANSI.Docs . print_heading ( heading , opts )
725725 IO . write ( types )
726+ IO.ANSI.Docs . print_metadata ( metadata , opts )
726727 IO.ANSI.Docs . print ( doc , opts )
727728 else
728729 IO . puts ( "* #{ heading } \n " )
729730 IO . write ( types )
731+ IO.ANSI.Docs . print_metadata ( metadata , enabled: false )
730732 IO . puts ( doc )
731733 end
732734 end
733735
734- defp print_typespec ( { types , doc } ) do
736+ defp print_typespec ( { types , doc , metadata } ) do
735737 IO . puts ( types )
736738 doc = translate_doc ( doc )
737739
738740 if opts = IEx.Config . ansi_docs ( ) do
741+ IO.ANSI.Docs . print_metadata ( metadata , opts )
739742 doc && IO.ANSI.Docs . print ( doc , opts )
740743 else
744+ IO.ANSI.Docs . print_metadata ( metadata , enabled: false )
741745 doc && IO . puts ( doc )
742746 end
743747 end
0 commit comments