douyi5822 2015-02-16 15:14
浏览 85
已采纳

PHP和Doxygen具有多个属性声明

I finally got doxygen to work with php and PHPDoc styled comments (I'm removing '@package' with filter since it breaks up doxygen) though there's one thing I would love to have and are not able to figure out how.

In PHP I'm writing multiple property declaration in a class like this:

class Foo
{
private
    /// the blue color
    $blue,
    /// the red color
    $red,
    /// the yellow color
    $yellow;

public
    /// the orange color
    $orange,
    /// black (no color)
    $black;

public function bar() {}
}

If I'm now generating the docs, only the first property is shown as private Attribute while all other properties are simply referenced as Data Fields. So doxygen obviously doesn't parse the accesors of every property after the first one.

Is it possible to make this commentation style compatible to doxygen ?

P.S: I thought about applying a filter which converts it in doxygen-parsable code style. Though this would only be a fix I'm currently working on it.

  • 写回答

1条回答 默认 最新

  • dongzouqie4220 2015-04-23 17:01
    关注

    I wrote this filter, that works for the example you provided. I think I should also work for more complex examples.

    // Get the input
    $source = file_get_contents($argv[1]);
    
    $count = 0;
    
    do {
        $source = preg_replace('#(private|public|protected)(\s*[^$]*)(\$[^,;]+),#',
                               "$2 $1 $3;
    $1 ", $source, -1, $count);
    } while($count > 0);
    
    // Output
    echo $source;
    

    You can find this and other filters at my GitHub repository doxygen-php-filters.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