如何在文档块注释中显示代码示例


How to display code samples in docblock comments?

我已经使用netbeans 7.3PHP中的类属性编写了一个docblock注释。被注释的属性是一个关联数组,所以我想对每个键进行注释。这是代码:

/**
 * The expression being built.
 * 
 * This will be pushed to the {@see $_parts} array when complete.
 * <code>
 * array(
 *      'schema',       # The qualified schema name
 *      'table',        # The qualified table name
 *      'column',       # The qualified column name
 *      'alias',        # A simple name for schema.table.column
 *      'expr'          # A nested (in parenthesis) Expression object.
 *      'raw'           # Used for unrecognized expressions.
 *      'operator',     # The operator comparing column and value
 *      'value',        # The value(s) to compare column against
 *      'eval'          # A callable method to do the compare.
 *      'query'         # A sub Query (or Transaction) object.
 * )
 * </code>
 * 
 * @var mixed[]
 */
protected $_unit = array();

我希望<code>块能够保留行格式。问题是,当使用"自动弹出文档窗口"时,注释中的换行符被忽略,所有多个空格都被压缩为一个空格。这使得它很难阅读。

有没有其他方法可以保存格式,或者至少使其可读?

<code>标签周围使用<pre>标签。否则只使用<br>

从phpDocumentor:

<code> -- Use this to surround php code, some converters will highlight it
<pre> -- Preserve line breaks and spacing, and assume all tags are text (like XML's CDATA)
<br> -- hard line break, may be ignored by some converters

示例:

/**
 * The expression being built.
 *
 * This will be pushed to the {@see $_parts} array when complete.
 * <pre>
 * <code>
 * array(
 *      'schema',       # The qualified schema name
 *      'table',        # The qualified table name
 *      'column',       # The qualified column name
 *      'alias',        # A simple name for schema.table.column
 *      'expr'          # A nested (in parenthesis) Expression object.
 *      'raw'           # Used for unrecognized expressions.
 *      'operator',     # The operator comparing column and value
 *      'value',        # The value(s) to compare column against
 *      'eval'          # A callable method to do the compare.
 *      'query'         # A sub Query (or Transaction) object.
 * )
 * </code>
 * </pre>
 *
 * @var mixed[]
 */