Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule ExDoc.Mixfile do
{:makeup_html, ">= 0.1.0", optional: true},
{:jason, "~> 1.2", only: :test},
{:floki, "~> 0.0", only: :test},
{:easyhtml, "~> 0.0", only: :test}
{:lazy_html, "~> 0.1.0", only: :test}
]
end

Expand Down
5 changes: 4 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
%{
"cc_precompiler": {:hex, :cc_precompiler, "0.1.10", "47c9c08d8869cf09b41da36538f62bc1abd3e19e41701c2cea2675b53c704258", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "f6e046254e53cd6b41c6bacd70ae728011aa82b2742a80d6e2214855c6e06b22"},
"earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"},
"easyhtml": {:hex, :easyhtml, "0.3.2", "050adfc8074f53b261f7dfe83303d864f1fbf5988245b369f8fdff1bf4c4b3e6", [:mix], [{:floki, "~> 0.35", [hex: :floki, repo: "hexpm", optional: false]}], "hexpm", "b6a936f91612a4870aa3e828cd8da5a08d9e3b6221b4d3012b6ec70b87845d06"},
"elixir_make": {:hex, :elixir_make, "0.9.0", "6484b3cd8c0cee58f09f05ecaf1a140a8c97670671a6a0e7ab4dc326c3109726", [:mix], [], "hexpm", "db23d4fd8b757462ad02f8aa73431a426fe6671c80b200d9710caf3d1dd0ffdb"},
"fine": {:hex, :fine, "0.1.0", "9bb99a5ff9b968f12c3b458fa1277c39e9a620b23a9439103703a25917293871", [:mix], [], "hexpm", "1d6485bf811b95dc6ae3d197c0e6f994880b86167a827983bb29cbfc03a02684"},
"floki": {:hex, :floki, "0.36.2", "a7da0193538c93f937714a6704369711998a51a6164a222d710ebd54020aa7a3", [:mix], [], "hexpm", "a8766c0bc92f074e5cb36c4f9961982eda84c5d2b8e979ca67f5c268ec8ed580"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
"lazy_html": {:hex, :lazy_html, "0.1.0", "619c4c124a7375ecbf66263de90270d221ffc7479afde436717a4e5cceaac954", [:make, :mix], [{:cc_precompiler, "~> 0.1", [hex: :cc_precompiler, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.9.0", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:fine, "~> 0.1.0", [hex: :fine, repo: "hexpm", optional: false]}], "hexpm", "a212f417b0e546055b7d5d72d302fce747b63ac9dfe0cf491c1f9af6d198e256"},
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
"makeup_c": {:hex, :makeup_c, "0.1.1", "14250b1a69770b1892f4113129417a2df098e2a72b9e1477aa9096e9e6c473a6", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "89e9cf45372822d354c19a7e18d77f84cfd70e2d206ac987eb15a1b8357f2869"},
"makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"},
Expand Down
23 changes: 16 additions & 7 deletions test/ex_doc/formatter/html/templates_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
Templates.module_page(mod, config)
end

defp num_nodes_matched(doc, selector) do
import LazyHTML

doc
|> query(selector)
|> to_tree()
|> length()
end

setup %{tmp_dir: tmp_dir} do
File.cp_r!("formatters/html", tmp_dir <> "/html_templates")
File.touch!(tmp_dir <> "/html_templates/dist/sidebar_items-123456.js")
Expand Down Expand Up @@ -497,13 +506,13 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
end
)

doc = EasyHTML.parse!(content)
assert doc["#example-functions a[href='#example-functions']"]
assert doc["#legacy a[href='#legacy']"]
assert doc["#example-functions [id='example/2']"]
refute doc["#legacy [id='example/2']"]
assert doc["#functions [id='example_1/0']"]
refute doc["#functions [id='example/2']"]
doc = LazyHTML.from_document(content)
assert num_nodes_matched(doc, "#example-functions a[href='#example-functions']") == 1
assert num_nodes_matched(doc, "#legacy a[href='#legacy']") == 1
assert num_nodes_matched(doc, "#example-functions [id='example/2']") == 1
assert num_nodes_matched(doc, "#legacy [id='example/2']") == 0
assert num_nodes_matched(doc, "#functions [id='example_1/0']") == 1
assert num_nodes_matched(doc, "#functions [id='example/2']") == 0
end

test "outputs deprecation information", context do
Expand Down
10 changes: 6 additions & 4 deletions test/ex_doc/formatter/html_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ defmodule ExDoc.Formatter.HTMLTest do
end

test "multiple extras with the same name", c do
import LazyHTML

File.mkdir_p!("#{c.tmp_dir}/foo")

File.write!("#{c.tmp_dir}/foo/README.md", """
Expand All @@ -105,11 +107,11 @@ defmodule ExDoc.Formatter.HTMLTest do

generate_docs(config)

foo_content = EasyHTML.parse!(File.read!("#{c.tmp_dir}/html/readme-1.html"))["#content"]
bar_content = EasyHTML.parse!(File.read!("#{c.tmp_dir}/html/readme-2.html"))["#content"]
foo_content = "#{c.tmp_dir}/html/readme-1.html" |> File.read!() |> from_document()
bar_content = "#{c.tmp_dir}/html/readme-2.html" |> File.read!() |> from_document()

assert to_string(foo_content["h1"]) == "README foo"
assert to_string(bar_content["h1"]) == "README bar"
assert foo_content |> query("h1") |> text() == "README foo"
assert bar_content |> query("h1") |> text() == "README bar"
end

test "warns when generating an index.html file with an invalid redirect",
Expand Down