Skip to content

Commit

Permalink
Add :otp_eep48 and :otp_has_docs tags (#1516)
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed Feb 15, 2022
1 parent 277c401 commit 7fa36d5
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
9 changes: 6 additions & 3 deletions lib/ex_doc/language/elixir.ex
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,12 @@ defmodule ExDoc.Language.Elixir do
defp parse_function("__block__"), do: {:function, :__block__}

defp parse_function(string) do
case Code.string_to_quoted(string <> "/0") do
{:ok, {:/, _, [{function, _, _}, 0]}} when is_atom(function) -> {:function, function}
_ -> :error
case Code.string_to_quoted("& #{string}/0") do
{:ok, {:&, _, [{:/, _, [{function, _, _}, 0]}]}} when is_atom(function) ->
{:function, function}

_ ->
:error
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/ex_doc/formatter/html/erlang_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule ExDoc.Formatter.HTML.ErlangTest do
use ExUnit.Case
import TestHelper

@moduletag :otp24
@moduletag :otp_eep48
@moduletag :tmp_dir

test "it works", c do
Expand Down
7 changes: 6 additions & 1 deletion test/ex_doc/language/elixir_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,22 @@ defmodule ExDoc.Language.ElixirTest do
assert_unchanged("bar/1", current_module: AutolinkTest.Foo)
end

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

assert autolink_doc("&/1") ==
~m"[`&/1`](https://hexdocs.pm/elixir/Kernel.SpecialForms.html#&/1)"

assert autolink_doc("for/1") ==
~m"[`for/1`](https://hexdocs.pm/elixir/Kernel.SpecialForms.html#for/1)"

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

@tag skip: not Version.match?(System.version(), "~> 1.13")
test "stepped range" do
assert autolink_doc("..///3") ==
~m"[`..///3`](https://hexdocs.pm/elixir/Kernel.html#..///3)"
end
Expand Down
2 changes: 1 addition & 1 deletion test/ex_doc/language/erlang_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule ExDoc.Language.ErlangTest do
use ExUnit.Case
import TestHelper

@moduletag :otp24
@moduletag :otp_has_docs
@moduletag :tmp_dir

describe "autolink_doc/2" do
Expand Down
2 changes: 1 addition & 1 deletion test/ex_doc/retriever/erlang_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule ExDoc.Retriever.ErlangTest do
alias ExDoc.{Retriever, DocAST, Language.Erlang}
import TestHelper

@moduletag :otp24
@moduletag :otp_eep48
@moduletag :tmp_dir

describe "docs_from_modules/2" do
Expand Down
7 changes: 5 additions & 2 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
otp_eep48? = Code.ensure_loaded?(:edoc_doclet_chunks)

exclude = [
earmark: not ExDoc.Markdown.Earmark.available?(),
otp24: System.otp_release() < "24"
otp_eep48: not otp_eep48?,
otp_has_docs: not match?({:docs_v1, _, _, _, _, _, _}, Code.fetch_docs(:array))
]

ExUnit.start(exclude: Enum.filter(exclude, &elem(&1, 1)))
Expand Down Expand Up @@ -71,7 +74,7 @@ defmodule TestHelper do
:ok
end

if Code.ensure_loaded?(:edoc_doclet_chunks) do
if otp_eep48? do
def edoc_to_chunk(module) do
source_path = module.module_info(:compile)[:source]
dir = :filename.dirname(source_path)
Expand Down

0 comments on commit 7fa36d5

Please sign in to comment.