Omega359 commented on code in PR #12822:
URL: https://github.com/apache/datafusion/pull/12822#discussion_r1855238619


##########
datafusion/macros/src/lib.rs:
##########
@@ -0,0 +1,216 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+extern crate proc_macro;
+use proc_macro::TokenStream;
+use quote::quote;
+use syn::{parse_macro_input, DeriveInput, LitStr};
+
+/// The procedural macro is intended to parse rust custom attribute and create 
a user documentation
+/// from it by constructing a `DocumentBuilder()` automatically. The 
`Documentation` can be
+/// retrieved from `documentation()` method
+/// declared on `AggregateUDF`, `WindowUDFImpl`, `ScalarUDFImpl` traits.
+///
+/// Example:
+/// #[user_doc(
+///     doc_section(include = "true", label = "Time and Date Functions"),
+///     description = r"Converts a value to a date (`YYYY-MM-DD`)."
+///     sql_example = "```sql\n\
+/// \> select to_date('2023-01-31');\n\
+/// +-----------------------------+\n\
+/// | to_date(Utf8(\"2023-01-31\")) |\n\
+/// +-----------------------------+\n\
+/// | 2023-01-31                  |\n\
+/// +-----------------------------+\n\"),
+///     standard_argument(name = "expression", prefix = "String"),
+///     argument(
+///         name = "format_n",
+///         description = r"Optional [Chrono 
format](https://docs.rs/chrono/latest/chrono/format/strftime/index.html) 
strings to use to parse the expression. Formats will be tried in the order
+///   they appear with the first successful one being returned. If none of the 
formats successfully parse the expression
+///   an error will be returned."
+///    )
+/// )]
+/// #[derive(Debug)]
+/// pub struct ToDateFunc {
+///     signature: Signature,
+/// }
+///
+/// will generate the following code
+///
+/// #[derive(Debug)] pub struct ToDateFunc { signature : Signature, }
+/// use datafusion_doc :: DocSection;
+/// use datafusion_doc :: DocumentationBuilder;
+/// static DOCUMENTATION : OnceLock < Documentation > = OnceLock :: new();
+/// impl ToDateFunc
+/// {
+///     fn doc(& self) -> Option < & Documentation >
+///     {
+///         Some(DOCUMENTATION.get_or_init(||
+///         {
+///             Documentation ::
+///             builder().with_doc_section(DocSection
+///             {
+///                 include : true, label : "Time and Date Functions", 
description
+///                 : None
+///             }).with_description(r"Converts a value to a date 
(`YYYY-MM-DD`).")
+/// .with_syntax_example("to_date('2017-05-31', 
'%Y-%m-%d')".to_string()).with_sql_example("```sql\n\
+/// \> select to_date('2023-01-31');\n\
+/// +-----------------------------+\n\
+/// | to_date(Utf8(\"2023-01-31\")) |\n\
+/// +-----------------------------+\n\
+/// | 2023-01-31                  |\n\
+/// +-----------------------------+\n\)
+/// .with_standard_argument("expression", "String".into())
+/// .with_argument("format_n",
+///             r"Optional [Chrono 
format](https://docs.rs/chrono/latest/chrono/format/strftime/index.html) 
strings to use to parse the expression. Formats will be tried in the order
+///   they appear with the first successful one being returned. If none of the 
formats successfully parse the expression
+///   an error will be returned.").build()
+///         }))
+///     }
+/// }
+#[proc_macro_attribute]
+pub fn user_doc(args: TokenStream, input: TokenStream) -> TokenStream {
+    let mut doc_section_include: Option<LitStr> = None;
+    let mut doc_section_lbl: Option<LitStr> = None;
+    let mut doc_section_desc: Option<LitStr> = None;
+
+    let mut description: Option<LitStr> = None;
+    let mut syntax_example: Option<LitStr> = None;
+    let mut sql_example: Option<LitStr> = None;
+    let mut standard_args: Vec<(Option<LitStr>, Option<LitStr>)> = vec![];
+    let mut udf_args: Vec<(Option<LitStr>, Option<LitStr>)> = vec![];

Review Comment:
   Missing alternative_syntax as well.



##########
datafusion/macros/src/lib.rs:
##########
@@ -0,0 +1,216 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+extern crate proc_macro;
+use proc_macro::TokenStream;
+use quote::quote;
+use syn::{parse_macro_input, DeriveInput, LitStr};
+
+/// The procedural macro is intended to parse rust custom attribute and create 
a user documentation

Review Comment:
   ```suggestion
   /// This procedural macro is intended to parse a rust custom attribute and 
create user documentation
   ```



##########
datafusion/macros/src/lib.rs:
##########
@@ -0,0 +1,216 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+extern crate proc_macro;
+use proc_macro::TokenStream;
+use quote::quote;
+use syn::{parse_macro_input, DeriveInput, LitStr};
+
+/// The procedural macro is intended to parse rust custom attribute and create 
a user documentation
+/// from it by constructing a `DocumentBuilder()` automatically. The 
`Documentation` can be
+/// retrieved from `documentation()` method

Review Comment:
   ```suggestion
   /// retrieved from the `documentation()` method
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to