Skip to content

Commit 7fa36d5

Browse files
authored
Add :otp_eep48 and :otp_has_docs tags (#1516)
1 parent 277c401 commit 7fa36d5

File tree

6 files changed

+20
-9
lines changed

6 files changed

+20
-9
lines changed

lib/ex_doc/language/elixir.ex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,12 @@ defmodule ExDoc.Language.Elixir do
627627
defp parse_function("__block__"), do: {:function, :__block__}
628628

629629
defp parse_function(string) do
630-
case Code.string_to_quoted(string <> "/0") do
631-
{:ok, {:/, _, [{function, _, _}, 0]}} when is_atom(function) -> {:function, function}
632-
_ -> :error
630+
case Code.string_to_quoted("& #{string}/0") do
631+
{:ok, {:&, _, [{:/, _, [{function, _, _}, 0]}]}} when is_atom(function) ->
632+
{:function, function}
633+
634+
_ ->
635+
:error
633636
end
634637
end
635638

test/ex_doc/formatter/html/erlang_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule ExDoc.Formatter.HTML.ErlangTest do
22
use ExUnit.Case
33
import TestHelper
44

5-
@moduletag :otp24
5+
@moduletag :otp_eep48
66
@moduletag :tmp_dir
77

88
test "it works", c do

test/ex_doc/language/elixir_test.exs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,22 @@ defmodule ExDoc.Language.ElixirTest do
9797
assert_unchanged("bar/1", current_module: AutolinkTest.Foo)
9898
end
9999

100-
@tag :otp24
101100
test "auto-imported function" do
102101
assert autolink_doc("+/2") ==
103102
~m"[`+/2`](https://hexdocs.pm/elixir/Kernel.html#+/2)"
104103

104+
assert autolink_doc("&/1") ==
105+
~m"[`&/1`](https://hexdocs.pm/elixir/Kernel.SpecialForms.html#&/1)"
106+
105107
assert autolink_doc("for/1") ==
106108
~m"[`for/1`](https://hexdocs.pm/elixir/Kernel.SpecialForms.html#for/1)"
107109

108110
assert autolink_doc("for/1", apps: [:elixir]) ==
109111
~m"[`for/1`](Kernel.SpecialForms.html#for/1)"
112+
end
110113

114+
@tag skip: not Version.match?(System.version(), "~> 1.13")
115+
test "stepped range" do
111116
assert autolink_doc("..///3") ==
112117
~m"[`..///3`](https://hexdocs.pm/elixir/Kernel.html#..///3)"
113118
end

test/ex_doc/language/erlang_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule ExDoc.Language.ErlangTest do
22
use ExUnit.Case
33
import TestHelper
44

5-
@moduletag :otp24
5+
@moduletag :otp_has_docs
66
@moduletag :tmp_dir
77

88
describe "autolink_doc/2" do

test/ex_doc/retriever/erlang_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule ExDoc.Retriever.ErlangTest do
33
alias ExDoc.{Retriever, DocAST, Language.Erlang}
44
import TestHelper
55

6-
@moduletag :otp24
6+
@moduletag :otp_eep48
77
@moduletag :tmp_dir
88

99
describe "docs_from_modules/2" do

test/test_helper.exs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
otp_eep48? = Code.ensure_loaded?(:edoc_doclet_chunks)
2+
13
exclude = [
24
earmark: not ExDoc.Markdown.Earmark.available?(),
3-
otp24: System.otp_release() < "24"
5+
otp_eep48: not otp_eep48?,
6+
otp_has_docs: not match?({:docs_v1, _, _, _, _, _, _}, Code.fetch_docs(:array))
47
]
58

69
ExUnit.start(exclude: Enum.filter(exclude, &elem(&1, 1)))
@@ -71,7 +74,7 @@ defmodule TestHelper do
7174
:ok
7275
end
7376

74-
if Code.ensure_loaded?(:edoc_doclet_chunks) do
77+
if otp_eep48? do
7578
def edoc_to_chunk(module) do
7679
source_path = module.module_info(:compile)[:source]
7780
dir = :filename.dirname(source_path)

0 commit comments

Comments
 (0)