如何在phpDocumentor中忽略特定文件

4

我正在使用phpDocumentor记录我用PHP构建的程序。一切都运行得很完美,但文档显示我有近100个错误,因为它正在读取我用来将文件上传到服务器的文件,但我并没有创建这个文件。 是否可能忽略给我所有错误的特定文件? 这是我执行以生成文档文件的命令:

phpdoc run -d /var/www/html/myprogram/ -t /var/www/html/myprogram/documentation

我正在尝试忽略的文件位于/myprogram目录中,就像这样:
/modules/module1/uploader.php

我发现了一些关于使用 --ignore 的信息,但我不知道那是否指的是特定的目录。
index.php 文件中编写一些内容来指示 phpDocumentor 忽略某些文件是否可能?
2个回答

7

--ignore标志可以接受单个文件名(以及目录名或通配符表达式):

phpdoc run --ignore /var/www/html/myprogram/modules/module1/uploader.php -d /var/www/html/myprogram/ -t /var/www/html/myprogram/documentation

或者,由于它可以接受部分目录,因此可以缩短为:

phpdoc run --ignore modules/module1/uploader.php -d /var/www/html/myprogram/ -t /var/www/html/myprogram/documentation

谢谢您的帮助,第二个方法对我有用 :D - Tales

4
我希望我的回答不会被downvote。我在这里提供我的答案,以备将来参考和其他人受益。
在项目的根目录中创建一个phpdoc.xml配置文件可以极大地帮助简化命令,而不是包含多个include/ignore选项。一个人可以轻松地将所有所需选项捆绑在一起,并由phpdoc读取以帮助构建文档。
例如,我的项目的phpdoc.xml配置文件如下,包含phpdoc选项:
<?xml version="1.0" encoding="UTF-8" ?>
<phpdoc>
    <title>App Plugins Documentations</title>
    <parser>
        <target>reference/docs</target>
    </parser>
    <transformer>
        <target>reference/docs</target>
    </transformer>
    <files>
        <directory>.</directory> <!-- Scan and parse all the php files except those found in the paths below -->
        <ignore>assets/*</ignore>
        <ignore>includes/gm-virtual-pages/*</ignore>
        <ignore>includes/app_virtual_pages/*</ignore>
        <ignore>includes/third-party/*</ignore>
        <ignore>includes/vendor/*</ignore>
        <ignore>reference/docs/*</ignore>
        <ignore>storage/*</ignore>
        <ignore>views/*</ignore>
        <ignore>index.php</ignore> <!-- Ignore all the index.php files -->
    </files>
</phpdoc>

这样你就可以包含/忽略多个路径和文件,甚至像你的问题中那样指定特定的文件。你所需要做的就是在文件的相对路径中包含ignore选项。

<ignore>/modules/module1/uploader.php</ignore>

只需在项目的根目录中运行以下命令,使用其中包含 phpdoc.xml 配置文件即可:phpdoc

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接