Skip to content

Commit 690b780

Browse files
committed
Fixes to the distinct and distinctBy KDocs after review.
1 parent 119f5ad commit 690b780

File tree

2 files changed

+50
-56
lines changed

2 files changed

+50
-56
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/distinct.kt

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import org.jetbrains.kotlinx.dataframe.DataRow
77
import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
88
import org.jetbrains.kotlinx.dataframe.annotations.Interpretable
99
import org.jetbrains.kotlinx.dataframe.annotations.Refine
10+
import org.jetbrains.kotlinx.dataframe.api.DistinctDocs.DESCRIPTION
11+
import org.jetbrains.kotlinx.dataframe.api.DistinctDocs.DISTINCT_PARAM
1012
import org.jetbrains.kotlinx.dataframe.api.DistinctDocs.DISTINCT_RETURN
13+
import org.jetbrains.kotlinx.dataframe.api.DistinctDocs.FUNCTION
14+
import org.jetbrains.kotlinx.dataframe.api.DistinctDocs.PHRASE_ENDING
1115
import org.jetbrains.kotlinx.dataframe.api.Select.SelectSelectingOptions
1216
import org.jetbrains.kotlinx.dataframe.columns.ColumnSet
1317
import org.jetbrains.kotlinx.dataframe.columns.SingleColumn
@@ -16,6 +20,7 @@ import org.jetbrains.kotlinx.dataframe.documentation.DocumentationUrls
1620
import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate
1721
import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources
1822
import org.jetbrains.kotlinx.dataframe.documentation.Indent
23+
import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns
1924
import org.jetbrains.kotlinx.dataframe.exceptions.DuplicateColumnNamesException
2025
import org.jetbrains.kotlinx.dataframe.impl.columns.DistinctColumnSet
2126
import org.jetbrains.kotlinx.dataframe.indices
@@ -25,54 +30,60 @@ import kotlin.reflect.KProperty
2530
// region DataFrame
2631

2732
/**
28-
* ## The {@get NAME Distinct} Operation
33+
* {@get [DESCRIPTION] Removes duplicated rows based on {@get [PHRASE_ENDING]}}.
2934
*
30-
* {@get DESCRIPTION It removes duplicated rows based on {@get PHRASE_ENDING}}.
31-
*
32-
* __NOTE:__ The [rows][DataRow] in the resulting [DataFrame] are in the same order
35+
* The [rows][DataRow] in the resulting [DataFrame] are in the same order
3336
* as they were in the original [DataFrame].
3437
*
35-
* {@get [DISTINCT_PARAM]}
38+
* See also {@get [FUNCTION] [distinctBy] that removes duplicated rows based on the specified columns
39+
* and keeps all the columns in the resulting [DataFrame].}
40+
*
41+
* @include [SelectingColumns.ColumnGroupsAndNestedColumnsMention]
42+
*
43+
* See [Selecting Columns][SelectSelectingOptions].
3644
*
37-
* {@get [DISTINCT_RETURN] @return A new [DataFrame] containing only distinct rows.}
45+
* For more information:
46+
*
47+
* {@include [DocumentationUrls.Distinct]}
48+
*
49+
* {@include [DocumentationUrls.DistinctBy]}
50+
*
51+
* {@get [DISTINCT_PARAM]}
3852
*
39-
* @see [Selecting Columns][SelectSelectingOptions].
40-
* @see {@include [DocumentationUrls.Distinct]}
41-
* @see {@include [DocumentationUrls.DistinctBy]}
53+
* @return {@get [DISTINCT_RETURN] A new [DataFrame] containing only distinct rows}
4254
*/
4355
@ExcludeFromSources
4456
@Suppress("ClassName")
4557
private interface DistinctDocs {
4658
interface DISTINCT_PARAM
4759

4860
interface DISTINCT_RETURN
61+
62+
interface DESCRIPTION
63+
64+
interface PHRASE_ENDING
65+
66+
interface FUNCTION
4967
}
5068

