Skip to content
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
6 changes: 3 additions & 3 deletions test/ex_doc/formatter/epub_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ defmodule ExDoc.Formatter.EPUBTest do

content = File.read!("#{output_dir()}/OEBPS/readme.xhtml")
assert content =~ ~r{<title>README [^<]*</title>}
assert content =~ ~r{<a href="RandomError.xhtml"><code>RandomError</code>}
assert content =~ ~r{<a href="CustomBehaviourImpl.xhtml#hello/1"><code>CustomBehaviourImpl.hello/1</code>}
assert content =~ ~r{<a href="TypesAndSpecs.Sub.xhtml"><code>TypesAndSpecs.Sub</code></a>}
assert content =~ ~r{<a href="RandomError.xhtml"><code(\sclass="inline")?>RandomError</code>}
assert content =~ ~r{<a href="CustomBehaviourImpl.xhtml#hello/1"><code(\sclass="inline")?>CustomBehaviourImpl.hello/1</code>}
assert content =~ ~r{<a href="TypesAndSpecs.Sub.xhtml"><code(\sclass="inline")?>TypesAndSpecs.Sub</code></a>}

content = File.read!("#{output_dir()}/OEBPS/nav.xhtml")
assert content =~ ~r{<li><a href="readme.xhtml">README</a></li>}
Expand Down
18 changes: 9 additions & 9 deletions test/ex_doc/formatter/html/templates_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do

test "site title text links to homepage_url when set" do
content = Templates.sidebar_template(doc_config(), @empty_nodes_map)
assert content =~ ~r{<a href="#{homepage_url()}" class="sidebar-projectLink">\n\s*<div class="sidebar-projectDetails">\n\s*<h1 class="sidebar-projectName">\n\s*Elixir\n\s*</h1>\n\s*<h2 class="sidebar-projectVersion">\n\s*v1.0.1\n\s*</h2>\n\s*</div>\n\s*</a>}
assert content =~ ~r{<a href="#{homepage_url()}" class="sidebar-projectLink">\s*<div class="sidebar-projectDetails">\s*<h1 class="sidebar-projectName">\s*Elixir\s*</h1>\s*<h2 class="sidebar-projectVersion">\s*v1.0.1\s*</h2>\s*</div>\s*</a>}
end

test "site title text links to main when there is no homepage_url" do
config = %ExDoc.Config{project: "Elixir", version: "1.0.1",
source_root: File.cwd!, main: "hello",}
content = Templates.sidebar_template(config, @empty_nodes_map)
assert content =~ ~r{<a href="hello.html" class="sidebar-projectLink">\n\s*<div class="sidebar-projectDetails">\n\s*<h1 class="sidebar-projectName">\n\s*Elixir\n\s*</h1>\n\s*<h2 class="sidebar-projectVersion">\n\s*v1.0.1\n\s*</h2>\n\s*</div>\n\s*</a>}
assert content =~ ~r{<a href="hello.html" class="sidebar-projectLink">\s*<div class="sidebar-projectDetails">\s*<h1 class="sidebar-projectName">\s*Elixir\s*</h1>\s*<h2 class="sidebar-projectVersion">\s*v1.0.1\s*</h2>\s*</div>\s*</a>}
end

test "list_page enables nav link when module type have at least one element" do
Expand Down Expand Up @@ -206,7 +206,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do

# Title and headers
assert content =~ ~r{<title>CompiledWithDocs [^<]*</title>}
assert content =~ ~r{<h1>\n\s*<small class="visible-xs">Elixir v1.0.1</small>\n\s*CompiledWithDocs\s*}
assert content =~ ~r{<h1>\s*<small class="visible-xs">Elixir v1.0.1</small>\s*CompiledWithDocs\s*}
refute content =~ ~r{<small>module</small>}
assert content =~ ~r{moduledoc.*Example.*CompiledWithDocs\.example.*}ms
assert content =~ ~r{<h2 id="module-example-unicode-escaping" class="section-heading">.*<a href="#module-example-unicode-escaping" class="hover-link">.*<span class="icon-link" aria-hidden="true"></span>.*</a>.*Example.*</h2>}ms
Expand All @@ -217,13 +217,13 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
assert content =~ ~r{example_1/0.*<span class="note">\(macro\)</span>}ms

# Source
assert content =~ ~r{<a href="#{source_url()}/blob/master/test/fixtures/compiled_with_docs.ex#L10"[^>]*>\n\s*<span class="icon-code" aria-hidden="true"></span>\n\s*<span class="sr-only">View Source</span>\n\s*</a>}ms
assert content =~ ~r{<a href="#{source_url()}/blob/master/test/fixtures/compiled_with_docs.ex#L10"[^>]*>\s*<span class="icon-code" aria-hidden="true"></span>\s*<span class="sr-only">View Source</span>\s*</a>}ms

