@@ -23,16 +23,16 @@ defmodule ExDoc.Config do
23
23
before_closing_head_tag: & __MODULE__ . before_closing_head_tag / 1 ,
24
24
canonical: nil ,
25
25
cover: nil ,
26
- default_group_for_doc: & __MODULE__ . default_group_for_doc / 1 ,
27
26
deps: [ ] ,
27
+ docs_groups: [ ] ,
28
28
extra_section: nil ,
29
29
extras: [ ] ,
30
30
favicon: nil ,
31
31
filter_modules: & __MODULE__ . filter_modules / 2 ,
32
32
formatter: "html" ,
33
33
formatters: [ ] ,
34
+ group_for_doc: & __MODULE__ . default_group_for_doc / 1 ,
34
35
groups_for_extras: [ ] ,
35
- groups_for_docs: [ ] ,
36
36
groups_for_modules: [ ] ,
37
37
homepage_url: nil ,
38
38
language: "en" ,
@@ -67,16 +67,16 @@ defmodule ExDoc.Config do
67
67
before_closing_head_tag: ( atom ( ) -> String . t ( ) ) | mfa ( ) | map ( ) ,
68
68
canonical: nil | String . t ( ) ,
69
69
cover: nil | Path . t ( ) ,
70
- default_group_for_doc: ( keyword ( ) -> String . t ( ) | nil ) ,
71
70
deps: [ { ebin_path :: String . t ( ) , doc_url :: String . t ( ) } ] ,
71
+ docs_groups: [ String . t ( ) ] ,
72
72
extra_section: nil | String . t ( ) ,
73
73
extras: list ( ) ,
74
74
favicon: nil | Path . t ( ) ,
75
75
filter_modules: ( module , map -> boolean ) ,
76
76
formatter: nil | String . t ( ) ,
77
77
formatters: [ String . t ( ) ] ,
78
+ group_for_doc: ( keyword ( ) -> String . t ( ) | nil ) ,
78
79
groups_for_extras: [ { binary ( ) , term ( ) } ] ,
79
- groups_for_docs: [ { binary ( ) , ( keyword ( ) -> boolean ) } ] ,
80
80
groups_for_modules: [ { binary ( ) , term ( ) } ] ,
81
81
homepage_url: nil | String . t ( ) ,
82
82
language: String . t ( ) ,
@@ -113,13 +113,17 @@ defmodule ExDoc.Config do
113
113
options
114
114
end
115
115
116
+ apps = Keyword . get ( options , :apps , [ ] )
117
+
116
118
{ groups_for_docs , options } = Keyword . pop ( options , :groups_for_docs , [ ] )
117
119
{ groups_for_extras , options } = Keyword . pop ( options , :groups_for_extras , [ ] )
118
- apps = Keyword . get ( options , :apps , [ ] )
119
120
120
121
{ groups_for_modules , options } =
121
122
Keyword . pop ( options , :groups_for_modules , default_groups_for_modules ( apps ) )
122
123
124
+ { default_group_for_doc , options } =
125
+ Keyword . pop ( options , :default_group_for_doc , & default_group_for_doc / 1 )
126
+
123
127
{ skip_undefined_reference_warnings_on , options } =
124
128
Keyword . pop (
125
129
options ,
@@ -137,7 +141,8 @@ defmodule ExDoc.Config do
137
141
138
142
preconfig = % __MODULE__ {
139
143
filter_modules: normalize_filter_modules ( filter_modules ) ,
140
- groups_for_docs: normalize_groups ( groups_for_docs ) ,
144
+ docs_groups: for ( { group , _ } <- groups_for_docs , do: to_string ( group ) ) ,
145
+ group_for_doc: normalize_groups_for_docs ( groups_for_docs , default_group_for_doc ) ,
141
146
groups_for_extras: normalize_groups ( groups_for_extras ) ,
142
147
groups_for_modules:
143
148
normalize_groups (
@@ -176,6 +181,16 @@ defmodule ExDoc.Config do
176
181
raise ArgumentError , "#{ inspect ( proglang ) } is not supported"
177
182
end
178
183
184
+ defp normalize_groups_for_docs ( groups , default ) do
185
+ groups = normalize_groups ( groups )
186
+
187
+ fn metadata ->
188
+ Enum . find_value ( groups , fn { group , function } ->
189
+ function . ( metadata ) && group
190
+ end ) || default . ( metadata )
191
+ end
192
+ end
193
+
179
194
defp normalize_groups ( groups ) do
180
195
for { k , v } <- groups , do: { to_string ( k ) , v }
181
196
end
0 commit comments