2012-12-28 45 views
4

我正在記錄一個我使用phpDocumentor在PHP中構建的程序。一切工作都很完美,但文檔顯示我有近100個錯誤,因爲它正在讀取我用來將文件上傳到我的服務器的文件,但我沒有創建。 是否有可能忽略那個給我所有錯誤的特定文件?這是我執行生成的文檔文件的命令:如何忽略phpDocumentor中的特定文件

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

文件我試圖忽略位於/myprogram目錄裏面是這樣的:

/modules/module1/uploader.php 

我發現的一些信息使用--ignore,但我不知道這是否指的是與目錄特定的東西。

是否可以在index.php文件中寫入指示phpDocumentor忽略某些文件的內容?

回答

6

--ignore flag將接受單個文件名(以及目錄名或水珠表達式):

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 
+0

感謝您的幫助,第二位爲我完成了這項工作:D – Tales

2

我希望我的答案不會被低估。我在這裏列出了我的答案,以供將來參考,以及其他可能從中受益的人。

在項目的根目錄下創建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命令。

相關問題