From aca43d0e9e059d24e72e17006a2bbe56034a51e1 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Wed, 4 Oct 2023 16:58:30 +0100 Subject: [PATCH] Partially fix abstract Erlang types (`{@type ...}`) (#1787) --- lib/ex_doc/language/erlang.ex | 4 ++++ test/ex_doc/language/erlang_test.exs | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/ex_doc/language/erlang.ex b/lib/ex_doc/language/erlang.ex index 0cfa1fea7..0d1ce48da 100644 --- a/lib/ex_doc/language/erlang.ex +++ b/lib/ex_doc/language/erlang.ex @@ -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 diff --git a/test/ex_doc/language/erlang_test.exs b/test/ex_doc/language/erlang_test.exs index 0a986ce37..8a1cc231d 100644 --- a/test/ex_doc/language/erlang_test.exs +++ b/test/ex_doc/language/erlang_test.exs @@ -124,6 +124,21 @@ defmodule ExDoc.Language.ErlangTest do ~s|array:array()| end + test "abstract types - description", c do + assert autolink_doc("{@type myList(X). A special kind of lists ...}", c) == + ~s|myList(X)| + end + + test "abstract types - description+dot", c do + assert autolink_doc("{@type myList(X, Y).}", c) == + ~s|myList(X, Y)| + end + + test "abstract types - no description", c do + assert autolink_doc("{@type myList()}", c) == + ~s|myList()| + end + test "bad module", c do assert ExUnit.CaptureIO.capture_io(:stderr, fn -> assert autolink_doc("{@link bad}", c) == ~s|bad|