【问题标题】:PHP and Doxygen with multiple property declaration具有多个属性声明的 PHP 和 Doxygen
【发布时间】:2015-04-17 03:30:19
【问题描述】:

我终于让 doxygen 与 php 和 PHPDoc 样式的 cmets 一起工作(我正在删除带有过滤器的 '@package',因为它会破坏 doxygen)虽然我很想拥有一件事,但我不知道怎么做。

在 PHP 中,我在这样的类中编写多个属性声明:

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() {}
}

如果我现在正在生成文档,则只有第一个属性显示为 private Attribute,而所有其他属性都简单地引用为 Data Fields。所以 doxygen 显然不会在第一个属性之后解析每个属性的访问者。

是否可以让这种评论风格与 doxygen 兼容?

P.S:我考虑过应用一个过滤器,将其转换为 doxygen 可解析的代码样式。虽然这只是我目前正在努力解决的问题。

【问题讨论】:

    标签: php properties doxygen multiline variable-declaration


    【解决方案1】:

    我编写了这个过滤器,它适用于您提供的示例。我认为它也应该适用于更复杂的示例。

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

    您可以在我的 GitHub 存储库 doxygen-php-filters 中找到此过滤器和其他过滤器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-14
      • 1970-01-01
      • 2011-10-24
      • 2013-12-16
      • 1970-01-01
      • 2018-09-06
      相关资源
      最近更新 更多