Skip to content

Commit

Permalink
WIP. Test gen doc from macros
Browse files Browse the repository at this point in the history
  • Loading branch information
comphead committed Oct 8, 2024
1 parent dca1a33 commit 5fe25f3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
13 changes: 8 additions & 5 deletions datafusion/functions/src/math/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use datafusion_expr::{
};
use datafusion_expr::{ScalarUDFImpl, Signature, Volatility};

#[udf_doc(description="log_description", example="log_example")]
#[udf_doc(description = "log_description", example = "log_example")]
#[derive(Debug)]
pub struct LogFunc {
signature: Signature,
Expand Down Expand Up @@ -475,9 +475,12 @@ mod tests {
#[test]
fn test_doc() {
let log = LogFunc::new();
assert_eq!(log.documentation_test(), Some(DocumentationTest {
description: "log_description".to_string(),
syntax_example: "log_example".to_string(),
}));
assert_eq!(
log.documentation_test(),
Some(DocumentationTest {
description: "log_description".to_string(),
syntax_example: "log_example".to_string(),
})
);
}
}
3 changes: 1 addition & 2 deletions datafusion/macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extern crate proc_macro;
use datafusion_pre_macros::DocumentationTest;
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, DeriveInput, Lit, LitStr, Meta, MetaNameValue};
use datafusion_pre_macros::DocumentationTest;

#[proc_macro_attribute]
pub fn udf_doc(args: TokenStream, input: TokenStream) -> TokenStream {
Expand All @@ -29,7 +29,6 @@ pub fn udf_doc(args: TokenStream, input: TokenStream) -> TokenStream {

//eprintln!("input={input:?}");


let expanded = quote! {
#input

Expand Down
2 changes: 1 addition & 1 deletion datafusion/pre-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ pub struct DocumentationTest {
pub description: String,
/// a brief example of the syntax. For example "ascii(str)"
pub syntax_example: String,
}
}

0 comments on commit 5fe25f3

Please sign in to comment.