Skip to content

Commit

Permalink
Fix so that fun() in Erlang does not try to generate any link (#2079)
Browse files Browse the repository at this point in the history
  • Loading branch information
garazdawi authored Jan 28, 2025
1 parent 344026c commit c46b012
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ jobs:
# Test Erlang without -doc attribute support
- elixir: "1.16"
otp: "26"
# Test Erlang with -doc attribute support
# Test with initial Erlang doc attribute support
- elixir: "1.17"
otp: "27"
- elixir: "1.18"
otp: "27"
lint: true
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_doc/language/elixir.ex
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ defmodule ExDoc.Language.Elixir do
{:local, :..}

["//", "", ""] ->
{:local, :"..//"}
{:local, :..//}

["", ""] ->
{:local, :.}
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_doc/language/erlang.ex
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ defmodule ExDoc.Language.Erlang do
name == :record and acc != [] ->
{ast, acc}

name in [:"::", :when, :%{}, :{}, :|, :->, :...] ->
name in [:"::", :when, :%{}, :{}, :|, :->, :..., :fun] ->
{ast, acc}

# %{required(...) => ..., optional(...) => ...}
Expand Down
8 changes: 8 additions & 0 deletions test/ex_doc/language/erlang_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,14 @@ defmodule ExDoc.Language.ErlangTest do
end
end

test "function - specific arity", c do
assert autolink_spec(~s"-spec foo() -> fun((t()) -> t()) | erlang_bar:t().", c) ==
~s[foo() -> fun((<a href="#t:t/0">t</a>()) -> <a href="#t:t/0">t</a>()) | <a href="erlang_bar.html#t:t/0">erlang_bar:t</a>().]

assert autolink_spec(~s"-spec foo() -> fun((t(), t()) -> t()) | erlang_bar:t().", c) ==
~s[foo() -> fun((<a href="#t:t/0">t</a>(), <a href="#t:t/0">t</a>()) -> <a href="#t:t/0">t</a>()) | <a href="erlang_bar.html#t:t/0">erlang_bar:t</a>().]
end

test "local type", c do
assert autolink_spec(~S"-spec foo() -> t().", c) ==
~s|foo() -> <a href="#t:t/0">t</a>().|
Expand Down

0 comments on commit c46b012

Please sign in to comment.