Skip to content

Commit fa2c96f

Browse files
committed
Remove specs which are pass through and from private modules
1 parent db20316 commit fa2c96f

File tree

15 files changed

+60
-189
lines changed

15 files changed

+60
-189
lines changed

lib/eex/lib/eex.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ defmodule EEx do
125125
| {:indentation, non_neg_integer}
126126
| {:trim, boolean()}
127127

128-
@type compile_opt :: tokenize_opt | {:engine, module()} | {:parser_options, Code.parser_opts()}
128+
@type compile_opt ::
129+
tokenize_opt
130+
| {:engine, module()}
131+
| {:parser_options, Code.parser_opts()}
132+
| {atom(), term()}
129133

130134
@doc """
131135
Generates a function definition from the given string.
@@ -137,6 +141,7 @@ defmodule EEx do
137141
template.
138142
139143
The supported `options` are described [in the module docs](#module-options).
144+
Additional options are passed to the underlying engine.
140145
141146
## Examples
142147

lib/eex/lib/eex/compiler.ex

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,6 @@ defmodule EEx.Compiler do
1010
@h_spaces [?\s, ?\t]
1111
@all_spaces [?\s, ?\t, ?\n, ?\r]
1212

13-
@typedoc """
14-
Options for EEx compilation functions.
15-
16-
These options control various aspects of EEx template compilation including
17-
file information, parsing behavior, and the template engine to use.
18-
"""
19-
@type compile_opts :: [
20-
file: String.t(),
21-
line: pos_integer(),
22-
column: pos_integer(),
23-
indentation: non_neg_integer(),
24-
trim: boolean(),
25-
parser_options: Code.parser_opts(),
26-
engine: module()
27-
]
28-
2913
@doc """
3014
Tokenize EEx contents.
3115
"""
@@ -306,7 +290,7 @@ defmodule EEx.Compiler do
306290
and the engine together by handling the tokens and invoking
307291
the engine every time a full expression or text is received.
308292
"""
309-
@spec compile([EEx.token()], String.t(), compile_opts) :: Macro.t()
293+
@spec compile([EEx.token()], String.t(), keyword) :: Macro.t()
310294
def compile(tokens, source, opts) do
311295
file = opts[:file] || "nofile"
312296
line = opts[:line] || 1

lib/eex/lib/eex/engine.ex

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,16 @@ defmodule EEx.Engine do
1414

1515
@type state :: term
1616

17-
@typedoc """
18-
Options passed to engine initialization.
19-
20-
These are the same options passed to `EEx.Compiler.compile/3`,
21-
allowing engines to access compilation settings and customize
22-
their behavior accordingly.
23-
"""
24-
@type init_opts :: [
25-
file: String.t(),
26-
line: pos_integer(),
27-
column: pos_integer(),
28-
indentation: non_neg_integer(),
29-
trim: boolean(),
30-
parser_options: Code.parser_opts(),
31-
engine: module()
32-
]
33-
3417
@doc """
3518
Called at the beginning of every template.
3619
20+
It receives the options during compilation, including the
21+
ones managed by EEx, such as `:line` and `:file`, as well
22+
as custom engine options.
23+
3724
It must return the initial state.
3825
"""
39-
@callback init(opts :: init_opts) :: state
26+
@callback init(opts :: keyword) :: state
4027

