antvis/G6

Generate Docs from Comments #5324

Aarebecca posted onGitHub

To reduce documentation maintenance costs, G6 will generate docs from code comments, which puts some requirements on the writing of comments. A standard comments should includes several parts:

  • description
  • [optional] example
  • params
  • returns
  • accessibility
  • written in both Chinese and English

Here is an example:

/**
 * <zh/> 计算两个数的和
 *
 * <en/> Calculate the sum of two numbers
 * @example
 * ```ts
 * const result = sum(10, 20);
 * ```
 * @param a - <zh/>第一个数 | <en>The first number
 * @param b - <zh/>第二个数 | <en>The second number
 * @returns <zh/>两数之和 | <en/>The sum of the two numbers
 * @public
 */
export function sum(a: number, b: number): number {
  return a + b;
}

Image

These comments will be extract by @microsoft/api-extractor and generate docs by @microsoft/api-documenter, We will develop a post processor to convert the generated docs to AntV docs.


Fund this Issue

$0.00
Funded

Pull requests