los*_*enn 15 php variables doxygen
我正在尝试使用doxygen将php代码解析为xml输出.Doxygen不解析类成员变量的描述.
这是我的示例php文件:
<?php
class A
{
/**
* Id on page.
*
* @var integer
*/
var $id = 1;
}
?>
Run Code Online (Sandbox Code Playgroud)
请注意,注释具有简要描述和变量类型.这是我从这个来源获得的xml:
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.7.2">
<compounddef id="class_a" kind="class" prot="public">
<compoundname>A</compoundname>
<sectiondef kind="public-attrib">
<memberdef kind="variable" id="class_a_1ae97941710d863131c700f069b109991e" prot="public" static="no" mutable="no">
<type></type>
<definition>$id</definition>
<argsstring></argsstring>
<name>$id</name>
<initializer> 1</initializer>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="C:/projects/version6-7/asprunner/PHP/source/classes/a.php" line="11" bodyfile="C:/projects/version6-7/asprunner/PHP/source/classes/a.php" bodystart="11" bodyend="-1"/>
</memberdef>
</sectiondef>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<location file="C:/projects/version6-7/asprunner/PHP/source/classes/a.php" line="5" bodyfile="C:/projects/version6-7/asprunner/PHP/source/classes/a.php" bodystart="4" bodyend="12"/>
<listofallmembers>
<member refid="class_a_1ae97941710d863131c700f069b109991e" prot="public" virt="non-virtual"><scope>A</scope><name>$id</name></member>
</listofallmembers>
</compounddef>
</doxygen>
Run Code Online (Sandbox Code Playgroud)
解析了描述或类型.我怎样才能解决这个问题?
Gor*_*kic 12
我正在使用输入过滤器从@var注释中插入带有变量声明的内联类型,并删除@var注释,因为它在Doxygen中具有不同的含义.有关详细信息,请参阅错误#626105.
由于Doxygen使用类似C的解析器,因此当输入过滤器运行时,它可以识别类型.
<?php
$source = file_get_contents($argv[1]);
$regexp = '#\@var\s+([^\s]+)([^/]+)/\s+(var|public|protected|private)\s+(\$[^\s;=]+)#';
$replac = '${2} */ ${3} ${1} ${4}';
$source = preg_replace($regexp, $replac, $source);
echo $source;
Run Code Online (Sandbox Code Playgroud)
这是一个快速入侵,可能有bug,它只适用于我的代码:

您可以在Doxyfile中使用INPUT_FILTER选项启用输入过滤器.将上面的代码保存到名为php_var_filter.php的文件中,并将过滤器值设置为"php php_var_filter.php".