4128
@doc """
4229
Called at the end of every template.

lib/elixir/lib/code.ex

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

lib/elixir/lib/code/formatter.ex

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -155,32 +155,10 @@ defmodule Code.Formatter do
155155

156156
@do_end_keywords [:rescue, :catch, :else, :after]
157157

158-
@typedoc """
159-
Options for `to_algebra/2`.
160-
161-
These options include all the standard code formatting options plus
162-
additional context like comments and syntax highlighting colors.
163-
"""
164-
@type to_algebra_opt ::
165-
{:comments, [term()]}
166-
| {:syntax_colors, keyword()}
167-
| {:sigils, keyword()}
168-
| {:file, binary()}
169-
| {:line, pos_integer()}
170-
| {:line_length, pos_integer()}
171-
| {:locals_without_parens, keyword()}
172-
| {:force_do_end_blocks, boolean()}
173-
| {:migrate, boolean()}
174-
| {:migrate_bitstring_modifiers, boolean()}
175-
| {:migrate_call_parens_on_pipe, boolean()}
176-
| {:migrate_charlists_as_sigils, boolean()}
177-
| {:migrate_unless, boolean()}
178-
| {atom(), term()}
179-
180158
@doc """
181159
Converts the quoted expression into an algebra document.
182160
"""
183-
@spec to_algebra(Macro.t(), [to_algebra_opt]) :: Inspect.Algebra.t()
161+
@spec to_algebra(Macro.t(), keyword()) :: Inspect.Algebra.t()
184162
def to_algebra(quoted, opts \\ []) do
185163
comments = Keyword.get(opts, :comments, [])
186164

lib/elixir/lib/code/normalizer.ex

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,11 @@ defmodule Code.Normalizer do
1010
is_binary(x) or
1111
is_atom(x)
1212

13-
@typedoc """
14-
Options for `normalize/2`.
15-
"""
16-
@type normalize_opt ::
17-
{:line, pos_integer() | nil}
18-
| {:escape, boolean()}
19-
| {:locals_without_parens, keyword()}
20-
| {atom(), term()}
21-
2213
@doc """
2314
Wraps literals in the quoted expression to conform to the AST format expected
2415
by the formatter.
2516
"""
26-
@spec normalize(Macro.t(), [normalize_opt]) :: Macro.t()
17+
@spec normalize(Macro.t(), keyword()) :: Macro.t()
2718
def normalize(quoted, opts \\ []) do
2819
line = Keyword.get(opts, :line, nil)
2920
escape = Keyword.get(opts, :escape, true)

lib/elixir/lib/io/ansi/docs.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ defmodule IO.ANSI.Docs do
4444
Values for the color settings are strings with
4545
comma-separated ANSI values.
4646
"""
47-
@spec default_options() :: keyword
47+
@spec default_options() :: print_opts
4848
def default_options do
4949
[
5050
enabled: true,

lib/elixir/lib/module/types/descr.ex

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,6 @@ defmodule Module.Types.Descr do
4949
@empty_intersection [0, @none]
5050
@empty_difference [0, []]
5151

52-
# Type definitions
53-
54-
@typedoc """
55-
Options for `to_quoted/2`.
56-
"""
57-
@type to_quoted_opts :: [
58-
collapse_structs: boolean()
59-
]
60-
6152
defguard is_descr(descr) when is_map(descr) or descr == :term
6253

6354
defp descr_key?(:term, _key), do: true
@@ -559,7 +550,6 @@ defmodule Module.Types.Descr do
559550
* `:collapse_structs` - do not show struct fields that match
560551
their default type
561552
"""
562-
@spec to_quoted(term(), to_quoted_opts) :: Macro.t()
563553
def to_quoted(descr, opts \\ []) do
564554
if term_type?(descr) do
565555
{:term, [], []}
@@ -634,7 +624,6 @@ defmodule Module.Types.Descr do
634624
* `:collapse_structs` - do not show struct fields that match
635625
their default type
636626
"""
637-
@spec to_quoted(term(), to_quoted_opts) :: String.t()
638627
def to_quoted_string(descr, opts \\ []) do
639628
descr
640629
|> to_quoted(opts)

lib/elixir/lib/module/types/helpers.ex

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ defmodule Module.Types.Helpers do
66
# AST and enumeration helpers.
77
@moduledoc false
88

9-
@typedoc """
10-
Options for `expr_to_string/2`.
11-
"""
12-
@type expr_to_string_opts :: [
13-
collapse_structs: boolean()
14-
]
15-
169
## AST helpers
1710

1811
@doc """
@@ -278,8 +271,11 @@ defmodule Module.Types.Helpers do
278271
translating inlined Erlang calls back to Elixir.
279272
280273
We also undo some macro expressions done by the Kernel module.
274+
275+
## Options
276+
277+
* `:collapse_structs` - when false, show structs full representation
281278
"""
282-
@spec expr_to_string(Macro.t(), expr_to_string_opts) :: String.t()
283279
def expr_to_string(expr, opts \\ []) do
284280
string = prewalk_expr_to_string(expr, opts)
285281

lib/iex/lib/iex/broker.ex

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ defmodule IEx.Broker do
99
@type take_ref :: {takeover_ref :: reference(), server_ref :: reference()}
1010
@type shell :: pid | nil
1111

12-
@typedoc """
13-
Options for `take_over/3`.
14-
"""
15-
@type take_over_opts :: [
16-
evaluator: pid()
17-
]
18-
1912
use GenServer
2013

2114
## Shell API
@@ -65,7 +58,7 @@ defmodule IEx.Broker do
6558
@doc """
6659
Client requests a takeover.
6760
"""
68-
@spec take_over(binary, iodata, take_over_opts) ::
61+
@spec take_over(binary, iodata, keyword) ::
6962
{:ok, server :: pid, group_leader :: pid, counter :: integer}
7063
| {:error, :no_iex | :refused | atom()}
7164
def take_over(location, whereami, opts) do

0 commit comments

Comments
 (0)