Skip to content

Commit 03022e6

Browse files
authored
Add ExDoc.Formatter.HTML.ErlangTest (#1514)
1 parent 4f4a59e commit 03022e6

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

mix.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ defmodule ExDoc.Mixfile do
3535
{:earmark_parser, "~> 1.4.19"},
3636
{:makeup_elixir, "~> 0.14"},
3737
{:makeup_erlang, "~> 0.1"},
38-
{:jason, "~> 1.2", only: :test}
38+
{:jason, "~> 1.2", only: :test},
39+
{:floki, "~> 0.0", only: :test}
3940
]
4041
end
4142

mix.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
%{
22
"earmark_parser": {:hex, :earmark_parser, "1.4.19", "de0d033d5ff9fc396a24eadc2fcf2afa3d120841eb3f1004d138cbf9273210e8", [:mix], [], "hexpm", "527ab6630b5c75c3a3960b75844c314ec305c76d9899bb30f71cb85952a9dc45"},
3+
"floki": {:hex, :floki, "0.32.0", "f915dc15258bc997d49be1f5ef7d3992f8834d6f5695270acad17b41f5bcc8e2", [:mix], [{:html_entities, "~> 0.5.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm", "1c5a91cae1fd8931c26a4826b5e2372c284813904c8bacb468b5de39c7ececbd"},
4+
"html_entities": {:hex, :html_entities, "0.5.2", "9e47e70598da7de2a9ff6af8758399251db6dbb7eebe2b013f2bbd2515895c3c", [:mix], [], "hexpm", "c53ba390403485615623b9531e97696f076ed415e8d8058b1dbaa28181f4fdcc"},
35
"jason": {:hex, :jason, "1.2.0", "10043418c42d2493d0ee212d3fddd25d7ffe484380afad769a0a38795938e448", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "116747dbe057794c3a3e4e143b7c8390b29f634e16c78a7f59ba75bfa6852e7f"},
46
"makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
57
"makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"},
68
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
7-
"nimble_parsec": {:hex, :nimble_parsec, "1.2.2", "811e32fb77aabb2b5b6196b21f76fe6ba8b6861c3d8c9eaeedbbf1f4cda627d1", [:mix], [], "hexpm", "dd3504559b0ddfeb7f55297557313fc05340120a037f981a4775b1c43e61d1b9"},
9+
"nimble_parsec": {:hex, :nimble_parsec, "1.2.2", "b99ca56bbce410e9d5ee4f9155a212e942e224e259c7ebbf8f2c86ac21d4fa3c", [:mix], [], "hexpm", "98d51bd64d5f6a2a9c6bb7586ee8129e27dfaab1140b5a4753f24dac0ba27d2f"},
810
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
defmodule ExDoc.Formatter.HTML.ErlangTest do
2+
use ExUnit.Case
3+
import TestHelper
4+
setup :create_tmp_dir
5+
6+
@moduletag :otp24
7+
8+
test "it works", c do
9+
erlc(c, :foo, ~S"""
10+
%% @doc
11+
%% foo module.
12+
-module(foo).
13+
-export([foo/1]).
14+
-export_type([t/0]).
15+
16+
%% @doc
17+
%% f/0 function.
18+
-spec foo(atom()) -> atom().
19+
foo(X) -> X.
20+
21+
-type t() :: atom().
22+
%% t/0 type.
23+
""")
24+
25+
doc = generate_docs(c)
26+
27+
assert [_] = Floki.find(doc, "pre:fl-contains('foo(atom()) -> atom().')")
28+
29+
assert [_] = Floki.find(doc, "pre:fl-contains('t() :: atom().')")
30+
end
31+
32+
defp generate_docs(c) do
33+
config = [
34+
version: "1.0.0",
35+
project: "Foo",
36+
formatter: "html",
37+
output: Path.join(c.tmp_dir, "doc"),
38+
source_beam: Path.join(c.tmp_dir, "ebin"),
39+
extras: []
40+
]
41+
42+
ExDoc.generate_docs(config[:project], config[:version], config)
43+
[c.tmp_dir, "doc", "foo.html"] |> Path.join() |> File.read!() |> Floki.parse_document!()
44+
end
45+
end

0 commit comments

Comments
 (0)