Skip to content

Commit 4ead53d

Browse files
authored
Fix broken types and some dialyzer issues (#1615)
1 parent 6ad3fdd commit 4ead53d

File tree

5 files changed

+59
-57
lines changed

5 files changed

+59
-57
lines changed

lib/ex_doc/formatter/html/templates.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ defmodule ExDoc.Formatter.HTML.Templates do
224224
prefixed with `prefix`.
225225
"""
226226
@heading_regex ~r/<(h[23]).*?>(.*?)<\/\1>/m
227-
@spec link_headings(String.t(), Regex.t(), String.t()) :: String.t()
227+
@spec link_headings(String.t() | nil, Regex.t(), String.t()) :: String.t() | nil
228228
def link_headings(content, regex \\ @heading_regex, prefix \\ "")
229229
def link_headings(nil, _, _), do: nil
230230

lib/ex_doc/language.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule ExDoc.Language do
22
@moduledoc false
33

4-
@typep spec_ast() :: term()
4+
@type spec_ast() :: term()
55

66
@typedoc """
77
The map has the following keys:

lib/ex_doc/language/elixir.ex

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ defmodule ExDoc.Language.Elixir do
225225
prefixes
226226
|> Enum.find(&String.starts_with?(title, &1 <> "."))
227227
|> case do
228-
nil -> {nil, nil}
228+
nil -> nil
229229
prefix -> {"." <> String.trim_leading(title, prefix <> "."), prefix}
230230
end
231231
end
@@ -835,16 +835,12 @@ defmodule ExDoc.Language.Elixir do
835835

836836
case {mode, Refs.get_visibility({:module, module}), Refs.get_visibility(ref)} do
837837
{_mode, _module_visibility, :public} ->
838-
case Autolink.tool(module, config) do
839-
:no_tool ->
840-
nil
838+
tool = Autolink.tool(module, config)
841839

842-
tool ->
843-
if same_module? do
844-
fragment(tool, kind, name, arity)
845-
else
846-
Autolink.app_module_url(tool, module, config) <> fragment(tool, kind, name, arity)
847-
end
840+
if same_module? do
841+
fragment(tool, kind, name, arity)
842+
else
843+
Autolink.app_module_url(tool, module, config) <> fragment(tool, kind, name, arity)
848844
end
849845

850846
{:regular_link, module_visibility, :undefined}

lib/ex_doc/nodes.ex

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,27 @@ defmodule ExDoc.ModuleNode do
2222
language: nil,
2323
annotations: []
2424

25+
@typep annotation :: atom()
26+
2527
@type t :: %__MODULE__{
26-
id: nil | String.t(),
27-
title: nil | String.t(),
28-
nested_context: nil | String.t(),
29-
nested_title: nil | String.t(),
30-
module: nil | String.t(),
31-
group: nil | String.t(),
32-
deprecated: nil | String.t(),
33-
function_groups: list(String.t()),
34-
docs: list(),
35-
doc: term(),
36-
rendered_doc: nil | String.t(),
28+
id: String.t(),
29+
title: String.t(),
30+
nested_context: String.t() | nil,
31+
nested_title: String.t() | nil,
32+
module: module(),
33+
group: atom() | nil,
34+
deprecated: String.t() | nil,
35+
doc: ExDoc.DocAST.t() | nil,
36+
rendered_doc: String.t() | nil,
3737
doc_line: non_neg_integer(),
38-
typespecs: list(),
39-
source_path: nil | String.t(),
40-
source_url: nil | String.t(),
41-
type: nil | atom(),
38+
function_groups: [atom()],
39+
docs: [ExDoc.FunctionNode.t()],
40+
typespecs: [ExDoc.TypeNode.t()],
41+
source_path: String.t(),
42+
source_url: String.t() | nil,
43+
type: atom(),
4244
language: module(),
43-
annotations: list()
45+
annotations: [annotation()]
4446
}
4547
end
4648

@@ -65,22 +67,25 @@ defmodule ExDoc.FunctionNode do
6567
source_path: nil,
6668
source_url: nil
6769

70+
@typep annotation :: String.t()
71+
@typep function_default :: {name :: atom(), arity :: non_neg_integer()}
72+
6873
@type t :: %__MODULE__{
69-
id: nil | String.t(),
70-
name: nil | String.t(),
71-
arity: non_neg_integer,
72-
defaults: non_neg_integer,
73-
doc: term(),
74-
rendered_doc: nil | String.t(),
75-
doc_line: non_neg_integer,
76-
source_path: nil | String.t(),
77-
source_url: nil | String.t(),
78-
group: nil | String.t(),
79-
type: nil | String.t(),
80-
signature: nil | String.t(),
81-
specs: list(),
82-
annotations: list(),
83-
deprecated: nil | String.t()
74+
id: String.t(),
75+
name: atom(),
76+
arity: non_neg_integer(),
77+
defaults: [function_default()],
78+
deprecated: String.t() | nil,
79+
doc: ExDoc.DocAST.t() | nil,
80+
rendered_doc: String.t() | nil,
81+
type: atom(),
82+
signature: String.t(),
83+
specs: [ExDoc.Language.spec_ast()],
84+
annotations: [annotation()],
85+
group: atom() | nil,
86+
doc_line: non_neg_integer(),
87+
source_path: String.t(),
88+
source_url: String.t() | nil
8489
}
8590
end
8691

@@ -103,19 +108,21 @@ defmodule ExDoc.TypeNode do
103108
signature: nil,
104109
annotations: []
105110

111+
@typep annotation :: String.t()
112+
106113
@type t :: %__MODULE__{
107-
id: nil | String.t(),
108-
name: nil | String.t(),
109-
arity: non_neg_integer,
110-
type: nil | String.t(),
111-
spec: nil | String.t(),
112-
deprecated: nil | String.t(),
113-
doc: term(),
114-
rendered_doc: nil | String.t(),
115-
doc_line: non_neg_integer,
116-
signature: nil | String.t(),
117-
source_url: nil | String.t(),
118-
source_path: nil | String.t(),
119-
annotations: list()
114+
id: String.t(),
115+
name: atom(),
116+
arity: non_neg_integer(),
117+
type: atom(),
118+
deprecated: nil,
119+
doc: ExDoc.DocAST.t() | nil,
120+
rendered_doc: String.t() | nil,
121+
doc_line: non_neg_integer(),
122+
source_path: String.t(),
123+
source_url: String.t() | nil,
124+
spec: ExDoc.Language.spec_ast(),
125+
signature: String.t(),
126+
annotations: [annotation()]
120127
}
121128
end

lib/ex_doc/retriever.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ defmodule ExDoc.Retriever do
314314

315315
## General helpers
316316

317-
defp signature([]), do: nil
318317
defp signature(list) when is_list(list), do: Enum.join(list, " ")
319318

320319
defp annotations_from_metadata(metadata) do

0 commit comments

Comments
 (0)