Skip to content

Commit cf49545

Browse files
committed
Require Elixir v1.14+
1 parent 39960b5 commit cf49545

File tree

7 files changed

+45
-82
lines changed

7 files changed

+45
-82
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
include:
19-
- pair: # Test very old elixir and Erlang
20-
elixir: "1.13"
21-
otp: "22"
19+
- pair: # Test very old Elixir and Erlang
20+
elixir: "1.14"
21+
otp: "23"
2222
- pair: # Test Erlang without -doc attribute support
2323
elixir: "1.16"
2424
otp: "26"

lib/ex_doc/autolink.ex

+4-12
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,9 @@ defmodule ExDoc.Autolink do
8080
app_url(base_url, module, config, path, config.ext, "#{anchor}")
8181
end
8282

83-
defp string_app_module_url(string, tool, module, anchor, config) do
83+
defp string_app_module_url(tool, module, anchor, config) do
8484
if Enum.any?(config.filtered_modules, &(&1.module == module)) do
85-
# TODO: Remove on Elixir v1.14
86-
prefix =
87-
if unquote(Version.match?(System.version(), ">= 1.14.0")) do
88-
""
89-
else
90-
~s|"#{string}" |
91-
end
92-
93-
warn(config, prefix <> "reference to a filtered module")
85+
warn(config, "reference to a filtered module")
9486
nil
9587
else
9688
app_module_url(tool, module, anchor, config)
@@ -269,7 +261,7 @@ defmodule ExDoc.Autolink do
269261

270262
case {mode, Refs.get_visibility(ref)} do
271263
{_link_type, visibility} when visibility in [:public, :limited] ->
272-
string_app_module_url(string, tool(module, config), module, anchor, config)
264+
string_app_module_url(tool(module, config), module, anchor, config)
273265

274266
{:regular_link, :undefined} ->
275267
nil
@@ -493,7 +485,7 @@ defmodule ExDoc.Autolink do
493485
if same_module? do
494486
fragment(kind, name, arity)
495487
else
496-
url = string_app_module_url(original_text, tool, module, nil, config)
488+
url = string_app_module_url(tool, module, nil, config)
497489
url && url <> fragment(kind, name, arity)
498490
end
499491

lib/ex_doc/language/elixir.ex

+5-16
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ defmodule ExDoc.Language.Elixir do
9292
extra_annotations =
9393
case {kind, name, arity} do
9494
{:macro, _, _} -> ["macro"]
95-
{_, :__struct__, 0} -> ["struct"]
95+
{_, :__struct__, _} -> ["struct"]
9696
_ -> []
9797
end
9898

@@ -122,19 +122,8 @@ defmodule ExDoc.Language.Elixir do
122122
end
123123

124124
# If content is a map, then it is ok.
125-
defp doc?({_, _, _, %{}, _}, _) do
126-
true
127-
end
128-
129-
# If it is none, then we need to look at underscore.
130-
# TODO: We can remove this on Elixir v1.13 as all underscored are hidden.
131-
defp doc?({{_, name, _}, _, _, :none, _}, _type) do
132-
not match?([?_ | _], Atom.to_charlist(name))
133-
end
134-
135-
# Everything else is hidden.
136-
defp doc?({_, _, _, _, _}, _) do
137-
false
125+
defp doc?({_, _, _, doc, _}, _) do
126+
doc != :hidden
138127
end
139128

140129
@impl true
@@ -424,8 +413,8 @@ defmodule ExDoc.Language.Elixir do
424413

425414
defp module_type_and_skip(module) do
426415
cond do
427-
function_exported?(module, :__struct__, 0) and
428-
match?(%{__exception__: true}, module.__struct__()) ->
416+
function_exported?(module, :__info__, 1) and
417+
Enum.any?(module.__info__(:struct) || [], &(&1.field == :__exception__)) ->
429418
{:exception, false}
430419

431420
function_exported?(module, :__protocol__, 1) ->

lib/ex_doc/language/erlang.ex

+28-31
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,40 @@ defmodule ExDoc.Language.Erlang do
6262
def function_data(entry, module_data) do
6363
{{kind, name, arity}, _anno, _signature, doc_content, metadata} = entry
6464

65-
# TODO: Edoc on Erlang/OTP24.1+ includes private functions in
66-
# the chunk, so we manually yank them out for now.
67-
if kind == :function and doc_content != :hidden and
68-
function_exported?(module_data.module, name, arity) do
65+
if kind == :function and doc_content != :hidden do
6966
function_data(name, arity, doc_content, module_data, metadata)
7067
else
7168
:skip
7269
end
7370
end
7471

