@@ -24,7 +24,6 @@ defmodule ExDoc.Formatter.EPUBTest do
24
24
formatter: "epub" ,
25
25
output: tmp_dir <> "/epub" ,
26
26
source_beam: "test/tmp/beam" ,
27
- extras: [ "test/fixtures/README.md" ] ,
28
27
skip_undefined_reference_warnings_on: [ "Warnings" ]
29
28
]
30
29
end
@@ -63,7 +62,7 @@ defmodule ExDoc.Formatter.EPUBTest do
63
62
assert content =~ ~r{ <html.*lang="fr".*xmlns:epub="http://www.idpf.org/2007/ops">} ms
64
63
end
65
64
66
- test "allows to set the authors of the book " , % { tmp_dir: tmp_dir } = context do
65
+ test "allows to set the authors of the document " , % { tmp_dir: tmp_dir } = context do
67
66
generate_docs_and_unzip ( context , doc_config ( context , authors: [ "John Doe" , "Jane Doe" ] ) )
68
67
69
68
content = File . read! ( tmp_dir <> "/epub/OEBPS/content.opf" )
@@ -108,7 +107,6 @@ defmodule ExDoc.Formatter.EPUBTest do
108
107
assert File . regular? ( "#{ oebps_dir } /content.opf" )
109
108
assert File . regular? ( "#{ oebps_dir } /nav.xhtml" )
110
109
assert File . regular? ( "#{ oebps_dir } /title.xhtml" )
111
- assert File . regular? ( "#{ oebps_dir } /readme.xhtml" )
112
110
assert File . regular? ( "#{ oebps_dir } /CompiledWithDocs.xhtml" )
113
111
assert File . regular? ( "#{ oebps_dir } /CompiledWithDocs.Nested.xhtml" )
114
112
assert [ _ ] = Path . wildcard ( "#{ dist_dir } /epub-*.js" )
@@ -129,7 +127,7 @@ defmodule ExDoc.Formatter.EPUBTest do
129
127
end
130
128
131
129
test "generates the readme file" , % { tmp_dir: tmp_dir } = context do
132
- config = doc_config ( context , main: "README" )
130
+ config = doc_config ( context , main: "README" , extras: [ "test/fixtures/README.md" ] )
133
131
generate_docs_and_unzip ( context , config )
134
132
135
133
content = File . read! ( tmp_dir <> "/epub/OEBPS/readme.xhtml" )
@@ -174,13 +172,13 @@ defmodule ExDoc.Formatter.EPUBTest do
174
172
"CompiledWithDocs.Nested.xhtml"
175
173
]
176
174
177
- test "before_closing_*_tags required by the user are in the right place" ,
178
- % { tmp_dir: tmp_dir } = context do
175
+ test "generates before_closing_*_tags using functions" , % { tmp_dir: tmp_dir } = context do
179
176
generate_docs_and_unzip (
180
177
context ,
181
178
doc_config ( context ,
182
179
before_closing_head_tag: & before_closing_head_tag / 1 ,
183
- before_closing_body_tag: & before_closing_body_tag / 1
180
+ before_closing_body_tag: & before_closing_body_tag / 1 ,
181
+ extras: [ "test/fixtures/README.md" ]
184
182
)
185
183
)
186
184
@@ -193,13 +191,13 @@ defmodule ExDoc.Formatter.EPUBTest do
193
191
end
194
192
end
195
193
196
- test "before_closing_*_tags required by the user are in the right place using map" ,
197
- % { tmp_dir: tmp_dir } = context do
194
+ test "generates before_closing_*_tags using maps" , % { tmp_dir: tmp_dir } = context do
198
195
generate_docs_and_unzip (
199
196
context ,
200
197
doc_config ( context ,
201
198
before_closing_head_tag: % { epub: "<meta name=StaticDemo>" } ,
202
- before_closing_body_tag: % { epub: "<p>StaticDemo</p>" }
199
+ before_closing_body_tag: % { epub: "<p>StaticDemo</p>" } ,
200
+ extras: [ "test/fixtures/README.md" ]
203
201
)
204
202
)
205
203
@@ -212,13 +210,13 @@ defmodule ExDoc.Formatter.EPUBTest do
212
210
end
213
211
end
214
212
215
- test "before_closing_*_tags required by the user are in the right place using a MFA" ,
216
- % { tmp_dir: tmp_dir } = context do
213
+ test "generates before_closing_*_tags using MFA" , % { tmp_dir: tmp_dir } = context do
217
214
generate_docs_and_unzip (
218
215
context ,
219
216
doc_config ( context ,
220
217
before_closing_head_tag: { __MODULE__ , :before_closing_head_tag , [ "Demo" ] } ,
221
- before_closing_body_tag: { __MODULE__ , :before_closing_body_tag , [ "Demo" ] }
218
+ before_closing_body_tag: { __MODULE__ , :before_closing_body_tag , [ "Demo" ] } ,
219
+ extras: [ "test/fixtures/README.md" ]
222
220
)
223
221
)
224
222
@@ -231,7 +229,7 @@ defmodule ExDoc.Formatter.EPUBTest do
231
229
end
232
230
end
233
231
234
- test "assets required by the user end up in the right place " , % { tmp_dir: tmp_dir } = context do
232
+ test "generates assets required by the user" , % { tmp_dir: tmp_dir } = context do
235
233
File . mkdir_p! ( "test/tmp/epub_assets/hello" )
236
234
File . touch! ( "test/tmp/epub_assets/hello/world.png" )
237
235
File . touch! ( "test/tmp/epub_assets/hello/world.pdf" )
@@ -256,43 +254,30 @@ defmodule ExDoc.Formatter.EPUBTest do
256
254
describe "warnings" do
257
255
@ describetag :warnings
258
256
259
- test "multiple warnings are registered when using warnings_as_errors: true" , context do
260
- Utils . unset_warned ( )
261
-
262
- output =
263
- capture_io ( :stderr , fn ->
264
- generate_docs (
265
- doc_config ( context ,
266
- skip_undefined_reference_warnings_on: [ ] ,
267
- warnings_as_errors: true
257
+ for warnings_as_errors <- [ true , false ] do
258
+ test "when warnings_as_errors: #{ warnings_as_errors } " , context do
259
+ Utils . unset_warned ( )
260
+
261
+ output =
262
+ capture_io ( :stderr , fn ->
263
+ generate_docs (
264
+ doc_config ( context ,
265
+ skip_undefined_reference_warnings_on: [ ] ,
266
+ warnings_as_errors: unquote ( warnings_as_errors )
267
+ )
268
268
)
269
- )
270
- end )
271
-
272
- # TODO: remove check when we require Elixir v1.16
273
- if Version . match? ( System . version ( ) , ">= 1.16.0-rc" ) do
274
- assert output =~ ~S| moduledoc `Warnings.bar/0`|
275
- assert output =~ ~S| typedoc `Warnings.bar/0`|
276
- assert output =~ ~S| doc callback `Warnings.bar/0`|
277
- assert output =~ ~S| doc `Warnings.bar/0`|
278
- end
279
-
280
- assert Utils . unset_warned ( )
281
- end
282
-
283
- test "warnings are registered even with warnings_as_errors: false" , context do
284
- Utils . unset_warned ( )
269
+ end )
285
270
286
- capture_io ( :stderr , fn ->
287
- generate_docs (
288
- doc_config ( context ,
289
- skip_undefined_reference_warnings_on: [ ] ,
290
- warnings_as_errors: false
291
- )
292
- )
293
- end )
271
+ # TODO: remove check when we require Elixir v1.16
272
+ if Version . match? ( System . version ( ) , ">= 1.16.0-rc" ) do
273
+ assert output =~ ~S| moduledoc `Warnings.bar/0`|
274
+ assert output =~ ~S| typedoc `Warnings.bar/0`|
275
+ assert output =~ ~S| doc callback `Warnings.bar/0`|
276
+ assert output =~ ~S| doc `Warnings.bar/0`|
277
+ end
294
278
295
- assert Utils . unset_warned ( )
279
+ assert Utils . unset_warned ( )
280
+ end
296
281
end
297
282
end
298
283
end
0 commit comments