Skip to content

Commit

Permalink
epub fixes, closes #2087
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Feb 2, 2025
1 parent 4f7580a commit d0ea964
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 35 deletions.
2 changes: 1 addition & 1 deletion assets/js/tooltips/tooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import tooltipBodyTemplate from '../handlebars/templates/tooltip-body.handlebars
const TOOLTIP_HTML = '<div class="tooltip"><div class="tooltip-body"></div></div>'

// Elements that can activate the tooltip.
const TOOLTIP_ACTIVATORS_SELECTOR = '.content a:not([data-no-tooltip])'
const TOOLTIP_ACTIVATORS_SELECTOR = '.content a:not([data-no-tooltip=""])'
// Tooltip root element.
const TOOLTIP_SELECTOR = '.tooltip'
// Tooltip content element.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions lib/ex_doc/formatter/epub/templates.ex
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,6 @@ defmodule ExDoc.Formatter.EPUB.Templates do
trim: true
)

EEx.function_from_file(
:defp,
:nav_item_template,
Path.expand("templates/nav_item_template.eex", __DIR__),
[:name, :nodes],
trim: true
)

EEx.function_from_file(
:defp,
:nav_grouped_item_template,
Expand Down
9 changes: 0 additions & 9 deletions lib/ex_doc/formatter/epub/templates/nav_item_template.eex

This file was deleted.

25 changes: 15 additions & 10 deletions lib/ex_doc/formatter/epub/templates/nav_template.eex
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@
<h1>Table of contents</h1>
<nav epub:type="toc">
<ol>
<%= nav_grouped_item_template config.extras %>
<%= nav_grouped_item_template config.extras %>

<%= unless Enum.empty?(nodes.modules) do %>
<%= if nodes.modules != [] do %>
<li>
<ol>
<li><span>Modules</span>
<ol>
<%= nav_grouped_item_template nodes.modules %>
</ol>
</li>
</ol>
<span>Modules</span>
<ol><%= nav_grouped_item_template nodes.modules %></ol>
</li>
<% end %>
<%= nav_item_template "Mix Tasks", nodes.tasks %>

<%= if nodes.tasks != [] do %>
<li>
<span>Mix Tasks</span>
<ol>
<%= for node <- nodes.tasks do %>
<li><a href="<%= URI.encode node.id %>.xhtml"><%=h node.title %></a></li>
<% end %>
</ol>
</li>
<% end %>
</ol>
</nav>
<%= before_closing_body_tag(config, :epub) %>
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_doc/formatter/html/templates/detail_template.eex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<span id="<%=enc "#{default_name}/#{default_arity}" %>"></span>
<% end %>
<div class="detail-header">
<a href="#<%=enc node.id %>" class="detail-link" data-no-tooltip aria-label="Link to this <%= pretty_type(node) %>">
<a href="#<%=enc node.id %>" class="detail-link" data-no-tooltip="" aria-label="Link to this <%= pretty_type(node) %>">
<i class="ri-link-m" aria-hidden="true"></i>
</a>
<div class="heading-with-actions">
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_doc/formatter/html/templates/summary_template.eex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= for node <- nodes do %>
<div class="summary-row">
<div class="summary-signature">
<a href="#<%=enc node.id %>" data-no-tooltip translate="no"><%=h node.signature %></a>
<a href="#<%=enc node.id %>" data-no-tooltip="" translate="no"><%=h node.signature %></a>
<%= if deprecated = node.deprecated do %>
<span class="deprecated" title="<%= h(deprecated) %>">deprecated</span>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion test/ex_doc/formatter/epub/templates_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ defmodule ExDoc.Formatter.EPUB.TemplatesTest do
content = get_module_page([CompiledWithDocs])

assert content =~
~r{<div class="summary-signature">\s*<a href="#example_1/0" data-no-tooltip translate="no">}
~r{<div class="summary-signature">\s*<a href="#example_1/0" data-no-tooltip="" translate="no">}
end

test "contains links to summary sections when those exist" do
Expand Down
6 changes: 3 additions & 3 deletions test/ex_doc/formatter/html/templates_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
assert content =~ ~s{example(foo, bar \\\\ Baz)}

assert content =~
~r{<a href="#example/2" class="detail-link" data-no-tooltip aria-label="Link to this function">\s*<i class="ri-link-m" aria-hidden="true"></i>\s*</a>}ms
~r{<a href="#example/2" class="detail-link" data-no-tooltip="" aria-label="Link to this function">\s*<i class="ri-link-m" aria-hidden="true"></i>\s*</a>}ms
end

test "outputs function groups", context do
Expand Down Expand Up @@ -519,7 +519,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
~S[<a href="TypesAndSpecs.Sub.html#t:t/0">TypesAndSpecs.Sub.t</a>(), ] <>
~S[<a href="#t:opaque/0">opaque</a>(), :ok | :error}]

assert content =~ ~s[<a href="#t:public/1" data-no-tooltip translate="no">public(t)</a>]
assert content =~ ~s[<a href="#t:public/1" data-no-tooltip="" translate="no">public(t)</a>]
refute content =~ ~s[<a href="#t:private/0">private</a>]
assert content =~ public_html
refute content =~ ~s[<strong>private\(t\)]
Expand All @@ -538,7 +538,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
content = get_module_page([CompiledWithDocs], context)

assert content =~
~r{<div class="summary-signature">\s*<a href="#example_1/0" data-no-tooltip translate="no">}
~r{<div class="summary-signature">\s*<a href="#example_1/0" data-no-tooltip="" translate="no">}
end

test "contains links to summary sections when those exist", context do
Expand Down

0 comments on commit d0ea964

Please sign in to comment.