Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially fix abstract Erlang types ({@type ...}) #1787

Merged
merged 3 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading