@@ -166,49 +166,24 @@ defmodule ExDoc.Retriever do
166166
167167 ## Function helpers
168168
169- defp get_docs ( % { type: type , docs: docs } = module_data , source , groups_for_functions ) do
170- { :docs_v1 , _ , _ , _ , _ , _ , doc_elements } = docs
169+ defp get_docs ( module_data , source , groups_for_functions ) do
170+ { :docs_v1 , _ , _ , _ , _ , _ , doc_elements } = module_data . docs
171171
172- function_doc_elements =
173- for doc_element <- doc_elements , doc? ( doc_element , type ) do
174- get_function ( doc_element , source , module_data , groups_for_functions )
175- end
176-
177- filter_defaults ( function_doc_elements )
178- end
179-
180- # TODO: Elixir specific
181- # We are only interested in functions and macros for now
182- defp doc? ( { { kind , _ , _ } , _ , _ , _ , _ } , _ ) when kind not in [ :function , :macro ] do
183- false
184- end
185-
186- # TODO: Elixir specific
187- # Skip impl_for and impl_for! for protocols
188- defp doc? ( { { _ , name , _ } , _ , _ , _ , _ } , :protocol ) when name in [ :impl_for , :impl_for! ] do
189- false
190- end
172+ nodes =
173+ Enum . flat_map ( doc_elements , fn doc_element ->
174+ case module_data . language . function_data ( doc_element , module_data ) do
175+ :skip ->
176+ [ ]
191177
192- # If content is a map, then it is ok.
193- defp doc? ( { _ , _ , _ , % { } , _ } , _ ) do
194- true
195- end
196-
197- # We keep this clause with backwards compatibility with Elixir,
198- # from v1.12+, functions not starting with _ always default to %{}.
199- # TODO: Remove me once we require Elixir v1.12.
200- defp doc? ( { { _ , name , _ } , _ , _ , :none , _ } , _type ) do
201- hd ( Atom . to_charlist ( name ) ) != ?_
202- end
178+ function_data ->
179+ [ get_function ( doc_element , function_data , source , module_data , groups_for_functions ) ]
180+ end
181+ end )
203182
204- # Everything else is hidden.
205- defp doc? ( { _ , _ , _ , _ , _ } , _ ) do
206- false
183+ filter_defaults ( nodes )
207184 end
208185
209- defp get_function ( doc_element , source , module_data , groups_for_functions ) do
210- function_data = module_data . language . function_data ( doc_element , module_data )
211-
186+ defp get_function ( doc_element , function_data , source , module_data , groups_for_functions ) do
212187 { :docs_v1 , _ , _ , content_type , _ , _ , _ } = module_data . docs
213188 { { type , name , arity } , anno , signature , doc_content , metadata } = doc_element
214189 doc_line = anno_line ( anno )
@@ -249,14 +224,14 @@ defmodule ExDoc.Retriever do
249224 for default <- ( arity - defaults ) .. ( arity - 1 ) , do: { name , default }
250225 end
251226
252- defp filter_defaults ( docs ) do
253- Enum . map ( docs , & filter_defaults ( & 1 , docs ) )
227+ defp filter_defaults ( nodes ) do
228+ Enum . map ( nodes , & filter_defaults ( & 1 , nodes ) )
254229 end
255230
256- defp filter_defaults ( doc , docs ) do
257- update_in ( doc . defaults , fn defaults ->
231+ defp filter_defaults ( node , nodes ) do
232+ update_in ( node . defaults , fn defaults ->
258233 Enum . reject ( defaults , fn { name , arity } ->
259- Enum . any? ( docs , & match? ( % { name: ^ name , arity: ^ arity } , & 1 ) )
234+ Enum . any? ( nodes , & match? ( % { name: ^ name , arity: ^ arity } , & 1 ) )
260235 end )
261236 end )
262237 end
0 commit comments