# Functions
assert content =~ ~s{<div class="detail" id="example/2">}
assert content =~ ~s{<span id="example/1"></span>}
assert content =~ ~s{example(foo, bar \\\\ Baz)}
assert content =~ ~r{<a href="#example/2" class="detail-link" title="Link to this function">\n\s*<span class="icon-link" aria-hidden="true"></span>\n\s*<span class="sr-only">Link to this function</span>\n\s*</a>}ms
assert content =~ ~r{<a href="#example/2" class="detail-link" title="Link to this function">\s*<span class="icon-link" aria-hidden="true"></span>\s*<span class="sr-only">Link to this function</span>\s*</a>}ms
end

test "module_page outputs the types and function specs" do
Expand Down Expand Up @@ -261,14 +261,14 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do

test "module_page outputs behavior and callbacks" do
content = get_module_page([CustomBehaviourOne])
assert content =~ ~r{<h1>\n\s*<small class="visible-xs">Elixir v1.0.1</small>\n\s*CustomBehaviourOne\s*<small>behaviour</small>}m
assert content =~ ~r{<h1>\s*<small class="visible-xs">Elixir v1.0.1</small>\s*CustomBehaviourOne\s*<small>behaviour</small>}m
assert content =~ ~r{Callbacks}
assert content =~ ~r{<div class="detail" id="c:hello/1">}
assert content =~ ~s[hello(integer)]
assert content =~ ~s[greet(arg0)]

content = get_module_page([CustomBehaviourTwo])
assert content =~ ~r{<h1>\n\s*<small class="visible-xs">Elixir v1.0.1</small>\n\s*CustomBehaviourTwo\s*<small>behaviour</small>\s*}m
assert content =~ ~r{<h1>\s*<small class="visible-xs">Elixir v1.0.1</small>\s*CustomBehaviourTwo\s*<small>behaviour</small>\s*}m
assert content =~ ~r{Callbacks}
assert content =~ ~r{<div class="detail" id="c:bye/1">}
end
Expand All @@ -277,13 +277,13 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do

test "module_page outputs the protocol type" do
content = get_module_page([CustomProtocol])
assert content =~ ~r{<h1>\n\s*<small class="visible-xs">Elixir v1.0.1</small>\n\s*CustomProtocol\s*<small>protocol</small>\s*}m
assert content =~ ~r{<h1>\s*<small class="visible-xs">Elixir v1.0.1</small>\s*CustomProtocol\s*<small>protocol</small>\s*}m
end

## TASKS

test "module_page outputs the task type" do
content = get_module_page([Mix.Tasks.TaskWithDocs])
assert content =~ ~r{<h1>\n\s*<small class="visible-xs">Elixir v1.0.1</small>\n\s*mix task_with_docs\s*}m
assert content =~ ~r{<h1>\s*<small class="visible-xs">Elixir v1.0.1</small>\s*mix task_with_docs\s*}m
end
end
8 changes: 4 additions & 4 deletions test/ex_doc/formatter/html_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ defmodule ExDoc.Formatter.HTMLTest do

content = File.read!("#{output_dir()}/readme.html")
assert content =~ ~r{<title>README [^<]*</title>}
assert content =~ ~r{<h2 id="header-sample" class="section-heading">.*<a href="#header-sample" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>.*<code>Header</code> sample.*</h2>}ms
assert content =~ ~r{<h2 id="header-sample" class="section-heading">.*<a href="#header-sample" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>.*<code(\sclass="inline")?>Header</code> sample.*</h2>}ms
assert content =~ ~r{<h2 id="more-than" class="section-heading">.*<a href="#more-than" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>.*more &gt; than.*</h2>}ms
assert content =~ ~r{<a href="RandomError.html"><code>RandomError</code>}
assert content =~ ~r{<a href="CustomBehaviourImpl.html#hello/1"><code>CustomBehaviourImpl.hello/1</code>}
assert content =~ ~r{<a href="TypesAndSpecs.Sub.html"><code>TypesAndSpecs.Sub</code></a>}
assert content =~ ~r{<a href="RandomError.html"><code(\sclass="inline")?>RandomError</code>}
assert content =~ ~r{<a href="CustomBehaviourImpl.html#hello/1"><code(\sclass="inline")?>CustomBehaviourImpl.hello/1</code>}
assert content =~ ~r{<a href="TypesAndSpecs.Sub.html"><code(\sclass="inline")?>TypesAndSpecs.Sub</code></a>}
end

test "run generates pages with custom names" do
Expand Down