Android 样本评论 BEGIN_INCLUDE END_INCLUDE

Android samples comments BEGIN_INCLUDE END_INCLUDE

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

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

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

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

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

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

{@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