Skip to content

Commit 43efab8

Browse files
committed
Print undocumented functions to console while generating docs
1 parent ef70b5a commit 43efab8

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

datafusion/core/src/bin/print_functions_docs.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@ use datafusion_expr::{
2020
aggregate_doc_sections, scalar_doc_sections, window_doc_sections, AggregateUDF,
2121
DocSection, Documentation, ScalarUDF, WindowUDF,
2222
};
23+
use hashbrown::HashSet;
2324
use itertools::Itertools;
2425
use std::env::args;
2526
use std::fmt::Write as _;
2627

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`
2733
fn main() {
2834
let args: Vec<String> = args().collect();
2935

@@ -83,9 +89,12 @@ fn print_docs(
8389
) -> String {
8490
let mut docs = "".to_string();
8591

92+
// Ensure that all providers have documentation
93+
let mut providers_with_no_docs = HashSet::new();
94+
8695
// doc sections only includes sections that have 'include' == true
8796
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
8998
if !&providers.iter().any(|f| {
9099
if let Some(documentation) = f.get_documentation() {
91100
documentation.doc_section == doc_section
@@ -96,12 +105,14 @@ fn print_docs(
96105
continue;
97106
}
98107

108+
// filter out functions that are not in this doc section
99109
let providers: Vec<&Box<dyn DocProvider>> = providers
100110
.iter()
101111
.filter(|&f| {
102112
if let Some(documentation) = f.get_documentation() {
103113
documentation.doc_section == doc_section
104114
} else {
115+
providers_with_no_docs.insert(f.get_name());
105116
false
106117
}
107118
})
@@ -202,9 +213,19 @@ fn print_docs(
202213
}
203214
}
204215

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+
205225
docs
206226
}
207227

228+
/// Trait for accessing name / aliases / documentation for differnet functions
208229
trait DocProvider {
209230
fn get_name(&self) -> String;
210231
fn get_aliases(&self) -> Vec<String>;

0 commit comments

Comments
 (0)