@@ -251,18 +251,27 @@ defmodule Code do
251251 @ typedoc """
252252 Options for code formatting functions.
253253 """
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- ]
254+ @ type format_opt ::
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+ | { atom ( ) , term ( ) }
266+
267+ @ typedoc """
268+ Options for `quoted_to_algebra/2`.
269+ """
270+ @ type quoted_to_algebra_opt ::
271+ { :line , pos_integer ( ) | nil }
272+ | { :escape , boolean ( ) }
273+ | { :locals_without_parens , keyword ( ) }
274+ | { :comments , [ term ( ) ] }
266275
267276 @ typedoc """
268277 Options for parsing functions that convert strings to quoted expressions.
@@ -1079,7 +1088,7 @@ defmodule Code do
10791088 address the deprecation warnings.
10801089 """
10811090 @ doc since: "1.6.0"
1082- @ spec format_string! ( binary , format_opts ) :: iodata
1091+ @ spec format_string! ( binary , [ format_opt ] ) :: iodata
10831092 def format_string! ( string , opts \\ [ ] ) when is_binary ( string ) and is_list ( opts ) do
10841093 line_length = Keyword . get ( opts , :line_length , 98 )
10851094
@@ -1104,7 +1113,7 @@ defmodule Code do
11041113 available options.
11051114 """
11061115 @ doc since: "1.6.0"
1107- @ spec format_file! ( binary , format_opts ) :: iodata
1116+ @ spec format_file! ( binary , [ format_opt ] ) :: iodata
11081117 def format_file! ( file , opts \\ [ ] ) when is_binary ( file ) and is_list ( opts ) do
11091118 string = File . read! ( file )
11101119 formatted = format_string! ( string , [ file: file , line: 1 ] ++ opts )
@@ -1516,14 +1525,13 @@ defmodule Code do
15161525 `string_to_quoted/2`, setting this option to `false` will prevent it from
15171526 escaping the sequences twice. Defaults to `true`.
15181527
1519- See `format_string!/2` for the full list of formatting options including
1528+ See `format_string!/2` for the full list of formatting options including
15201529 `:file`, `:line`, `:line_length`, `:locals_without_parens`, `:force_do_end_blocks`,
15211530 `:syntax_colors`, and all migration options like `:migrate_charlists_as_sigils`.
15221531 """
15231532 @ doc since: "1.13.0"
1524- @ spec quoted_to_algebra ( Macro . t ( ) , [
1525- Code.Formatter . to_algebra_opt ( ) | Code.Normalizer . normalize_opt ( )
1526- ] ) :: Inspect.Algebra . t ( )
1533+ @ spec quoted_to_algebra ( Macro . t ( ) , [ format_opt ( ) | quoted_to_algebra_opt ( ) ] ) ::
1534+ Inspect.Algebra . t ( )
15271535 def quoted_to_algebra ( quoted , opts \\ [ ] ) do
15281536 quoted
15291537 |> Code.Normalizer . normalize ( opts )
0 commit comments