You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "ding-young (via GitHub)" <gi...@apache.org> on 2025/01/11 14:10:26 UTC

[PR] doc-gen: make user_doc to work with predefined consts [datafusion]

ding-young opened a new pull request, #14086:
URL: https://github.com/apache/datafusion/pull/14086

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #14001 .
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   ## What changes are included in this PR?
   This pr modifies `user_doc` to find `label` only for given `doc_section` attribute and try correspondent const from predefined `DocSections`. If there is no match but label exists, (ex. `General Functions`) it will automatically fill `include` and `description` with default value as before.
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ## Are these changes tested?
   will test with github CI. 
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ## Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] doc-gen: make user_doc to work with predefined consts [datafusion]

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #14086:
URL: https://github.com/apache/datafusion/pull/14086#discussion_r1913640003


##########
datafusion/macros/src/user_doc.rs:
##########
@@ -192,13 +185,13 @@ pub fn user_doc(args: TokenStream, input: TokenStream) -> TokenStream {
     let input = parse_macro_input!(input as DeriveInput);
     let name = input.clone().ident;
 
-    let doc_section_include: bool = if let Some(doc_section_include) = doc_section_include
-    {
-        doc_section_include.value().parse().unwrap()
-    } else {
-        true
-    };
-
+    let label = doc_section_lbl.as_ref().unwrap().value();
+    let doc_section_option = doc_sections_const().iter().find(|ds| ds.label == label);

Review Comment:
   lets document this part, mentioning we trying to find a predefined const by `label` field



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] doc-gen: make user_doc to work with predefined consts [datafusion]

Posted by "ding-young (via GitHub)" <gi...@apache.org>.
ding-young commented on code in PR #14086:
URL: https://github.com/apache/datafusion/pull/14086#discussion_r1916385694


##########
datafusion/macros/src/user_doc.rs:
##########
@@ -24,11 +25,12 @@ use syn::{parse_macro_input, DeriveInput, LitStr};
 /// from it by constructing a `DocumentBuilder()` automatically. The `Documentation` can be
 /// retrieved from the `documentation()` method
 /// declared on `AggregateUDF`, `WindowUDFImpl`, `ScalarUDFImpl` traits.
-///
+/// For `doc_section`, this macro will try to find corresponding predefined `DocSection` by label field 
+/// Predefined `DocSection` can be found in datafusion/expr/src/udf.rs

Review Comment:
   also documented here



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] doc-gen: make user_doc to work with predefined consts [datafusion]

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead merged PR #14086:
URL: https://github.com/apache/datafusion/pull/14086


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] doc-gen: make user_doc to work with predefined consts [datafusion]

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on PR #14086:
URL: https://github.com/apache/datafusion/pull/14086#issuecomment-2587906492

   For MSRV I believe you need to update the codebase and run `cargo update` in datafusion-cli folder


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] doc-gen: make user_doc to work with predefined consts [datafusion]

Posted by "ding-young (via GitHub)" <gi...@apache.org>.
ding-young commented on PR #14086:
URL: https://github.com/apache/datafusion/pull/14086#issuecomment-2592453533

   @comphead Thank you for review. Please tell me if there is any suggestion about the documentation or else. 


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] doc-gen: make user_doc to work with predefined consts [datafusion]

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on PR #14086:
URL: https://github.com/apache/datafusion/pull/14086#issuecomment-2587904771

   Thanks @ding-young I think we are very close.


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] doc-gen: make user_doc to work with predefined consts [datafusion]

Posted by "ding-young (via GitHub)" <gi...@apache.org>.
ding-young commented on code in PR #14086:
URL: https://github.com/apache/datafusion/pull/14086#discussion_r1916385249


##########
datafusion/macros/src/user_doc.rs:
##########
@@ -192,13 +186,18 @@ pub fn user_doc(args: TokenStream, input: TokenStream) -> TokenStream {
     let input = parse_macro_input!(input as DeriveInput);
     let name = input.clone().ident;
 
-    let doc_section_include: bool = if let Some(doc_section_include) = doc_section_include
-    {
-        doc_section_include.value().parse().unwrap()
-    } else {
-        true
-    };
-
+    if doc_section_lbl.is_none() {
+        eprintln!("label for doc_section should exist");
+    }
+    let label = doc_section_lbl.as_ref().unwrap().value();
+    // Try to find a predefined const by label first. 
+    // If there is no match but label exists, default value will be used for include and description

Review Comment:
   I made the changes here



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] doc-gen: make user_doc to work with predefined consts [datafusion]

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #14086:
URL: https://github.com/apache/datafusion/pull/14086#discussion_r1913638267


##########
datafusion/macros/src/user_doc.rs:
##########
@@ -192,13 +185,13 @@ pub fn user_doc(args: TokenStream, input: TokenStream) -> TokenStream {
     let input = parse_macro_input!(input as DeriveInput);
     let name = input.clone().ident;
 
-    let doc_section_include: bool = if let Some(doc_section_include) = doc_section_include
-    {
-        doc_section_include.value().parse().unwrap()
-    } else {
-        true
-    };
-
+    let label = doc_section_lbl.as_ref().unwrap().value();
+    let doc_section_option = doc_sections_const().iter().find(|ds| ds.label == label);
+    let (doc_section_include, doc_section_label, doc_section_desc) =
+        match doc_section_option {
+            Some(section) => (section.include, section.label, section.description),
+            None => (true, label.as_str(), None),

Review Comment:
   if the label is not found lets do `eprintln!` saying the predefined doc section cannot be found



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org