Add KDocs for public reverse APIs - #2050
Conversation
…lumn, and ValueColumn Implemented type-safe `reverse` operations for data structures, retaining metadata such as schema, column names, and column kinds. Updated KDocs and test cases accordingly.
| This makes the KDoc more refactor-safe, and it makes it easier to understand which arguments | ||
| need to be provided for a certain template. | ||
|
|
||
| A `@set` value may span several lines, but the indentation of the continuation lines is kept |
There was a problem hiding this comment.
So, like:
/**
* {@get A}
* {@set A hello}
*/?
I don't think this can happen, because the argument in @set is trimmed
There was a problem hiding this comment.
Ah, okey, agent faced several time with the problem and decided to include it, probably need to double-check
There was a problem hiding this comment.
can you give an example where this holds?
| * Returns a new {@get [RECEIVER]} with the same {@get [UNIT]}s in reversed order, | ||
| * so the last {@get [UNIT]} becomes the first one. | ||
| * | ||
| * {@get [DETAILS]} |
There was a problem hiding this comment.
When using a tag on a newline, no {} are needed
|
|
||
| /** | ||
| * @include [CommonReverseDocs] | ||
| * {@set [CommonReverseDocs.RECEIVER] [DataFrame]} |
There was a problem hiding this comment.
nowhere in this kdoc are {} necessary
There was a problem hiding this comment.
Will it work? Was it in the initial KDOC or KODEX guide?
There was a problem hiding this comment.
Yes, it works; block tags end when another block tag is encountered. I'm not sure how explicitly it's described, but it's how all other block tags work :)
There was a problem hiding this comment.
Brackets are only needed when you want to put a tag inline
There was a problem hiding this comment.
Normally you can see where a tag starts and ends using the intellij plugin of KoDEx, but it seems that has broken in the latest updates...
| * @include [CommonReverseDocs] | ||
| * {@set [CommonReverseDocs.RECEIVER] [DataColumn]} | ||
| * {@set [CommonReverseDocs.UNIT] value} | ||
| * {@set [CommonReverseDocs.DETAILS] The column keeps its name, type and [kind][ColumnKind]: |
|
The produced KDocs look good and useful :) |
Add KDocs for public
reverseAPIsCloses #1980. All five public
reverseoverloads now have KDocs. No behavior changes.KDoc
CommonReverseDocsinapi/reverse.kt. It holds the firstline, the website link,
@param [T]and@return. Each overload only sets its own parts(
RECEIVER,UNIT,DETAILS,SEE_ALSO,TYPE_PARAM). Same pattern asCommonTakeAndDropDocs.DocumentationUrls.Reversefor thereverse.htmllink.What each overload now states:
DataFrameDataColumnDataColumn, so for a column group you needasColumnGroup().ColumnGroupFrameColumnValueColumnTests
3 tests -> 10. Every statement in the KDocs now has a test. The three old tests are unchanged.
The old tests did not call the overloads one may expect.
columnOf(a, b)returnsDataColumn<DataRow<*>>, notColumnGroup.columnOf(1, 2, 3)returnsDataColumn<Int>, notValueColumn. SoColumnGroup.reverse()andValueColumn.reverse()were never called by anytest. The new tests build these columns explicitly with
DataColumn.createColumnGroup()andDataColumn.createValueColumn().New tests:
dataframe keeps schema and size— schema and row count.column keeps name and type.column overload keeps the column kind— a group staysGroup, a frame staysFrame, a valuestays
Value. TheDataColumn<*>types in this test are required: without them the calls go tothe other overloads and the test would check something else.
column group type can be restored after the column overload—asColumnGroup()round-trip.ColumnGroupis not a subtype ofDataColumn(it extendsBaseColumnandDataFrame), so thiscast is the only way to get the group type back.
column group reverses rows as a whole— realColumnGroupreceiver. It checks the name, theschema and the row pairs. It compares against explicit expected pairs and not against
DataFrame.reverse(): comparing two implementations can pass while both are wrong.frameColumn— the frames swap places, rows inside them keep their order.valueColumn— theValueColumn<Int>type of the result is the assertion here. The compilerchecks it.
Note on assertions: column equality (
impl/columns/Utils.kt) compares name, type and values. OneshouldBeon a whole column therefore already covers name and type. Separatename()/type()asserts are used only where there is no whole-column comparison.
KDoc guidelines
Two notes added to
KDOC_GUIDELINES.md, both found while writing the template:@setvalue keeps the indent of its continuation lines. An indent of 4+ spacesbecomes a code block in Markdown, so the paragraph renders as monospace.
@paramand@returnmust stay at the end of a KDoc. Text cannot be added after@include, soall parts that differ between overloads must be passed in as
@setarguments.