Skip to content

Commit 30d957e

Browse files
committed
epub: fix links to media documents
`ex_doc` was silently falling to link media documents in the _package document_, which describes the rendering of an EPUB publication. The consequence of this is that links from a module (e.g., Application.xhtml) to the extra guides (e.g., Design-related anti-patterns) were broken. I added a unit test to avoid a regression in the future.
1 parent c0cac44 commit 30d957e

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/ex_doc/formatter/epub/templates/content_template.eex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<manifest>
1818
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav scripted"/>
1919
<item id="cover" href="title.xhtml" media-type="application/xhtml+xml" properties="scripted"/>
20-
<%= for {_title, extras} <- extras, extra <- extras do %>
20+
<%= for extra <- extras do %>
2121
<item id="<%= URI.encode extra.id %>" href="<%= URI.encode extra.id %>.xhtml" media-type="application/xhtml+xml" properties="scripted"/>
2222
<% end %>
2323
<%= for node <- modules ++ tasks do %>
@@ -36,7 +36,7 @@
3636
<spine>
3737
<itemref idref="cover"/>
3838
<itemref idref="nav"/>
39-
<%= for {_title, extras} <- extras, extra <- extras do %>
39+
<%= for extra <- extras do %>
4040
<itemref idref="<%= URI.encode extra.id %>"/>
4141
<% end %>
4242
<%= for node <- modules ++ tasks do %>

test/ex_doc/formatter/epub/templates_test.exs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,24 @@ defmodule ExDoc.Formatter.EPUB.TemplatesTest do
8888

8989
assert content =~ ~S|<itemref idref="XPTOModule"/>|
9090
end
91+
92+
test "includes extras as resource" do
93+
node =
94+
%ExDoc.ExtraNode{
95+
id: "changelog",
96+
title: "Changelog",
97+
doc: nil,
98+
type: :extra
99+
}
100+
101+
content =
102+
Templates.content_template(formatter_config(), [], [], [node], "uuid", "datetime", [])
103+
104+
assert content =~
105+
~S|<item id="changelog" href="changelog.xhtml" media-type="application/xhtml+xml" properties="scripted"/>|
106+
107+
assert content =~ ~S|<itemref idref="changelog"/>|
108+
end
91109
end
92110

93111
describe "module_template/2" do

0 commit comments

Comments
 (0)