Skip to content

Commit

Permalink
Act on review comment: leave HTML as is
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ferraz-oliveira committed Oct 3, 2023
1 parent 32ad4b7 commit 01b6065
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
20 changes: 2 additions & 18 deletions lib/ex_doc/language/erlang.ex
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,8 @@ defmodule ExDoc.Language.Erlang do
binary
end

defp walk_doc({:code, attrs, [{:a, a_attrs, [a_inner], _a_meta} | _] = a, meta}, _config) do
{arity, extra} =
case :lists.keydelete(:a, 1, a) do
[] ->
{0, ""}

[extra] ->
# a_meta is not broken down, so we have to parse stuff like (X, Y)
{extra |> String.split(",") |> Enum.count(), extra}
end

type = type_from_fragment(:otp, a_attrs[:href])
url = fragment(:ex_doc, :type, type, arity)
text = a_inner <> extra

{:a, [href: url], {:code, attrs, [text], meta}, %{}}
defp walk_doc({:code, _attrs, [{:a, _, _, _}], _meta} = ast, _config) do
ast
end

defp walk_doc({:code, attrs, [code], meta} = ast, config) do
Expand Down Expand Up @@ -474,8 +460,6 @@ defmodule ExDoc.Language.Erlang do
"#t:#{name}/#{arity}"
end

defp type_from_fragment(:otp, "#type-" <> name), do: name

defp kind("c:" <> rest), do: {:callback, rest}
defp kind("t:" <> rest), do: {:type, rest}
defp kind(rest), do: {:function, rest}
Expand Down
6 changes: 3 additions & 3 deletions test/ex_doc/language/erlang_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,21 @@ defmodule ExDoc.Language.ErlangTest do
# if type exists:
# <code><a href="#type-myList">myList</a>(X)</code>
assert autolink_doc("{@type myList(X). A special kind of lists ...}", c) ==
~s|<a href="#t:myList/1"><code>myList(X)</code></a>|
~s|<code><a href=\"#type-myList\">myList</a>(X)</code>|
end

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

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

test "bad module", c do
Expand Down

0 comments on commit 01b6065

Please sign in to comment.