@@ -1195,6 +1195,19 @@ defmodule Module do
11951195 raise ArgumentError , "expected an Elixir module, got: #{ inspect ( original ) } "
11961196 end
11971197
1198+ @ doc false
1199+ # TODO: Remove in 2.0 - deprecated.
1200+ def add_doc ( module , line , kind , function_tuple , signature \\ [ ] , doc ) do
1201+ assert_not_compiled! ( :add_doc , module )
1202+
1203+ if kind in [ :defp , :defmacrop , :typep ] do
1204+ if doc , do: { :error , :private_doc } , else: :ok
1205+ else
1206+ compile_doc ( data_table_for ( module ) , line , kind , function_tuple , signature , doc , __ENV__ )
1207+ :ok
1208+ end
1209+ end
1210+
11981211 @ doc false
11991212 # Used internally to compile documentation.
12001213 # This function is private and must be used only internally.
@@ -1205,22 +1218,17 @@ defmodule Module do
12051218 pair = { name , arity }
12061219
12071220 impl = compile_impl ( table , name , env , kind , args )
1208- compile_doc ( table , pair , env , kind , args , impl )
1209- compile_deprecated ( table , pair )
1221+ _deprecated = compile_deprecated ( table , pair )
1222+ _since = compile_since ( table )
12101223
1211- :ok
1212- end
1213-
1214- defp compile_doc ( table , pair , env , kind , args , impl ) do
1224+ # TODO: Store @since and @deprecated alongside the docs
12151225 { line , doc } = get_doc_info ( table , env , impl )
1226+ compile_doc ( table , line , kind , pair , args , doc , env )
12161227
1217- # TODO: Store @since alongside the docs
1218- _ = get_since_info ( table )
1219-
1220- add_doc ( table , line , kind , pair , args , doc , env )
1228+ :ok
12211229 end
12221230
1223- defp add_doc ( _table , line , kind , { name , arity } , _args , doc , env )
1231+ defp compile_doc ( _table , line , kind , { name , arity } , _args , doc , env )
12241232 when kind in [ :defp , :defmacrop ] do
12251233 if doc do
12261234 error_message =
@@ -1231,7 +1239,7 @@ defmodule Module do
12311239 end
12321240 end
12331241
1234- defp add_doc ( table , line , kind , pair , args , doc , env ) do
1242+ defp compile_doc ( table , line , kind , pair , args , doc , env ) do
12351243 signature = build_signature ( args , env )
12361244
12371245 case :ets . lookup ( table , { :doc , pair } ) do
@@ -1245,9 +1253,21 @@ defmodule Module do
12451253 end
12461254 end
12471255
1256+ defp compile_since ( table ) do
1257+ case :ets . take ( table , :since ) do
1258+ [ { :since , since , _ , _ } ] when is_binary ( since ) -> since
1259+ _ -> nil
1260+ end
1261+ end
1262+
12481263 defp compile_deprecated ( table , pair ) do
1249- if reason = get_deprecated_info ( table ) do
1250- :ets . insert ( table , { { :deprecated , pair } , reason } )
1264+ case :ets . take ( table , :deprecated ) do
1265+ [ { :deprecated , reason , _ , _ } ] when is_binary ( reason ) ->
1266+ :ets . insert ( table , { { :deprecated , pair } , reason } )
1267+ reason
1268+
1269+ _ ->
1270+ nil
12511271 end
12521272 end
12531273
@@ -1736,17 +1756,6 @@ defmodule Module do
17361756 end
17371757 end
17381758
1739- defp get_since_info ( table ) do
1740- :ets . take ( table , :since )
1741- end
1742-
1743- defp get_deprecated_info ( table ) do
1744- case :ets . take ( table , :deprecated ) do
1745- [ { :deprecated , reason , _ , _ } ] -> reason
1746- [ ] -> nil
1747- end
1748- end
1749-
17501759 defp data_table_for ( module ) do
17511760 :elixir_module . data_table ( module )
17521761 end
0 commit comments