Skip to content

Commit

Permalink
Remove links from module page “hover link” headings in EPUB
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidOliver committed Sep 11, 2023
1 parent 960e2ef commit 08a7bdf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
14 changes: 2 additions & 12 deletions lib/ex_doc/formatter/epub/templates/module_template.eex
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,14 @@

<%= if summary != [] do %>
<section id="summary" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#summary">
<i class="ri-link-m" aria-hidden="true"></i>
Summary
</a>
</h1>
<h1 class="section-heading">Summary</h1>
<%= for {name, nodes} <- summary, do: H.summary_template(name, nodes) %>
</section>
<% end %>

<%= for {name, nodes} <- summary, key = HTML.text_to_id(name) do %>
<section id="<%= key %>" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#<%= key %>">
<i class="ri-link-m" aria-hidden="true"></i>
<%= name %>
</a>
</h1>
<h1 class="section-heading"><%= name %></h1>
<div class="<%= key %>-list">
<%= for node <- nodes, do: H.detail_template(node, module) %>
</div>
Expand Down
6 changes: 4 additions & 2 deletions test/ex_doc/formatter/epub/templates_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ defmodule ExDoc.Formatter.EPUB.TemplatesTest do
assert content =~ ~r{<title>CompiledWithDocs [^<]*</title>}
assert content =~ ~r{<h1 id="content">\s*CompiledWithDocs\s*}

assert content =~ ~s{<h1 class="section-heading">Summary</h1>}

assert content =~
~r{<h2 id="module-example-unicode-escaping" class="section-heading">.*<a href="#module-example-unicode-escaping">.*<i class="ri-link-m" aria-hidden="true"></i>.*Example.*</a>.*</h2>}ms

Expand All @@ -85,8 +87,8 @@ defmodule ExDoc.Formatter.EPUB.TemplatesTest do
]
)

assert content =~ ~r{id="example-functions".*href="#example-functions".*Example functions}ms
assert content =~ ~r{id="legacy".*href="#legacy".*Legacy}ms
assert content =~ ~r{id="example-functions".*Example functions}ms
assert content =~ ~r{id="legacy".*Legacy}ms
assert content =~ ~r{id="example-functions".*id="example/2"}ms
refute content =~ ~r{id="legacy".*id="example/2"}ms
refute content =~ ~r{id="functions".*id="example/2"}ms
Expand Down

0 comments on commit 08a7bdf

Please sign in to comment.