Android 示例评论 BEGIN_INCLUDE END_INCLUDE

标签 android comments sample code-regions

在阅读一些 android 示例时,我通常会看到像

这样的评论
// BEGIN_INCLUDE (something)
// END_INCLUDE (something)

但是,我当前的 IDE——Android Studio 1.1——无法识别它们(或者我做错了什么)。我猜,它们用作某种代码区域标记(例如

//<editor-fold desc="Region name"> 
// some code
//</editor-fold>

在 AndroidStudio/IntellijIDEA 中),但这种语法很像 C++ 预处理器指令。所以问题是:我是否应该了解这些注释的一些重要信息(除了明显的注释功能之外)可以以任何方式改进我的代码?

最佳答案

它用于文档目的,用于识别要包含在目标文档中的 fragment 。它在编辑代码时并不是很有用;它有助于通过从实际代码生成文档来避免重复。

{@sample} and {@include}

These tags copy sample text from an arbitrary file into the output javadoc html.

The @include tag copies the text verbatim from the given file.

The @sample tag

  • copies the text from the given file and strips leading and trailing whitespace
  • reduces the indent level of the text to the indent level of the first non-whitespace line
  • escapes all <, >; and & characters for html
  • drops all lines containing either BEGIN_INCLUDE or END_INCLUDE so sample code can be nested

Both tags accept either a filename and an id or just a filename. If no id is provided, the entire file is copied. If an id is provided, the lines in the given file between the first two lines containing BEGIN_INCLUDE(id) and END_INCLUDE(id), for the given id, are copied. The id may be only letters, numbers and underscore ().

Four examples:

{@include samples/SampleCode/src/com/google/app/Notification1.java}
{@sample samples/SampleCode/src/com/google/app/Notification1.java}
{@include samples/SampleCode/src/com/google/app/Notification1.java Bleh}
{@sample samples/SampleCode/src/com/google/app/Notification1.java Bleh}

https://code.google.com/p/doclava/wiki/JavadocTags

关于Android 示例评论 BEGIN_INCLUDE END_INCLUDE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29094073/

相关文章:

java - Android:TextView 未更新

r - 如何使用 R 中前几行的示例数据填充非相邻行?

postgresql - postgres随机使用setseed

R中的随机样本

android - OptionsMenu onOptionsSelected 什么也没给我

android - 如何使用 JobScheduler 从后台应用程序获取步数

android - 如何使用不同风格或不同构建类型的不同混淆器文件?

parsing - PEG.js - 如何解析 C 风格的注释?

php - 编写单独评论区域的有效方法是什么?

c++ - VC++ 注释、文档和 IntelliSense