Skip to content

KDocs for min/max - #2012

Open
Jolanrensen wants to merge 5 commits into
masterfrom
min-max-docs
Open

KDocs for min/max#2012
Jolanrensen wants to merge 5 commits into
masterfrom
min-max-docs

Conversation

@Jolanrensen

@Jolanrensen Jolanrensen commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1971, #1974

I let Claude attempt write it using all our KDoc guides. It's quite impressive!
Only made some small fixes and maintainability improvements, but it looks good to me. All questions I had are answered in the KDocs and it seemed to understand and use KoDEx quite well.

@Jolanrensen Jolanrensen changed the title KDocs for max.kt KDocs for min/max Jul 30, 2026
@Jolanrensen
Jolanrensen marked this pull request as ready for review July 30, 2026 11:47
@Jolanrensen
Jolanrensen requested review from Copilot and removed request for Copilot July 30, 2026 12:54
@Jolanrensen

This comment was marked as resolved.

This comment was marked as low quality.

@Jolanrensen Jolanrensen linked an issue Jul 30, 2026 that may be closed by this pull request
@Jolanrensen
Jolanrensen requested review from Allex-Nik and AndreiKingsley and removed request for Allex-Nik and AndreiKingsley July 30, 2026 13:40

@AndreiKingsley AndreiKingsley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am not sure about maxBy/maxFor descriptions — they look complicated (especially for maxByOrNull), and hard to understand difference. May be slightly rephrase/restructurize them.

Also it's hard to get confused about max()/maxFor { }/max { } , I'd emphasise differences/commons between them.

Please add links to pivot/groupBy grammars.

Make comments in examples code more detailed.

* Link to it with `{@include [MaxDocsLink]}`.
* }
*
* ## The Max Operation

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please, remove all headers

Could you take a look, why Claude decided to bring header back? Because of examples or why?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sorry, now I’ve realised what this is topic, nevermind

@Jolanrensen Jolanrensen Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

indeed, I checked the others were gone, I think it's fine to introduce this concept, right?

*
* ## The Max Operation
*
* Computes the [maximum](https://en.wikipedia.org/wiki/Maximum_and_minimum) of values.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need this link here actually?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

not necessarily, but it was on the website, so for completeness it might be nice. Just in case people are confusing maximal and maximum or something

* `null` values in the input are always ignored.
*
* If the input contains [`NaN`][NaN] values, the result will be `NaN`,
* unless `skipNaN` is set to `true`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can be linked to an argument

* {@include [MaxDocs.ThrowsOnEmptySnippet]}
*
* See also:
* - [maxOrNull][DataColumn.maxOrNull] — returns `null` instead of throwing for an empty column.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

or column of nulls

maxOrNull(skipNaN).suggestIfNull("max")

/**
* Returns the maximum of the values in this [DataColumn], or `null` if there is nothing to compare.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd add

(i.e., column is empty or only `null` values are compared)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ok, there's a comprehensive snippet below, it's ok.

*
* See also:
* - [maxByOrNull][DataColumn.maxByOrNull] — returns `null` instead of throwing for an empty column.
* - [maxOf][DataColumn.maxOf] — returns the maximum [selector] value itself

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd place maxOf above see also section, with a message

"Don't confuse it with [maxOf] that returns maximum value computed with [selector] instead of the original element"

And the same in [maxOf] KDoc.

(and in maxByOrNull, min..()s, etc.)

* {@include [SelectingColumns.ColumnGroupsAndNestedColumnsSnippet]}
*
* See [Selecting Columns][MaxDocs.MaxSelectingOptions].
*

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All link to pivot grammar

* ### Example
* ```kotlin
* // The largest of all `Int` values in the first row
* // (so, in the "age" and "weight" columns), or `null` if there are none

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(so, in the "age" and "weight" columns)

Add more context —
"Assuming there's two int columns in DF — age and weight,..."

*
* ### Example
* ```kotlin
* // For each city, the largest value of each comparable column

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We need to write a more detailed comment: "city" is a column; we group by it and take the maximum value from each group, and a new column called ‘max’ will appear with this value.

* {@include [MaxDocs.NullOnEmptySnippet]}
*
* See also:
* - [maxBy][DataColumn.maxBy] — throws instead of returning `null` for an empty column.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe we should remove "for an empty column" here or replace it with something like "for a column with nothing to compare"?

*
* {@include [MaxDocs.InputValuesSnippet]}
*
* {@include [MaxDocs.ThrowsOnEmptySnippet]}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would it make sense to merge it with the @throws section?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add KDocs for non-deprecated min APIs Add KDocs for non-deprecated max APIs

4 participants