5169
/**
5270
* {@include [DistinctDocs]}
53-
* {@set PHRASE_ENDING all columns}.
54-
* {@set [DistinctDocs.DISTINCT_PARAM]}
71+
* {@set [PHRASE_ENDING] all columns}.
72+
* {@set [DISTINCT_PARAM]}
5573
*/
5674
public fun <T> DataFrame<T>.distinct(): DataFrame<T> = distinctBy { all() }
5775

5876
/**
5977
* {@include [DistinctDocs]}
60-
* {@set DESCRIPTION It selects the specified columns and keeps only distinct rows based on these selected columns}
61-
* {@set [DistinctDocs.DISTINCT_PARAM] @param [columns] The names of the columns to select
62-
* and to consider for evaluating distinct rows.}
63-
* {@set [DISTINCT_RETURN] @return A new [DataFrame] containing only selected columns and distinct rows.}
78+
* {@set [DESCRIPTION] Selects the specified columns and keeps only distinct rows based on these selected columns}
79+
* {@set [DISTINCT_PARAM] @param [columns\] The [ColumnsSelector] used to select columns
80+
* that will be included in the resulting [DataFrame] and considered for evaluating distinct rows.}
81+
* {@set [DISTINCT_RETURN] A new [DataFrame] containing only selected columns and distinct rows.}
6482
*/
6583
@Refine
6684
@Interpretable("Distinct0")
6785
public fun <T, C> DataFrame<T>.distinct(columns: ColumnsSelector<T, C>): DataFrame<T> = select(columns).distinct()
6886

69-
/**
70-
* {@include [DistinctDocs]}
71-
* {@set DESCRIPTION It selects the specified columns and keeps only distinct rows based on these selected columns}
72-
* {@set [DistinctDocs.DISTINCT_PARAM] @param [columns] The names of the columns to select
73-
* and to consider for evaluating distinct rows.}
74-
* {@set [DISTINCT_RETURN] @return A new [DataFrame] containing only selected columns and distinct rows.}
75-
*/
7687
@Deprecated(DEPRECATED_ACCESS_API)
7788
@AccessApiOverload
7889
public fun <T> DataFrame<T>.distinct(vararg columns: KProperty<*>): DataFrame<T> =
@@ -83,64 +94,47 @@ public fun <T> DataFrame<T>.distinct(vararg columns: KProperty<*>): DataFrame<T>
8394

8495
/**
8596
* {@include [DistinctDocs]}
86-
* {@set DESCRIPTION It selects the specified columns and keeps only distinct rows based on these selected columns}
87-
* {@set [DistinctDocs.DISTINCT_PARAM] @param [columns] The names of the columns to select
97+
* {@set [DESCRIPTION] Selects the specified columns and keeps only distinct rows based on these selected columns}
98+
* {@set [DISTINCT_PARAM] @param [columns\] The names of the columns to select
8899
* and to consider for evaluating distinct rows.}
89-
* {@set [DISTINCT_RETURN] @return A new [DataFrame] containing only selected columns and distinct rows.}
100+
* {@set [DISTINCT_RETURN] A new [DataFrame] containing only selected columns and distinct rows.}
90101
*/
91102
public fun <T> DataFrame<T>.distinct(vararg columns: String): DataFrame<T> = distinct { columns.toColumnSet() }
92103

93-
/**
94-
* {@include [DistinctDocs]}
95-
* {@set DESCRIPTION It selects the specified columns and keeps only distinct rows based on these selected columns}
96-
* {@set [DistinctDocs.DISTINCT_PARAM] @param [columns] The names of the columns to select
97-
* and to consider for evaluating distinct rows.}
98-
* {@set [DISTINCT_RETURN] @return A new [DataFrame] containing only selected columns and distinct rows.}
99-
*/
100104
@Deprecated(DEPRECATED_ACCESS_API)
101105
@AccessApiOverload
102106
public fun <T> DataFrame<T>.distinct(vararg columns: AnyColumnReference): DataFrame<T> =
103107
distinct { columns.toColumnSet() }
104108

