File tree Expand file tree Collapse file tree 4 files changed +54
-4
lines changed Expand file tree Collapse file tree 4 files changed +54
-4
lines changed Original file line number Diff line number Diff line change @@ -51,8 +51,8 @@ defmodule ExDoc.Config do
51
51
apps: [ atom ( ) ] ,
52
52
assets: nil | String . t ( ) ,
53
53
authors: nil | [ String . t ( ) ] ,
54
- before_closing_body_tag: ( atom ( ) -> String . t ( ) ) | mfa ( ) ,
55
- before_closing_head_tag: ( atom ( ) -> String . t ( ) ) | mfa ( ) ,
54
+ before_closing_body_tag: ( atom ( ) -> String . t ( ) ) | mfa ( ) | map ( ) ,
55
+ before_closing_head_tag: ( atom ( ) -> String . t ( ) ) | mfa ( ) | map ( ) ,
56
56
canonical: nil | String . t ( ) ,
57
57
cover: nil | Path . t ( ) ,
58
58
deps: [ { ebin_path :: String . t ( ) , doc_url :: String . t ( ) } ] ,
Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ defmodule ExDoc.Utils do
8
8
apply ( m , f , [ module | a ] )
9
9
end
10
10
11
+ def before_closing_head_tag ( % { before_closing_head_tag: before_closing_head_tag } , module )
12
+ when is_map ( before_closing_head_tag ) and is_map_key ( before_closing_head_tag , module ) do
13
+ Map . fetch! ( before_closing_head_tag , module )
14
+ end
15
+
11
16
def before_closing_head_tag ( % { before_closing_head_tag: before_closing_head_tag } , module ) do
12
17
before_closing_head_tag . ( module )
13
18
end
@@ -19,6 +24,11 @@ defmodule ExDoc.Utils do
19
24
apply ( m , f , [ module | a ] )
20
25
end
21
26
27
+ def before_closing_body_tag ( % { before_closing_body_tag: before_closing_body_tag } , module )
28
+ when is_map ( before_closing_body_tag ) and is_map_key ( before_closing_body_tag , module ) do
29
+ Map . fetch! ( before_closing_body_tag , module )
30
+ end
31
+
22
32
def before_closing_body_tag ( % { before_closing_body_tag: before_closing_body_tag } , module ) do
23
33
before_closing_body_tag . ( module )
24
34
end
Original file line number Diff line number Diff line change @@ -193,6 +193,25 @@ defmodule ExDoc.Formatter.EPUBTest do
193
193
194
194
test "before_closing_*_tags required by the user are in the right place using MFA" ,
195
195
% { tmp_dir: tmp_dir } = context do
196
+ generate_docs_and_unzip (
197
+ context ,
198
+ doc_config ( context ,
199
+ before_closing_head_tag: % { epub: "<meta name=StaticDemo>" } ,
200
+ before_closing_body_tag: % { epub: "<p>StaticDemo</p>" }
201
+ )
202
+ )
203
+
204
+ oebps_dir = tmp_dir <> "/epub/OEBPS"
205
+
206
+ for basename <- @ example_basenames do
207
+ content = File . read! ( Path . join ( oebps_dir , basename ) )
208
+ assert content =~ ~r[ <meta name=StaticDemo>\s *</head>]
209
+ assert content =~ ~r[ <p>StaticDemo</p>\s *</body>]
210
+ end
211
+ end
212
+
213
+ test "before_closing_*_tags required by the user are in the right place using a map" ,
214
+ % { tmp_dir: tmp_dir } = context do
196
215
generate_docs_and_unzip (
197
216
context ,
198
217
doc_config ( context ,
Original file line number Diff line number Diff line change @@ -547,7 +547,28 @@ defmodule ExDoc.Formatter.HTMLTest do
547
547
refute content_last =~ ~r{ Next Page}
548
548
end
549
549
550
- test "before_closing_*_tags required by the user are placed in the right place" ,
550
+ test "before_closing_*_tags required by the user are placed in the right place using a map" ,
551
+ % {
552
+ tmp_dir: tmp_dir
553
+ } = context do
554
+ generate_docs (
555
+ doc_config ( context ,
556
+ before_closing_head_tag: % { html: "<meta name=StaticDemo>" } ,
557
+ before_closing_body_tag: % { html: "<p>StaticDemo</p>" } ,
558
+ extras: [ "test/fixtures/README.md" ]
559
+ )
560
+ )
561
+
562
+ content = File . read! ( tmp_dir <> "/html/api-reference.html" )
563
+ assert content =~ ~r[ <meta name=StaticDemo>\s *</head>]
564
+ assert content =~ ~r[ <p>StaticDemo</p>\s *</body>]
565
+
566
+ content = File . read! ( tmp_dir <> "/html/readme.html" )
567
+ assert content =~ ~r[ <meta name=StaticDemo>\s *</head>]
568
+ assert content =~ ~r[ <p>StaticDemo</p>\s *</body>]
569
+ end
570
+
571
+ test "before_closing_*_tags required by the user are placed in the right place using MFA" ,
551
572
% {
552
573
tmp_dir: tmp_dir
553
574
} = context do
@@ -568,7 +589,7 @@ defmodule ExDoc.Formatter.HTMLTest do
568
589
assert content =~ ~r[ <p>Demo</p>\s *</body>]
569
590
end
570
591
571
- test "before_closing_*_tags required by the user are placed in the right place using MFA " ,
592
+ test "before_closing_*_tags required by the user are placed in the right place" ,
572
593
% {
573
594
tmp_dir: tmp_dir
574
595
} = context do
You can’t perform that action at this time.
0 commit comments