Doxygen not documenting php code inside if tags

一个人想着一个人 提交于 2019-12-11 02:10:17

问题


I am using doxygen, but it doesn't document some of my classes. All these classes are called in the following way:

<?php
if(!class_exists('a')){
    class a{

        function b(){
            print 'c';
        }
    }
}
?>

I assume it has to do with if(!class_exists('a')), how can i let doxygen still document this?


回答1:


Doxygen has many issues documenting php code. And many of them can be corrected by using an input_filter.

Use the following code as filter

<?php
$source = file_get_contents($argv[1]);
$regexp = '#(<\?php[\s]+)(if\(!class_exists\([^\)]+\)\)\{)([\s\S]*)(\})([\s]*\?>)#';
$replace = '$1 $3 $5';
$source = preg_replace($regexp, $replace, $source);
echo $source;
?>

and enter it as

/path/to/php php_var_filter.php

into the INPUT_FILTER setting.

Notice: This way you can fix many doxygen issues. If something does not work, it is beacause of a difference between c (or c++) code to php code (most likly). You can use the input_filter to change your php code to look more like c code. This will fix many problems.

Edit
Maybe you also want to think about an autoload function. I think this is a better way to get the if(!class_exists(..))-result.

Edit I just noticed I already answerd a similar question different. You can also use this answer.

You can find some more input filters to improve doxygen's php support on GitHub.



来源:https://stackoverflow.com/questions/26168273/doxygen-not-documenting-php-code-inside-if-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!