Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print undocumented functions to console while generating docs #12874

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion datafusion/core/src/bin/print_functions_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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' == true
for 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 section
if !&providers.iter().any(|f| {
if let Some(documentation) = f.get_documentation() {
documentation.doc_section == doc_section
Expand All @@ -96,12 +105,14 @@ fn print_docs(
continue;
}

// filter out functions that are not in this doc section
let 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
}
})
Expand Down Expand Up @@ -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 functions
trait DocProvider {
fn get_name(&self) -> String;
fn get_aliases(&self) -> Vec<String>;
Expand Down
Loading