Omega359 commented on code in PR #13646:
URL: https://github.com/apache/datafusion/pull/13646#discussion_r1870569576
##########
datafusion/doc/src/lib.rs:
##########
@@ -63,6 +63,88 @@ impl Documentation {
) -> DocumentationBuilder {
DocumentationBuilder::new(doc_section, description, syntax_example)
}
+
+ /// Output the `Documentation` struct in form of custom Rust documentation
attributes
+ pub fn to_doc_attribute(&self) -> String {
+ let mut result = String::new();
+
+ result.push_str("#[user_doc(");
+ // Doc Section
+ result.push_str(
+ format!(
+ "\n doc_section({}label = \"{}\"{}),",
+ if !self.doc_section.include {
+ "include = \"false\", "
+ } else {
+ ""
+ },
+ self.doc_section.label,
+ self.doc_section
+ .description
+ .map(|s| format!(", description = \"{}\"", s))
+ .unwrap_or_default(),
+ )
+ .as_ref(),
+ );
+
+ // Description
+ result.push_str(format!("\n description=\"{}\",",
self.description).as_ref());
+ // Syntax Example
+ result.push_str(
+ format!("\n syntax_example=\"{}\",",
self.syntax_example).as_ref(),
+ );
+ // SQL Example
+ result.push_str(
+ &self
+ .sql_example
+ .clone()
+ .map(|s| format!("\n sql_example = r#\"{}\"#,", s))
+ .unwrap_or_default(),
+ );
+
+ let st_arg_token = " expression to operate on. Can be a constant,
column, or function, and any combination of operators.";
Review Comment:
Perhaps this could be extracted to a constant and that used instead of
having text copies of the string in 2 places.
##########
datafusion/core/src/bin/print_functions_docs.rs:
##########
@@ -158,6 +158,23 @@ fn print_docs(
unreachable!()
};
+ // let attr_text = documentation.to_doc_attribute();
+ //
+ // let file_path = format!("{}.txt", name);
+ // if std::path::Path::new(&file_path).exists() {
+ // std::fs::remove_file(&file_path).unwrap();
Review Comment:
I would just add a small comment noting this is useful for migration
purposes.
--
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]