@@ -20,10 +20,16 @@ use datafusion_expr::{
20
20
aggregate_doc_sections, scalar_doc_sections, window_doc_sections, AggregateUDF ,
21
21
DocSection , Documentation , ScalarUDF , WindowUDF ,
22
22
} ;
23
+ use hashbrown:: HashSet ;
23
24
use itertools:: Itertools ;
24
25
use std:: env:: args;
25
26
use std:: fmt:: Write as _;
26
27
28
+ /// Print documentation for all functions of a given type to stdout
29
+ ///
30
+ /// Usage: `cargo run --bin print_functions_docs -- <type>`
31
+ ///
32
+ /// Called from `dev/update_function_docs.sh`
27
33
fn main ( ) {
28
34
let args: Vec < String > = args ( ) . collect ( ) ;
29
35
@@ -83,9 +89,12 @@ fn print_docs(
83
89
) -> String {
84
90
let mut docs = "" . to_string ( ) ;
85
91
92
+ // Ensure that all providers have documentation
93
+ let mut providers_with_no_docs = HashSet :: new ( ) ;
94
+
86
95
// doc sections only includes sections that have 'include' == true
87
96
for doc_section in doc_sections {
88
- // make sure there is a function that is in this doc section
97
+ // make sure there is at least one function that is in this doc section
89
98
if !& providers. iter ( ) . any ( |f| {
90
99
if let Some ( documentation) = f. get_documentation ( ) {
91
100
documentation. doc_section == doc_section
@@ -96,12 +105,14 @@ fn print_docs(
96
105
continue ;
97
106
}
98
107
108
+ // filter out functions that are not in this doc section
99
109
let providers: Vec < & Box < dyn DocProvider > > = providers
100
110
. iter ( )
101
111
. filter ( |& f| {
102
112
if let Some ( documentation) = f. get_documentation ( ) {
103
113
documentation. doc_section == doc_section
104
114
} else {
115
+ providers_with_no_docs. insert ( f. get_name ( ) ) ;
105
116
false
106
117
}
107
118
} )
@@ -202,9 +213,19 @@ fn print_docs(
202
213
}
203
214
}
204
215
216
+ // If there are any functions that do not have documentation, print them out
217
+ // eventually make this an error: https://github.com/apache/datafusion/issues/12872
218
+ if !providers_with_no_docs. is_empty ( ) {
219
+ eprintln ! ( "INFO: The following functions do not have documentation:" ) ;
220
+ for f in providers_with_no_docs {
221
+ eprintln ! ( " - {f}" ) ;
222
+ }
223
+ }
224
+
205
225
docs
206
226
}
207
227
228
+ /// Trait for accessing name / aliases / documentation for differnet functions
208
229
trait DocProvider {
209
230
fn get_name ( & self ) -> String ;
210
231
fn get_aliases ( & self ) -> Vec < String > ;
0 commit comments