@@ -3,6 +3,7 @@ defmodule ExDoc.Config do
33
44 # Defaults
55 @ default_source_ref "main"
6+ def default_group_for_doc ( metadata ) , do: metadata [ :group ]
67 def filter_modules ( _module , _metadata ) , do: true
78 def before_closing_head_tag ( _ ) , do: ""
89 def before_closing_footer_tag ( _ ) , do: ""
@@ -21,6 +22,7 @@ defmodule ExDoc.Config do
2122 before_closing_head_tag: & __MODULE__ . before_closing_head_tag / 1 ,
2223 canonical: nil ,
2324 cover: nil ,
25+ default_group_for_doc: & __MODULE__ . default_group_for_doc / 1 ,
2426 deps: [ ] ,
2527 extra_section: nil ,
2628 extras: [ ] ,
@@ -63,15 +65,16 @@ defmodule ExDoc.Config do
6365 before_closing_head_tag: ( atom ( ) -> String . t ( ) ) | mfa ( ) | map ( ) ,
6466 canonical: nil | String . t ( ) ,
6567 cover: nil | Path . t ( ) ,
68+ default_group_for_doc: ( keyword ( ) -> String . t ( ) | nil ) ,
6669 deps: [ { ebin_path :: String . t ( ) , doc_url :: String . t ( ) } ] ,
6770 extra_section: nil | String . t ( ) ,
6871 extras: list ( ) ,
6972 filter_modules: ( module , map -> boolean ) ,
7073 formatter: nil | String . t ( ) ,
7174 formatters: [ String . t ( ) ] ,
72- groups_for_extras: keyword ( ) ,
73- groups_for_docs: keyword ( ( keyword ( ) -> boolean ) ) ,
74- groups_for_modules: keyword ( ) ,
75+ groups_for_extras: [ { binary ( ) , term ( ) } ] ,
76+ groups_for_docs: [ { binary ( ) , ( keyword ( ) -> boolean ) } ] ,
77+ groups_for_modules: [ { binary ( ) , term ( ) } ] ,
7578 homepage_url: nil | String . t ( ) ,
7679 language: String . t ( ) ,
7780 logo: nil | Path . t ( ) ,
@@ -96,7 +99,6 @@ defmodule ExDoc.Config do
9699 @ spec build ( String . t ( ) , String . t ( ) , Keyword . t ( ) ) :: ExDoc.Config . t ( )
97100 def build ( project , vsn , options ) do
98101 { output , options } = Keyword . pop ( options , :output , "./doc" )
99- { groups_for_modules , options } = Keyword . pop ( options , :groups_for_modules , [ ] )
100102 { nest_modules_by_prefix , options } = Keyword . pop ( options , :nest_modules_by_prefix , [ ] )
101103 { proglang , options } = Keyword . pop ( options , :proglang , :elixir )
102104 { filter_modules , options } = Keyword . pop ( options , :filter_modules , & filter_modules / 2 )
@@ -109,6 +111,10 @@ defmodule ExDoc.Config do
109111 options
110112 end
111113
114+ { groups_for_docs , options } = Keyword . pop ( options , :groups_for_docs , [ ] )
115+ { groups_for_extras , options } = Keyword . pop ( options , :groups_for_extras , [ ] )
116+ { groups_for_modules , options } = Keyword . pop ( options , :groups_for_modules , [ ] )
117+
112118 { skip_undefined_reference_warnings_on , options } =
113119 Keyword . pop (
114120 options ,
@@ -126,7 +132,13 @@ defmodule ExDoc.Config do
126132
127133 preconfig = % __MODULE__ {
128134 filter_modules: normalize_filter_modules ( filter_modules ) ,
129- groups_for_modules: normalize_groups_for_modules ( groups_for_modules ) ,
135+ groups_for_docs: normalize_groups ( groups_for_docs ) ,
136+ groups_for_extras: normalize_groups ( groups_for_extras ) ,
137+ groups_for_modules:
138+ normalize_groups (
139+ # TODO: The default module groups must be returned by the language
140+ groups_for_modules ++ [ Deprecated: & deprecated? / 1 , Exceptions: & exception? / 1 ]
141+ ) ,
130142 homepage_url: options [ :homepage_url ] ,
131143 main: options [ :main ] ,
132144 nest_modules_by_prefix: normalize_nest_modules_by_prefix ( nest_modules_by_prefix ) ,
@@ -159,12 +171,8 @@ defmodule ExDoc.Config do
159171 raise ArgumentError , "#{ inspect ( proglang ) } is not supported"
160172 end
161173
162- # TODO: The default module groups must be returned by the language
163- defp normalize_groups_for_modules ( groups_for_modules ) do
164- default_groups = [ Deprecated: & deprecated? / 1 , Exceptions: & exception? / 1 ]
165-
166- groups_for_modules ++
167- Enum . reject ( default_groups , fn { k , _ } -> Keyword . has_key? ( groups_for_modules , k ) end )
174+ defp normalize_groups ( groups ) do
175+ for { k , v } <- groups , do: { to_string ( k ) , v }
168176 end
169177
170178 defp deprecated? ( metadata ) , do: metadata [ :deprecated ] != nil
0 commit comments