Flutter和Dart文档中的@macro注释是什么 [英] What is the @macro annotation in Flutter and Dart documentation
问题描述
When I'm reading the source code I often see something like this (from TextField):
/// {@macro flutter.widgets.editableText.keyboardType}
final TextInputType keyboardType;
@macro
是什么意思?
我找到了答案,因此将其发布在下面,作为自我解答.
推荐答案
@macro
是一种插入 dartdoc 文档已在其他地方编写.这样,您就不必维护重复的文档.
A @macro
is a way to insert some dartdoc documentation that has been written somewhere else. That way you don't have duplicate docs that you have to maintain.
@macro
后面的字符串是模板的名称,其中包括您要插入的文档.因此,在 TextField 例如:
The string that follows @macro
is the name of a template, which includes the documentation you'll insert. So in the TextField example:
/// {@macro flutter.widgets.editableText.keyboardType}
final TextInputType keyboardType;
模板名称为 flutter.widgets.editableText.keyboardType
.如果您转到的源代码EditableText ,您将找到带有文档文本的模板:
the template name is flutter.widgets.editableText.keyboardType
. If you go to the source code for EditableText, you'll find the template with it's documentation text:
/// {@template flutter.widgets.editableText.keyboardType}
/// The type of keyboard to use for editing the text.
///
/// Defaults to [TextInputType.text] if [maxLines] is one and
/// [TextInputType.multiline] otherwise.
/// {@endtemplate}
final TextInputType keyboardType;
注释 @template
会启动模板,后跟其名称. @endtemplate
完成它.
The annotation @template
starts the template and is followed by its name. @endtemplate
finishes it.
当您查看 EditableText.keyboardType
和 TextField.keyboardType
的文档时,您会发现它们是完全相同的:
When you view the documentation for EditableText.keyboardType
and TextField.keyboardType
, you can see they are exactly the same:
- https://api.flutter.dev/flutter/widgets/EditableText/keyboardType.html
- https://api.flutter.dev/flutter/material/TextField/keyboardType.html
请参阅 dartdoc文档中的更多内容.
这篇关于Flutter和Dart文档中的@macro注释是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!