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

Doc gen: Attributes to support related_udf, alternative_syntax #13575

Merged
merged 3 commits into from
Nov 27, 2024

Conversation

comphead
Copy link
Contributor

Which issue does this PR close?

Followup on #12822
Closes #13553

Rationale for this change

  • Added support for related_udf, alternative_syntax
  • Migrated LTRIM to attrubute based doc gen instead of API
  • Changed documentation builder constructor to have mandatory params and avoid panics

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added logical-expr Logical plan and expressions functions labels Nov 26, 2024
@comphead
Copy link
Contributor Author

.md files has no changes, means the transition is smooth

name = "trim_str",
description = r"String expression to trim from the beginning of the input string. Can be a constant, column, or function, and any combination of arithmetic operators. _Default is whitespace characters._"
),
alternative_syntax = "trim(LEADING trim_str FROM str)",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Omega359 alternative_syntax and related_udf support

Copy link
Contributor

@jonathanc-n jonathanc-n left a comment

Choose a reason for hiding this comment

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

This lgtm! Looks good for the docs!

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thankyu @comphead

pub sql_example: Option<String>,
pub arguments: Option<Vec<(String, String)>>,
pub alternative_syntax: Option<Vec<String>>,
pub related_udfs: Option<Vec<String>>,
}

impl DocumentationBuilder {
pub fn new() -> Self {
pub fn new(
Copy link
Contributor

Choose a reason for hiding this comment

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

for anyone following along these settings are required, otherwise the builder will error (or now panic)

So I think the idea here is that the compiler can now verify the required fields which seems like an improvement to me, even though it is an API change

cc @Omega359

Copy link
Contributor

Choose a reason for hiding this comment

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

Gain one thing, loose another. Those fields now no longer have obvious names as they did previously if you are looking at them outside of an IDE. It's ok but it's obviously not the choice I made.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thats' correct. But another thing to mention the builder API mostly gonna be used internally within documentation generator crate so the user has to deal with attributes rather than API itself.

The following PR I'm intending to replace API approach to attributes where it is possible to, probably going crate by crate.

Thanks @alamb and @Omega359

Copy link
Contributor

Choose a reason for hiding this comment

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

Thats' correct. But another thing to mention the builder API mostly gonna be used internally within documentation generator crate so the user has to deal with attributes rather than API itself.

Ah, thanks for mentioning that as I had forgotten that.

@@ -205,30 +210,14 @@ impl DocumentationBuilder {
related_udfs,
} = self;

if doc_section.is_none() {
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

.with_description("Casts a value to a specific Arrow data type.")
.with_syntax_example("arrow_cast(expression, datatype)")
Documentation::builder(
DOC_SECTION_OTHER,
Copy link
Contributor

Choose a reason for hiding this comment

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

it is somewhat unfortunate that we lose the builder syntax but I think it is worth it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks @alamb. imho, it is regular builder pattern for the object construction which has both mandatory fields(in constructor) and optional fields(set by builder).

@comphead comphead merged commit 91670e2 into apache:main Nov 27, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
functions logical-expr Logical plan and expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation: Add related_udfs and alternative_syntax to doc gen macros
4 participants