Apache DataFusion SQL Query Engine
Print undocumented functions to console while generating docs (#12874)
Andrew Lamb21cb3573c741
diff --git a/datafusion/core/src/bin/print_functions_docs.rs b/datafusion/core/src/bin/print_functions_docs.rsindex d9415028c1..d87c3cefe6 100644--- a/datafusion/core/src/bin/print_functions_docs.rs+++ b/datafusion/core/src/bin/print_functions_docs.rs@@ -20,10 +20,16 @@ use datafusion_expr::{aggregate_doc_sections, scalar_doc_sections, window_doc_sections, AggregateUDF,DocSection, Documentation, ScalarUDF, WindowUDF,};+use hashbrown::HashSet;use itertools::Itertools;use std::env::args;use std::fmt::Write as _;+/// Print documentation for all functions of a given type to stdout+///+/// Usage: `cargo run --bin print_functions_docs -- <type>`+///+/// Called from `dev/update_function_docs.sh`fn main() {let args: Vec<String> = args().collect();@@ -83,9 +89,12 @@ fn print_docs() -> String {let mut docs = "".to_string();+ // Ensure that all providers have documentation+ let mut providers_with_no_docs = HashSet::new();+// doc sections only includes sections that have 'include' == truefor doc_section in doc_sections {- // make sure there is a function that is in this doc section+ // make sure there is at least one function that is in this doc sectionif !&providers.iter().any(|f| {if let Some(documentation) = f.get_documentation() {documentation.doc_section == doc_section@@ -96,12 +105,14 @@ fn print_docs(continue;}+ // filter out functions that are not in this doc sectionlet providers: Vec<&Box<dyn DocProvider>> = providers.iter().filter(|&f| {if let Some(documentation) = f.get_documentation() {documentation.doc_section == doc_section} else {+ providers_with_no_docs.insert(f.get_name());false}})@@ -202,9 +213,19 @@ fn print_docs(}}+ // If there are any functions that do not have documentation, print them out+ // eventually make this an error: https://github.com/apache/datafusion/issues/12872+ if !providers_with_no_docs.is_empty() {+ eprintln!("INFO: The following functions do not have documentation:");+ for f in providers_with_no_docs {+ eprintln!(" - {f}");+ }+ }+docs}+/// Trait for accessing name / aliases / documentation for differnet functionstrait DocProvider {fn get_name(&self) -> String;fn get_aliases(&self) -> Vec<String>;