105-
/**
106-
* {@include [DistinctDocs]}
107-
* {@set NAME DistinctBy}
108-
* {@set PHRASE_ENDING the specified columns}.
109-
* {@set [DistinctDocs.DISTINCT_PARAM] @param [columns]
110-
* The names of the columns to consider for evaluating distinct rows.}
111-
*/
112109
@Deprecated(DEPRECATED_ACCESS_API)
113110
@AccessApiOverload
114111
public fun <T> DataFrame<T>.distinctBy(vararg columns: KProperty<*>): DataFrame<T> =
115112
distinctBy { columns.toColumnSet() }
116113

117114
/**
118115
* {@include [DistinctDocs]}
119-
* {@set NAME DistinctBy}
120-
* {@set PHRASE_ENDING the specified columns}.
121-
* {@set [DistinctDocs.DISTINCT_PARAM] @param [columns]
116+
* {@set [PHRASE_ENDING] the specified columns}.
117+
* {@set [FUNCTION] [distinct] that selects the specified columns
118+
* (if the columns are not specified, selects all columns)
119+
* and keeps only distinct rows based on these selected columns.}
120+
* {@set [DISTINCT_PARAM] @param [columns\]
122121
* The names of the columns to consider for evaluating distinct rows.}
123122
*/
124123
public fun <T> DataFrame<T>.distinctBy(vararg columns: String): DataFrame<T> = distinctBy { columns.toColumnSet() }
125124

126-
/**
127-
* {@include [DistinctDocs]}
128-
* {@set NAME DistinctBy}
129-
* {@set PHRASE_ENDING the specified columns}.
130-
* {@set [DistinctDocs.DISTINCT_PARAM] @param [columns]
131-
* The names of the columns to consider for evaluating distinct rows.}
132-
*/
133125
@Deprecated(DEPRECATED_ACCESS_API)
134126
@AccessApiOverload
135127
public fun <T> DataFrame<T>.distinctBy(vararg columns: AnyColumnReference): DataFrame<T> =
136128
distinctBy { columns.toColumnSet() }
137129

138130
/**
139131
* {@include [DistinctDocs]}
140-
* {@set NAME DistinctBy}
141-
* {@set PHRASE_ENDING the specified columns}.
142-
* {@set [DistinctDocs.DISTINCT_PARAM] @param [columns]
143-
* The names of the columns to consider for evaluating distinct rows.}
132+
* {@set [PHRASE_ENDING] the specified columns}.
133+
* {@set [FUNCTION] [distinct] that selects the specified columns
134+
* (if the columns are not specified, selects all columns)
135+
* and keeps only distinct rows based on these selected columns.}
136+
* {@set [DISTINCT_PARAM] @param [columns\] The [ColumnsSelector] used to select columns
137+
* that will be considered for evaluating distinct rows.}
144138
*/
145139
public fun <T, C> DataFrame<T>.distinctBy(columns: ColumnsSelector<T, C>): DataFrame<T> {
146140
val cols = get(columns)
@@ -185,7 +179,7 @@ public interface DistinctColumnsSelectionDsl {
185179
* Returns a new [ColumnSet] from [this] [ColumnSet] containing only distinct columns (by path).
186180
* This is useful when you've selected the same column multiple times but only want it once.
187181
*
188-
* NOTE: This doesn't solve [DuplicateColumnNamesException] if you've selected two columns with the same name.
182+
* This doesn't solve [DuplicateColumnNamesException] if you've selected two columns with the same name.
189183
* For this, you'll need to [rename][ColumnsSelectionDsl.named] one of the columns.
190184
*
191185
* ### Check out: [Grammar]

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/DocumentationUrls.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ internal interface DocumentationUrls {
8484
/** [See `remove` on the documentation website.]({@include [Url]}/remove.html) */
8585
interface Remove
8686

87-
/** <a href="{@include [Url]}/distinct.html">See `distinct` on the documentation website.</a> */
87+
/** [See `distinct` on the documentation website.]({@include [Url]}/distinct.html) */
8888
interface Distinct
8989

90-
/** <a href="{@include [Url]}/distinct.html#distinctby">See `distinctBy` on the documentation website.</a> */
90+
/** [See `distinctBy` on the documentation website.]({@include [Url]}/distinct.html#distinctby) */
9191
interface DistinctBy
9292

9393
/** <a href="{@include [Url]}/flatten.html">See `flatten` on the documentation website.</a> */

0 commit comments

Comments
 (0)