@@ -23,16 +23,16 @@ defmodule ExDoc.Config do
2323 before_closing_head_tag: & __MODULE__ . before_closing_head_tag / 1 ,
2424 canonical: nil ,
2525 cover: nil ,
26- default_group_for_doc: & __MODULE__ . default_group_for_doc / 1 ,
2726 deps: [ ] ,
27+ docs_groups: [ ] ,
2828 extra_section: nil ,
2929 extras: [ ] ,
3030 favicon: nil ,
3131 filter_modules: & __MODULE__ . filter_modules / 2 ,
3232 formatter: "html" ,
3333 formatters: [ ] ,
34+ group_for_doc: & __MODULE__ . default_group_for_doc / 1 ,
3435 groups_for_extras: [ ] ,
35- groups_for_docs: [ ] ,
3636 groups_for_modules: [ ] ,
3737 homepage_url: nil ,
3838 language: "en" ,
@@ -67,16 +67,16 @@ defmodule ExDoc.Config do
6767 before_closing_head_tag: ( atom ( ) -> String . t ( ) ) | mfa ( ) | map ( ) ,
6868 canonical: nil | String . t ( ) ,
6969 cover: nil | Path . t ( ) ,
70- default_group_for_doc: ( keyword ( ) -> String . t ( ) | nil ) ,
7170 deps: [ { ebin_path :: String . t ( ) , doc_url :: String . t ( ) } ] ,
71+ docs_groups: [ String . t ( ) ] ,
7272 extra_section: nil | String . t ( ) ,
7373 extras: list ( ) ,
7474 favicon: nil | Path . t ( ) ,
7575 filter_modules: ( module , map -> boolean ) ,
7676 formatter: nil | String . t ( ) ,
7777 formatters: [ String . t ( ) ] ,
78+ group_for_doc: ( keyword ( ) -> String . t ( ) | nil ) ,
7879 groups_for_extras: [ { binary ( ) , term ( ) } ] ,
79- groups_for_docs: [ { binary ( ) , ( keyword ( ) -> boolean ) } ] ,
8080 groups_for_modules: [ { binary ( ) , term ( ) } ] ,
8181 homepage_url: nil | String . t ( ) ,
8282 language: String . t ( ) ,
@@ -113,13 +113,17 @@ defmodule ExDoc.Config do
113113 options
114114 end
115115
116+ apps = Keyword . get ( options , :apps , [ ] )
117+
116118 { groups_for_docs , options } = Keyword . pop ( options , :groups_for_docs , [ ] )
117119 { groups_for_extras , options } = Keyword . pop ( options , :groups_for_extras , [ ] )
118- apps = Keyword . get ( options , :apps , [ ] )
119120
120121 { groups_for_modules , options } =
121122 Keyword . pop ( options , :groups_for_modules , default_groups_for_modules ( apps ) )
122123
124+ { default_group_for_doc , options } =
125+ Keyword . pop ( options , :default_group_for_doc , & default_group_for_doc / 1 )
126+
123127 { skip_undefined_reference_warnings_on , options } =
124128 Keyword . pop (
125129 options ,
@@ -137,7 +141,8 @@ defmodule ExDoc.Config do
137141
138142 preconfig = % __MODULE__ {
139143 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 ) ,
141146 groups_for_extras: normalize_groups ( groups_for_extras ) ,
142147 groups_for_modules:
143148 normalize_groups (
@@ -176,6 +181,16 @@ defmodule ExDoc.Config do
176181 raise ArgumentError , "#{ inspect ( proglang ) } is not supported"
177182 end
178183
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+
179194 defp normalize_groups ( groups ) do
180195 for { k , v } <- groups , do: { to_string ( k ) , v }
181196 end
0 commit comments