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

Move toLeft -> toStart, toRight -> toEnd, add move KDocs #1071

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AndreiKingsley
Copy link
Collaborator

@Jolanrensen
Copy link
Collaborator

Uhm, we should probably keep the old functions, deprecate them (with ERROR right away is fine), and direct our users to the new ones.

@Jolanrensen Jolanrensen self-requested a review February 20, 2025 12:31
@AndreiKingsley
Copy link
Collaborator Author

AndreiKingsley commented Feb 20, 2025

Brought them back with Error-level deprecation

Copy link
Collaborator

@Jolanrensen Jolanrensen left a comment

Choose a reason for hiding this comment

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

Great job! This was not an easy function to document. Just a couple comments here and there

* {@include [LineBreak]}
* {@include [DslGrammarLink]}
* {@include [LineBreak]}
*
Copy link
Collaborator

Choose a reason for hiding this comment

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

Very nice! However, you're missing the definitions of the types you use. (fuck, I see I forgot it in update as well) Each grammar dsl in the selection dsl does have definitions on top. something like:

`colsSelector: `[ColumnsSelector]
`pathSelector: `[...]

This makes the grammar complete if we want to reuse it on writerside with @ExportAsHtml (Since there you cannot click on types anymore).

In the selection dsl, for each reference, I made a -Def and a -Ref variant (https://github.com/Kotlin/dataframe/blob/master/KDOC_PREPROCESSING.md#advanced-dsl-grammar-templating-columns-selection-dsl), something like:

/** `colsSelector: `[`ColumnsSelector`][ColumnsSelector] */
public interface ColumnsSelectorDef

(included at the definitions part of the grammar dsl)

/** [`colsSelector`][ColumnsSelectorDef] */
public interface ColumnsSelectorRef

(included at the actual notation part of the grammar dsl)

That way users can click on the reference, see the definition, and in the definition click on the type to see the actual type. This way you can also have a reference to a definition with multiple types allowed.

/**
* ## The Move Operation
*
* Moves the specified [columns] within the [DataFrame].
Copy link
Collaborator

Choose a reason for hiding this comment

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

KoDEx incorrectly recognizes [columns] as org.jetbrains.kotlinx.dataframe.columns, making it link up wrong. You can break the reference here by writing [columns\]

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also check this in other places as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

* which serves as an intermediate step. The [MoveClause] allows specifying the final
* destination of the selected columns using methods such as [MoveClause.to], [MoveClause.toStart],
* [MoveClause.toEnd], [MoveClause.into], [MoveClause.intoIndexed], [MoveClause.toTop],
* [MoveClause.after] or [MoveClause.under], that return a new [DataFrame] with updated columns order.
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably alias these links like [to][MoveClause.to], that reads a bit easier :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not just an updated order, right? It's an updated structure, I'd say

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

* @include [CommonMoveDocs]
* @include [SelectingColumns.Dsl] {@include [SetMoveOperationArg]}
* ### Examples:
* ```
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd write these examples starting with "```kt" so they are colored like Kotlin code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

* df.move("columnA", "columnB").after("columnC")
* df.move("age").under("info")
* ```
* @param [columns] The [Column Names][String] used to select the columns of this [DataFrame] to move.
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you want to link to something for column links, could I suggest org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnNames?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just followed a template from select KDocs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

* @param [columns] The [Column Names][String] used to select the columns of this [DataFrame].
*/
public fun <T> DataFrame<T>.select(vararg columns: String): DataFrame<T> = select { columns.toColumnSet() }

/**
* ## The MoveToStart Operation
*
* Moves the specified [columns] to the [DataFrame] start.
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe specify that this means the top-level, or do you think that's clear enough from this?

*
* For more information: {@include [DocumentationUrls.Move]}
*/
internal interface MoveToEnd {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I probably couldn't help myself and create a generic MoveToX doc hahaha, but that would probably be overkill, great job :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

/**
* ## Move Into
*
* Moves columns, previously selected with [move] into a new position specified with a
Copy link
Collaborator

Choose a reason for hiding this comment

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

*specified by

public fun <T, C> MoveClause<T, C>.to(columnIndex: Int): DataFrame<T> = moveTo(columnIndex)

/**
* ## Move ToTop
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems you are a bit inconsistent with the names of the sub-operations. Some are written like "Move ToTop", others like "MoveToStart". I assume you did this to mirror the function names, however it may be more readable to just separate them all by spaces and use Titlecase, like "Move to Top", "Move to Start", etc. Also, you'll make nikita happy if you use a couple more #'s so the titles become a bit smaller

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, so let's make a convention for all of this.

My logic was like this:
If its a complete operation (that is DF-> DF : moveToStart, moveToEnd) then it will have the full name in Upper Camel Case.
If it's a part of move operation (MoveClase -> DF), I write "Move" + this operation in UCC.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would favor readability over it following the function name exactly here. Users can already see the function name when they click to read the KDoc, so the title can just be a simple readable title I think.

*
* ### This After Overload
*/
internal interface MoveAfter
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be @ExcludeFromSources, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probable :) Done.

Copy link
Collaborator

@zaleslaw zaleslaw left a comment

Choose a reason for hiding this comment

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

No objection from my side after fixing comments from @Jolanrensen
Great job, I've learned also something new about the KoDex

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.

Move toLeft -> toStart, toRight -> toEnd Add KDocs for move
3 participants