Skip to content

Commit

Permalink
Partially fix abstract Erlang types ({@type ...}) (#1787)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ferraz-oliveira committed Oct 4, 2023
1 parent 51d8387 commit aca43d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/ex_doc/language/erlang.ex
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ defmodule ExDoc.Language.Erlang do
binary
end

defp walk_doc({:code, _attrs, [{:a, _, _, _}], _meta} = ast, _config) do
ast
end

defp walk_doc({:code, attrs, [code], meta} = ast, config) do
{text, url} =
case parse_autolink(code) do
Expand Down
15 changes: 15 additions & 0 deletions test/ex_doc/language/erlang_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ defmodule ExDoc.Language.ErlangTest do
~s|<a href="https://www.erlang.org/doc/man/array.html#type-array"><code>array:array()</code></a>|
end

test "abstract types - description", c do
assert autolink_doc("{@type myList(X). A special kind of lists ...}", c) ==
~s|<code><a href=\"#type-myList\">myList</a>(X)</code>|
end

test "abstract types - description+dot", c do
assert autolink_doc("{@type myList(X, Y).}", c) ==
~s|<code><a href=\"#type-myList\">myList</a>(X, Y)</code>|
end

test "abstract types - no description", c do
assert autolink_doc("{@type myList()}", c) ==
~s|<code><a href=\"#type-myList\">myList()</a></code>|
end

test "bad module", c do
assert ExUnit.CaptureIO.capture_io(:stderr, fn ->
assert autolink_doc("{@link bad}", c) == ~s|<code>bad</code>|
Expand Down

0 comments on commit aca43d0

Please sign in to comment.