Skip to content

Commit

Permalink
Keep settings and module source on top if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jan 11, 2022
1 parent 5488420 commit 9b58f96
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/ex_doc/formatter/html/templates/extra_template.eex
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<%= sidebar_template(config, nodes_map) %>

<h1>
<span><%= node.title_content %></span>
<%= settings_button_template() %>
<%= if node.source_url do %>
<a href="<%= node.source_url %>" title="View Source" class="view-source" rel="help">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
<% end %>
<span><%= node.title_content %></span>
</h1>

<%= if node.source_path && String.ends_with?(node.source_path, ".livemd") do %>
Expand Down
4 changes: 2 additions & 2 deletions lib/ex_doc/formatter/html/templates/module_template.eex
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<%= sidebar_template(config, nodes_map) %>

<h1>
<span translate="no"><%= module.title %></span> <%= module_type(module) %>
<small class="app-vsn" translate="no">(<%= config.project %> v<%= config.version %>)</small>
<%= settings_button_template() %>
<%= if module.source_url do %>
<a href="<%= module.source_url %>" title="View Source" class="view-source" rel="help">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
<% end %>
<span translate="no"><%= module.title %></span> <%= module_type(module) %>
<small class="app-vsn" translate="no">(<%= config.project %> v<%= config.version %>)</small>
<%= for annotation <- module.annotations do %>
<span class="note">(<%= annotation %>)</span>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_doc/formatter/html/templates/not_found_template.eex
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<%= sidebar_template(config, nodes_map) %>

<h1>
<span>Page not found</span>
<%= settings_button_template() %>
<span>Page not found</span>
</h1>

<p>Sorry, but the page you were trying to get to, does not exist. You
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_doc/formatter/html/templates/search_template.eex
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

<div id="search">
<h1>
<span>Page not found</span>
<%= settings_button_template() %>
<span>Page not found</span>
</h1>

<div class="loading"><div></div><div></div><div></div><div></div></div>
Expand Down
10 changes: 5 additions & 5 deletions test/ex_doc/formatter/html/templates_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
assert content =~ ~r{<title>CompiledWithDocs [^<]*</title>}

assert content =~
~r{<h1>\s*<span translate="no">CompiledWithDocs</span>\s*<small class=\"app-vsn\" translate="no">\(Elixir v1.0.1\)</small>}
~r{<span translate="no">CompiledWithDocs</span>\s*<small class=\"app-vsn\" translate="no">\(Elixir v1.0.1\)</small>}

refute content =~ ~r{<small>module</small>}

Expand Down Expand Up @@ -440,7 +440,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
content = get_module_page([CustomBehaviourOne])

assert content =~
~r{<h1>\s*<span translate="no">CustomBehaviourOne</span>\s*<small>behaviour</small>\s*<small class="app-vsn" translate="no">\(Elixir v1.0.1\)</small>}
~r{<span translate="no">CustomBehaviourOne</span>\s*<small>behaviour</small>\s*<small class="app-vsn" translate="no">\(Elixir v1.0.1\)</small>\s*</h1>}

assert content =~ ~r{Callbacks}
assert content =~ ~r{<section class="detail" id="c:hello/1">}
Expand All @@ -450,7 +450,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
content = get_module_page([CustomBehaviourTwo])

assert content =~
~r{<h1>\s*<span translate="no">CustomBehaviourTwo</span>\s*<small>behaviour</small>\s*<small class="app-vsn" translate="no">\(Elixir v1.0.1\)</small>}
~r{<span translate="no">CustomBehaviourTwo</span>\s*<small>behaviour</small>\s*<small class="app-vsn" translate="no">\(Elixir v1.0.1\)</small>\s*</h1>}

assert content =~ ~r{Callbacks}
assert content =~ ~r{<section class="detail" id="c:bye/1">}
Expand All @@ -462,7 +462,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
content = get_module_page([CustomProtocol])

assert content =~
~r{<h1>\s*<span translate="no">CustomProtocol</span>\s*<small>protocol</small>\s*<small class=\"app-vsn\" translate="no">\(Elixir v1.0.1\)</small>}
~r{<span translate="no">CustomProtocol</span>\s*<small>protocol</small>\s*<small class=\"app-vsn\" translate="no">\(Elixir v1.0.1\)</small>\s*</h1>}
end

## TASKS
Expand All @@ -471,7 +471,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
content = get_module_page([Mix.Tasks.TaskWithDocs])

assert content =~
~r{<h1>\s*<span translate="no">mix task_with_docs</span>\s*<small class="app-vsn" translate="no">\(Elixir v1.0.1\)</small>}
~r{<span translate="no">mix task_with_docs</span>\s*<small class="app-vsn" translate="no">\(Elixir v1.0.1\)</small>\s*</h1>}
end
end

Expand Down

0 comments on commit 9b58f96

Please sign in to comment.