How to make Typedoc grab TSDoc comments inside of a type definition

346 Views Asked by At

i'm working on the implementation of typedoc in my company's codebase and i'm stuck on an issue.

/**
 * The tuples and levels corresponding to the selected positions (which can be headers in a table or ticks on a chart's axes).
 */
export type CellSetAxesSelection = {
  /**
   * The id of the cellset axis corresponding to this part of the selection: 0 for column headers, and 1 for row headers and static headers.
   * COLUMNS: 0 | ROWS: 1
   */
  id: AxisId;
  // This attribute is called `hierarchies` even though it contains levelCoordinates, because the `CellSetSelection` interface is made to be close to CellSet.
  /**
   * The selected levels (for instance if the user selected the header of a column representing a level in a table).
   */
  hierarchies?: (
    | LevelCoordinates
    | { dimensionName: "Measures"; hierarchyName: "Measures" }
  )[];
  /**
   * The partial tuples corresponding to the selected row or column headers.
   * For instance, consider a table whose first 3 columns represent Currency, City and Date.
   * Assume that the 1rst row represents [USD, New York, Today].
   * The user selected the 2nd cell on that row.
   * Then there would be one position: [USD, New York].
   * If the user now selects the 3rd cell on that row, then "Today" would only be present on the partial tuple.
   */
  positions?: Tuple[];
  /**
   * The index of each selected position in `data.axes[axisIndex].positions`.
   * `positionIndices` always has the same length as the `positions` attribute above.
   * It can be used to retrieve the full tuples corresponding to the selected row or column headers.
   * For instance in the previous example, it allows to retrieve "Date = Today", even if the user clicked on the 2nd cell of the 1rst row.
   */
  positionIndices?: number[];
}[];

This type is decribied by the TSDoc comments on the top, which are grabed by Typedoc with no issues. However i cant get the comments inside the type definition to show up. Ideally i would be able to get the comments matched with the arguments in the documentation. This is how my doc looks right now : If anyone knows anything about this, thanks for your help !

1

There are 1 best solutions below

7
On

(TypeDoc maintainer here)

TypeDoc did parse all of those comments, but they aren't displayed by the default theme because CellSetAxesSelection is an array type, not just a plain object type, and it only renders properties for simple objects. The relevant code in the default theme is in member.declaration.tsx

Incidentally, a very similar issue, #2276 was recently filed with the same type of issue (wrapping intersection instead of array, but the same idea)

I'm not sure what the right solution for this is yet. It certainly doesn't make sense to recursively show properties for every object type within an arbitrary type e.g. type Foo<T> = T extends { a: string } ? Something<{ b: string }> : never, but both of these are simple enough cases that they probably ought to be rendered.

Reworking your exports to the following will display as expected for now:

export type CellSetAxesSelection = CellSetAxesSelectionItem[]
export type CellSetAxesSelectionItem = { ... }