Skip to content

Commit

Permalink
add remove KDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiKingsley committed Jan 21, 2025
1 parent 3f054ab commit c2ef84f
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
94 changes: 94 additions & 0 deletions core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/remove.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,129 @@ import org.jetbrains.kotlinx.dataframe.ColumnsSelector
import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.annotations.Interpretable
import org.jetbrains.kotlinx.dataframe.annotations.Refine
import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
import org.jetbrains.kotlinx.dataframe.columns.toColumnSet
import org.jetbrains.kotlinx.dataframe.documentation.DocumentationUrls
import org.jetbrains.kotlinx.dataframe.documentation.DocumentationUrls.Select
import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources
import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns
import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.OperationArg
import org.jetbrains.kotlinx.dataframe.impl.api.removeImpl
import kotlin.reflect.KProperty

// region DataFrame

// region remove

/**
* ## The Remove Operation
*
* Removes the specified [columns] from the original [DataFrame] and returns a new [DataFrame] without them.
*
* @include [SelectingColumns.ColumnGroupsAndNestedColumnsMention]
*
* See [Selecting Columns][Select.SelectSelectingOptions].
*
* For more information: {@include [DocumentationUrls.Remove]}
*/
internal interface Remove

/** {@set [SelectingColumns.OperationArg] [remove][remove]} */
@ExcludeFromSources
private interface SetRemoveOperationArg

/**
* {@include [Remove]}
* ### This Remove Overload
*/
@ExcludeFromSources
private interface CommonRemoveDocs

/**
* @include [CommonRemoveDocs]
* @include [SelectingColumns.Dsl.WithExample] {@include [SetRemoveOperationArg]}
* @param [columns] The [Columns Selector][ColumnsSelector] used to remove the columns of this [DataFrame].
*/
@Refine
@Interpretable("Remove0")
public fun <T> DataFrame<T>.remove(columns: ColumnsSelector<T, *>): DataFrame<T> =
removeImpl(allowMissingColumns = true, columns = columns).df

/**
* @include [CommonRemoveDocs]
* @include [SelectingColumns.ColumnNames.WithExample] {@include [SetRemoveOperationArg]}
* @param [columns] The [Column Names][String] used to remove the columns of this [DataFrame].
*/
public fun <T> DataFrame<T>.remove(vararg columns: String): DataFrame<T> = remove { columns.toColumnSet() }

/**
* @include [CommonRemoveDocs]
* @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetRemoveOperationArg]}
* @param [columns] The [Column Accessors][ColumnReference] used to remove the columns of this [DataFrame].
*/
public fun <T> DataFrame<T>.remove(vararg columns: AnyColumnReference): DataFrame<T> = remove { columns.toColumnSet() }

/**
* @include [CommonRemoveDocs]
* @include [SelectingColumns.KProperties.WithExample] {@include [SetRemoveOperationArg]}
* @param [columns] The [KProperties][KProperty] used to remove the columns of this [DataFrame].
*/
public fun <T> DataFrame<T>.remove(vararg columns: KProperty<*>): DataFrame<T> = remove { columns.toColumnSet() }

// endregion

// region minus

/**
* ## The Minus Operation
*
* Removes the specified [columns] from the original [DataFrame] and returns a new [DataFrame] without them.
*
* @include [SelectingColumns.ColumnGroupsAndNestedColumnsMention]
*
* See [Selecting Columns][Select.SelectSelectingOptions].
*
* Works exactly as [remove]. For more information: {@include [DocumentationUrls.Remove]}
*/
internal interface Minus

/** {@set [SelectingColumns.OperationArg] [minus][minus]} */
@ExcludeFromSources
private interface SetMinusOperationArg

/**
* {@include [Minus]}
* ### This Minus Overload
*/
@ExcludeFromSources
private interface CommonMinusDocs

/**
* @include [CommonMinusDocs]
* @include [SelectingColumns.Dsl.WithExample] {@include [SetMinusOperationArg]}
* @param [columns] The [Columns Selector][ColumnsSelector] used to remove the columns of this [DataFrame].
*/
public infix operator fun <T> DataFrame<T>.minus(columns: ColumnsSelector<T, *>): DataFrame<T> = remove(columns)

/**
* @include [CommonMinusDocs]
* @include [SelectingColumns.ColumnNames.WithExample] {@include [SetMinusOperationArg]}
* @param [columns] The [Column Names][String] used to remove the columns of this [DataFrame].
*/
public infix operator fun <T> DataFrame<T>.minus(column: String): DataFrame<T> = remove(column)

/**
* @include [CommonMinusDocs]
* @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetMinusOperationArg]}
* @param [columns] The [Column Accessors][ColumnReference] used to remove the columns of this [DataFrame].
*/
public infix operator fun <T> DataFrame<T>.minus(column: AnyColumnReference): DataFrame<T> = remove(column)

/**
* @include [CommonMinusDocs]
* @include [SelectingColumns.KProperties.WithExample] {@include [SetMinusOperationArg]}
* @param [columns] The [KProperties][KProperty] used to remove the columns of this [DataFrame].
*/
public infix operator fun <T> DataFrame<T>.minus(columns: KProperty<*>): DataFrame<T> = remove(columns)

// endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import kotlin.reflect.KProperty
*
* Returns a new [DataFrame] with only the columns selected by [columns].
*
* @include [SelectingColumns.ColumnGroupsAndNestedColumnsMention]
*
* See [Selecting Columns][SelectSelectingOptions].
*
* For more information: {@include [DocumentationUrls.Select]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,7 @@ internal interface DocumentationUrls {

/** [See `update` on the documentation website.]({@include [Url]}/update.html) */
interface Update

/** [See `remove` on the documentation website.]({@include [Url]}/remove.html) */
interface Remove
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.jetbrains.kotlinx.dataframe.api.gather
import org.jetbrains.kotlinx.dataframe.api.select
import org.jetbrains.kotlinx.dataframe.api.update
import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup
import org.jetbrains.kotlinx.dataframe.columns.ColumnSet
import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver
import org.jetbrains.kotlinx.dataframe.columns.SingleColumn
Expand Down Expand Up @@ -47,6 +48,11 @@ internal interface SelectingColumnsLink
*/
internal interface SelectingColumns {

/**
* This operation can also be used on [ColumnGroup] and nested columns.
*/
interface ColumnGroupsAndNestedColumnsMention

/*
* The key for a @set that will define the operation name for the examples below.
* Make sure to [alias][your examples].
Expand Down

0 comments on commit c2ef84f

Please sign in to comment.