72+
defp function_data(name, arity, _doc_content, module_data, metadata) do
73+
specs =
74+
case Map.fetch(module_data.private.specs, {name, arity}) do
75+
{:ok, spec} ->
76+
[spec]
77+
78+
:error ->
79+
case Map.fetch(module_data.private.specs, {module_data.module, name, arity}) do
80+
{:ok, spec} ->
81+
[spec]
82+
83+
:error ->
84+
[]
85+
end
86+
end
87+
88+
{file, line} = Source.fetch_function_location!(module_data, {name, arity})
89+
90+
%{
91+
doc_fallback: fn -> equiv_data(module_data.module, file, line, metadata) end,
92+
extra_annotations: [],
93+
source_line: line,
94+
source_file: file,
95+
specs: specs
96+
}
97+
end
98+
7599
defp equiv_data(module, file, line, metadata, prefix \\ "") do
76100
case metadata[:equiv] do
77101
nil ->
@@ -102,33 +126,6 @@ defmodule ExDoc.Language.Erlang do
102126
end
103127
end
104128

105-
defp function_data(name, arity, _doc_content, module_data, metadata) do
106-
specs =
107-
case Map.fetch(module_data.private.specs, {name, arity}) do
108-
{:ok, spec} ->
109-
[spec]
110-
111-
:error ->
112-
case Map.fetch(module_data.private.specs, {module_data.module, name, arity}) do
113-
{:ok, spec} ->
114-
[spec]
115-
116-
:error ->
117-
[]
118-
end
119-
end
120-
121-
{file, line} = Source.fetch_function_location!(module_data, {name, arity})
122-
123-
%{
124-
doc_fallback: fn -> equiv_data(module_data.module, file, line, metadata) end,
125-
extra_annotations: [],
126-
source_line: line,
127-
source_file: file,
128-
specs: specs
129-
}
130-
end
131-
132129
@impl true
133130
def callback_data(entry, module_data) do
134131
{{_kind, name, arity}, anno, signature, _doc, metadata} = entry

mix.exs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ defmodule ExDoc.Mixfile do
22
use Mix.Project
33

44
@source_url "https://github.com/elixir-lang/ex_doc"
5-
@version "0.34.2"
5+
@version "0.35.0-dev"
66

77
def project do
88
[
99
app: :ex_doc,
1010
version: @version,
11-
elixir: "~> 1.13",
11+
elixir: "~> 1.14",
1212
deps: deps(),
1313
aliases: aliases(),
1414
package: package(),

test/ex_doc/cli_test.exs

+1-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@ defmodule ExDoc.CLITest do
55
@ebin "_build/test/lib/ex_doc/ebin"
66

77
defp run(args) do
8-
# TODO: Use with_io on Elixir v1.13
9-
io =
10-
capture_io(fn ->
11-
send(self(), ExDoc.CLI.main(args, &{&1, &2, &3}))
12-
end)
13-
14-
assert_receive response
15-
{response, io}
8+
with_io(fn -> ExDoc.CLI.main(args, &{&1, &2, &3}) end)
169
end
1710

1811
test "minimum command-line options" do

test/ex_doc/formatter/html_test.exs

+2-10
Original file line numberDiff line numberDiff line change
@@ -337,17 +337,13 @@ defmodule ExDoc.Formatter.HTMLTest do
337337
)
338338
)
339339

340-
assert File.read!(tmp_dir <> "/html/old-license.html") == """
340+
assert File.read!(tmp_dir <> "/html/old-license.html") =~ """
341341
<!DOCTYPE html>
342342
<html>
343343
<head>
344344
<meta charset="utf-8">
345345
<title>Elixir v1.0.1 — Documentation</title>
346346
<meta http-equiv="refresh" content="0; url=license.html">
347-
<meta name="generator" content="ExDoc v0.34.2">
348-
</head>
349-
<body></body>
350-
</html>
351347
"""
352348
end
353349

@@ -361,17 +357,13 @@ defmodule ExDoc.Formatter.HTMLTest do
361357
)
362358
)
363359

364-
assert File.read!(tmp_dir <> "/html/old-license.html") == """
360+
assert File.read!(tmp_dir <> "/html/old-license.html") =~ """
365361
<!DOCTYPE html>
366362
<html>
367363
<head>
368364
<meta charset="utf-8">
369365
<title>Elixir v1.0.1 — Documentation</title>
370366
<meta http-equiv="refresh" content="0; url=license.html">
371-
<meta name="generator" content="ExDoc v0.34.2">
372-
</head>
373-
<body></body>
374-
</html>
375367
"""
376368
end
377369
end

0 commit comments

Comments
 (0)