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

问题描述 投票:0回答:1

我正在我公司的代码库中实施 typedoc,但我遇到了一个问题。

/**
 * 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[];
}[];

这种类型由顶部的 TSDoc 评论描述,Typedoc 毫无问题地抓住了这些评论。但是我无法让类型定义中的注释显示出来。理想情况下,我将能够获得与文档中的参数相匹配的评论。 这就是我的文档现在的样子: 如果有人对此有所了解,感谢您的帮助!

typescript documentation-generation typedoc tsdoc
1个回答
0
投票

(此处为 TypeDoc 维护者)

TypeDoc 确实解析了所有这些评论,但它们没有被默认主题显示,因为

CellSetAxesSelection
是一个数组类型,而不仅仅是一个普通的对象类型,它只呈现简单对象的属性。默认主题中的相关代码在member.declaration.tsx

顺便说一句,一个非常相似的问题,#2276 最近提交了相同类型的问题(包装交集而不是数组,但相同的想法)

我还不确定什么是正确的解决方案。在任意类型中递归显示every对象类型的属性当然没有意义,例如

type Foo<T> = T extends { a: string } ? Something<{ b: string }> : never
,但这两个案例都足够简单,可能应该渲染它们。

将您的出口重新加工为以下内容,现在将按预期显示:

export type CellSetAxesSelection = CellSetAxesSelectionItem[]
export type CellSetAxesSelectionItem = { ... }
© www.soinside.com 2019 - 2024. All rights reserved.