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

Make CI error if a function has no documentation #12938

Merged
merged 1 commit into from
Oct 25, 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
21 changes: 12 additions & 9 deletions datafusion/core/src/bin/print_functions_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

use datafusion::execution::SessionStateDefaults;
use datafusion_common::{not_impl_err, Result};
use datafusion_expr::{
aggregate_doc_sections, scalar_doc_sections, window_doc_sections, AggregateUDF,
DocSection, Documentation, ScalarUDF, WindowUDF,
Expand All @@ -30,7 +31,7 @@ use std::fmt::Write as _;
/// Usage: `cargo run --bin print_functions_docs -- <type>`
///
/// Called from `dev/update_function_docs.sh`
fn main() {
fn main() -> Result<()> {
let args: Vec<String> = args().collect();

if args.len() != 2 {
Expand All @@ -48,12 +49,13 @@ fn main() {
_ => {
panic!("Unknown function type: {}", function_type)
}
};
}?;

println!("{docs}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this println?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This is how the shell script that builds the .md files retrieves the text. see https://github.com/apache/datafusion/blob/main/dev/update_function_docs.sh for impl.

Ok(())
}

fn print_aggregate_docs() -> String {
fn print_aggregate_docs() -> Result<String> {
let mut providers: Vec<Box<dyn DocProvider>> = vec![];

for f in SessionStateDefaults::default_aggregate_functions() {
Expand All @@ -63,7 +65,7 @@ fn print_aggregate_docs() -> String {
print_docs(providers, aggregate_doc_sections::doc_sections())
}

fn print_scalar_docs() -> String {
fn print_scalar_docs() -> Result<String> {
let mut providers: Vec<Box<dyn DocProvider>> = vec![];

for f in SessionStateDefaults::default_scalar_functions() {
Expand All @@ -73,7 +75,7 @@ fn print_scalar_docs() -> String {
print_docs(providers, scalar_doc_sections::doc_sections())
}

fn print_window_docs() -> String {
fn print_window_docs() -> Result<String> {
let mut providers: Vec<Box<dyn DocProvider>> = vec![];

for f in SessionStateDefaults::default_window_functions() {
Expand All @@ -86,7 +88,7 @@ fn print_window_docs() -> String {
fn print_docs(
providers: Vec<Box<dyn DocProvider>>,
doc_sections: Vec<DocSection>,
) -> String {
) -> Result<String> {
let mut docs = "".to_string();

// Ensure that all providers have documentation
Expand Down Expand Up @@ -217,12 +219,13 @@ fn print_docs(
// 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 {
for f in &providers_with_no_docs {
eprintln!(" - {f}");
}
not_impl_err!("Some functions do not have documentation. Please implement `documentation` for: {providers_with_no_docs:?}")
} else {
Ok(docs)
}

docs
}

/// Trait for accessing name / aliases / documentation for differnet functions
Expand Down
Loading