gpt4 book ai didi

flutter - 如何为 Dart 函数参数添加 Doc 注释?

转载 作者:行者123 更新时间:2023-12-03 03:08:32 27 4
gpt4 key购买 nike

我们可以轻松地为 Dart 类变量添加 Doc 注释,例如

class SomeClass {
/// Class variable Doc Comment.
var someVariable;

}

我怎样才能对 Dart 函数参数做同样的事情,例如我试过这个
void someFunction(
{/// Function parameter documentation
String funParameter="Some Default Value"}
) {

}

但它没有显示任何东西。如果不可能,请建议我任何替代方案。

最佳答案

against the Effective Dart conventions使用类似的直接语法来记录函数的参数。相反,请使用散文来描述参数及其与函数用途的关系。

// Instead of this

/// someFunction
/// @funParameter Does something fun
void someFunction({ String funParameter="Some Default Value" }) ...

// Or this

/// someFunction
void someFunction({
/// Does something fun
String funParameter="Some Default Value"
}) ...

// Do this

/// Does something fun with the [funParameter].
void someFunction({ String funParameter="Some Default Value" }) ...

这也许是一个更实际的例子:

/// Takes the values [a] and [b] and returns their sum. Optionally a
/// third parameter [c] can be provided and it will be added to the
/// sum as well.
int add(int a, int b, [int c = 0]) ...

关于flutter - 如何为 Dart 函数参数添加 Doc 注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61563687/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com