@@ -248,6 +248,49 @@ defmodule Code do
248248  """ 
249249  @ type  position ( )  ::  line ( )  |  { line  ::  pos_integer ( ) ,  column  ::  pos_integer ( ) } 
250250
251+   @ typedoc  """ 
252+   Options for code formatting functions. 
253+   """ 
254+   @ type  format_opts  ::  [ 
255+           file:  binary ( ) , 
256+           line:  pos_integer ( ) , 
257+           line_length:  pos_integer ( ) , 
258+           locals_without_parens:  keyword ( ) , 
259+           force_do_end_blocks:  boolean ( ) , 
260+           migrate:  boolean ( ) , 
261+           migrate_bitstring_modifiers:  boolean ( ) , 
262+           migrate_call_parens_on_pipe:  boolean ( ) , 
263+           migrate_charlists_as_sigils:  boolean ( ) , 
264+           migrate_unless:  boolean ( ) 
265+         ] 
266+ 
267+   @ typedoc  """ 
268+   Options for parsing functions that convert strings to quoted expressions. 
269+   """ 
270+   @ type  parser_opts  ::  [ 
271+           file:  binary ( ) , 
272+           line:  pos_integer ( ) , 
273+           column:  pos_integer ( ) , 
274+           indentation:  non_neg_integer ( ) , 
275+           columns:  boolean ( ) , 
276+           unescape:  boolean ( ) , 
277+           existing_atoms_only:  boolean ( ) , 
278+           token_metadata:  boolean ( ) , 
279+           literal_encoder:  ( term ( ) ,  Macro . metadata ( )  ->  term ( ) ) , 
280+           static_atoms_encoder:  ( atom ( )  ->  term ( ) ) , 
281+           emit_warnings:  boolean ( ) 
282+         ] 
283+ 
284+   @ typedoc  """ 
285+   Options for environment evaluation functions like eval_string/3 and eval_quoted/3. 
286+   """ 
287+   @ type  env_eval_opts  ::  [ 
288+           file:  binary ( ) , 
289+           line:  pos_integer ( ) , 
290+           module:  module ( ) , 
291+           prune_binding:  boolean ( ) 
292+         ] 
293+ 
251294  @ boolean_compiler_options  [ 
252295    :docs , 
253296    :debug_info , 
@@ -560,7 +603,7 @@ defmodule Code do
560603      [a: 1, b: 2] 
561604
562605  """ 
563-   @ spec  eval_string ( List.Chars . t ( ) ,  binding ,  Macro.Env . t ( )  |  keyword )  ::  { term ,  binding } 
606+   @ spec  eval_string ( List.Chars . t ( ) ,  binding ,  Macro.Env . t ( )  |  env_eval_opts )  ::  { term ,  binding } 
564607  def  eval_string ( string ,  binding  \\  [ ] ,  opts  \\  [ ] ) 
565608
566609  def  eval_string ( string ,  binding ,  % Macro.Env { }  =  env )  do 
@@ -615,7 +658,8 @@ defmodule Code do
615658
616659  """ 
617660  @ doc  since:  "1.15.0" 
618-   @ spec  with_diagnostics ( keyword ( ) ,  ( ->  result ) )  ::  { result ,  [ diagnostic ( :warning  |  :error ) ] } 
661+   @ spec  with_diagnostics ( [ log:  boolean ( ) ] ,  ( ->  result ) )  :: 
662+           { result ,  [ diagnostic ( :warning  |  :error ) ] } 
619663        when  result:  term ( ) 
620664  def  with_diagnostics ( opts  \\  [ ] ,  fun )  do 
621665    value  =  :erlang . get ( :elixir_code_diagnostics ) 
@@ -648,7 +692,7 @@ defmodule Code do
648692      Defaults to `true`. 
649693  """ 
650694  @ doc  since:  "1.15.0" 
651-   @ spec  print_diagnostic ( diagnostic ( :warning  |  :error ) ,  keyword ( ) )  ::  :ok 
695+   @ spec  print_diagnostic ( diagnostic ( :warning  |  :error ) ,  snippet:  boolean ( ) )  ::  :ok 
652696  def  print_diagnostic ( diagnostic ,  opts  \\  [ ] )  do 
653697    read_snippet?  =  Keyword . get ( opts ,  :snippet ,  true ) 
654698    :elixir_errors . print_diagnostic ( diagnostic ,  read_snippet? ) 
@@ -1035,7 +1079,7 @@ defmodule Code do
10351079  address the deprecation warnings. 
10361080  """  
10371081  @ doc  since:  "1.6.0" 
1038-   @ spec  format_string! ( binary ,  keyword )  ::  iodata 
1082+   @ spec  format_string! ( binary ,  format_opts )  ::  iodata 
10391083  def  format_string! ( string ,  opts  \\  [ ] )  when  is_binary ( string )  and  is_list ( opts )  do 
10401084    line_length  =  Keyword . get ( opts ,  :line_length ,  98 ) 
10411085
@@ -1060,7 +1104,7 @@ defmodule Code do
10601104  available options. 
10611105  """ 
10621106  @ doc  since:  "1.6.0" 
1063-   @ spec  format_file! ( binary ,  keyword )  ::  iodata 
1107+   @ spec  format_file! ( binary ,  format_opts )  ::  iodata 
10641108  def  format_file! ( file ,  opts  \\  [ ] )  when  is_binary ( file )  and  is_list ( opts )  do 
10651109    string  =  File . read! ( file ) 
10661110    formatted  =  format_string! ( string ,  [ file:  file ,  line:  1 ]  ++  opts ) 
@@ -1098,7 +1142,7 @@ defmodule Code do
10981142      [a: 1, b: 2] 
10991143
11001144  """ 
1101-   @ spec  eval_quoted ( Macro . t ( ) ,  binding ,  Macro.Env . t ( )  |  keyword )  ::  { term ,  binding } 
1145+   @ spec  eval_quoted ( Macro . t ( ) ,  binding ,  Macro.Env . t ( )  |  env_eval_opts )  ::  { term ,  binding } 
11021146  def  eval_quoted ( quoted ,  binding  \\  [ ] ,  env_or_opts  \\  [ ] )  do 
11031147    { value ,  binding ,  _env }  = 
11041148      eval_verify ( :eval_quoted ,  [ quoted ,  binding ,  env_for_eval ( env_or_opts ) ] ) 
@@ -1129,8 +1173,15 @@ defmodule Code do
11291173    * `:line` - the line on which the script starts 
11301174
11311175    * `:module` - the module to run the environment on 
1176+ 
1177+     * `:prune_binding` - (since v1.14.2) prune binding to keep only 
1178+       variables read or written by the evaluated code. Note that 
1179+       variables used by modules are always pruned, even if later used 
1180+       by the modules. You can submit to the `:on_module` tracer event 
1181+       and access the variables used by the module from its environment. 
11321182  """ 
11331183  @ doc  since:  "1.14.0" 
1184+   @ spec  env_for_eval ( Macro.Env . t ( )  |  env_eval_opts )  ::  Macro.Env . t ( ) 
11341185  def  env_for_eval ( env_or_opts ) ,  do:  :elixir . env_for_eval ( env_or_opts ) 
11351186
11361187  @ doc  """ 
@@ -1144,15 +1195,11 @@ defmodule Code do
11441195
11451196  ## Options 
11461197
1147-     * `:prune_binding` - (since v1.14.2) prune binding to keep only 
1148-       variables read or written by the evaluated code. Note that 
1149-       variables used by modules are always pruned, even if later used 
1150-       by the modules. You can submit to the `:on_module` tracer event 
1151-       and access the variables used by the module from its environment. 
1198+   It accepts the same options as `env_for_eval/1`. 
11521199
11531200  """ 
11541201  @ doc  since:  "1.14.0" 
1155-   @ spec  eval_quoted_with_env ( Macro . t ( ) ,  binding ,  Macro.Env . t ( ) ,  keyword )  :: 
1202+   @ spec  eval_quoted_with_env ( Macro . t ( ) ,  binding ,  Macro.Env . t ( ) ,  env_eval_opts )  :: 
11561203          { term ,  binding ,  Macro.Env . t ( ) } 
11571204  def  eval_quoted_with_env ( quoted ,  binding ,  % Macro.Env { }  =  env ,  opts  \\  [ ] ) 
11581205      when  is_list ( binding )  do 
@@ -1263,7 +1310,7 @@ defmodule Code do
12631310      {:error, {[line: 1, column: 4], "syntax error before: ", "\" 3\" "}} 
12641311
12651312  """  
1266-   @ spec  string_to_quoted ( List.Chars . t ( ) ,  keyword )  :: 
1313+   @ spec  string_to_quoted ( List.Chars . t ( ) ,  parser_opts )  :: 
12671314          { :ok ,  Macro . t ( ) }  |  { :error ,  { location  ::  keyword ,  binary  |  { binary ,  binary } ,  binary } } 
12681315  def  string_to_quoted ( string ,  opts  \\  [ ] )  when  is_list ( opts )  do 
12691316    file  =  Keyword . get ( opts ,  :file ,  "nofile" ) 
@@ -1290,7 +1337,7 @@ defmodule Code do
12901337
12911338  Check `string_to_quoted/2` for options information. 
12921339  """ 
1293-   @ spec  string_to_quoted! ( List.Chars . t ( ) ,  keyword )  ::  Macro . t ( ) 
1340+   @ spec  string_to_quoted! ( List.Chars . t ( ) ,  parser_opts )  ::  Macro . t ( ) 
12941341  def  string_to_quoted! ( string ,  opts  \\  [ ] )  when  is_list ( opts )  do 
12951342    file  =  Keyword . get ( opts ,  :file ,  "nofile" ) 
12961343    line  =  Keyword . get ( opts ,  :line ,  1 ) 
@@ -1341,7 +1388,7 @@ defmodule Code do
13411388
13421389  """ 
13431390  @ doc  since:  "1.13.0" 
1344-   @ spec  string_to_quoted_with_comments ( List.Chars . t ( ) ,  keyword )  :: 
1391+   @ spec  string_to_quoted_with_comments ( List.Chars . t ( ) ,  parser_opts )  :: 
13451392          { :ok ,  Macro . t ( ) ,  list ( map ( ) ) }  |  { :error ,  { location  ::  keyword ,  term ,  term } } 
13461393  def  string_to_quoted_with_comments ( string ,  opts  \\  [ ] )  when  is_list ( opts )  do 
13471394    charlist  =  to_charlist ( string ) 
@@ -1371,7 +1418,7 @@ defmodule Code do
13711418  Check `string_to_quoted/2` for options information. 
13721419  """ 
13731420  @ doc  since:  "1.13.0" 
1374-   @ spec  string_to_quoted_with_comments! ( List.Chars . t ( ) ,  keyword )  ::  { Macro . t ( ) ,  list ( map ( ) ) } 
1421+   @ spec  string_to_quoted_with_comments! ( List.Chars . t ( ) ,  parser_opts )  ::  { Macro . t ( ) ,  list ( map ( ) ) } 
13751422  def  string_to_quoted_with_comments! ( string ,  opts  \\  [ ] )  do 
13761423    charlist  =  to_charlist ( string ) 
13771424
@@ -1456,6 +1503,9 @@ defmodule Code do
14561503
14571504  ## Options 
14581505
1506+   This function accepts all options supported by `format_string!/2` for controlling 
1507+   code formatting, plus these additional options: 
1508+ 
14591509    * `:comments` - the list of comments associated with the quoted expression. 
14601510      Defaults to `[]`. It is recommended that both `:token_metadata` and 
14611511      `:literal_encoder` options are given to `string_to_quoted_with_comments/2` 
@@ -1466,17 +1516,14 @@ defmodule Code do
14661516      `string_to_quoted/2`, setting this option to `false` will prevent it from 
14671517      escaping the sequences twice. Defaults to `true`. 
14681518
1469-     * `:locals_without_parens` - a keyword list of name and arity 
1470-       pairs that should be kept without parens whenever possible. 
1471-       The arity may be the atom `:*`, which implies all arities of 
1472-       that name. The formatter already includes a list of functions 
1473-       and this option augments this list. 
1474- 
1475-     * `:syntax_colors` - a keyword list of colors the output is colorized. 
1476-       See `Inspect.Opts` for more information. 
1519+   See `format_string!/2` for the full list of formatting options including  
1520+   `:file`, `:line`, `:line_length`, `:locals_without_parens`, `:force_do_end_blocks`, 
1521+   `:syntax_colors`, and all migration options like `:migrate_charlists_as_sigils`. 
14771522  """  
14781523  @ doc  since:  "1.13.0" 
1479-   @ spec  quoted_to_algebra ( Macro . t ( ) ,  keyword )  ::  Inspect.Algebra . t ( ) 
1524+   @ spec  quoted_to_algebra ( Macro . t ( ) ,  [ 
1525+           Code.Formatter . to_algebra_opt ( )  |  Code.Normalizer . normalize_opt ( ) 
1526+         ] )  ::  Inspect.Algebra . t ( ) 
14801527  def  quoted_to_algebra ( quoted ,  opts  \\  [ ] )  do 
14811528    quoted 
14821529    |>  Code.Normalizer . normalize ( opts ) 
0 commit comments