douwen0647 2014-06-16 01:49
浏览 20
已采纳

如何在docblock评论中显示代码示例?

I've written a docblock comment for a class property in PHP using netbeans 7.3. The property being commented is an associative array, so I'd like to comment on each key. Here's the code:

/**
 * 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();

I was hoping the <code> block would preserve the line formatting. The problem is, new line characters in the comment are being ignored and all multi spaces are condensed to a single space, when using the "auto popup documentation window". This makes it very hard to read.

Is there another way to preserve the format, or at least make it readable?

  • 写回答

1条回答 默认 最新

  • duanbohan2015 2014-06-16 02:05
    关注

    Try it with <pre> tags around the <code> tags. Else just use <br>.

    From 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
    

    Example:

    /**
     * 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[]
     */
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看