2009-04-17

【P】PHPDoctor - 產生程式文件的好工具

這是一套產生 PHP 程式文件的好東西~

上次經由會議上,聽到小鳳介紹後,一直到了昨天才開始研究~

我就先到了 PHPDoctor 去下載程式。

然後放到可以執行 PHP 環境的Server上。

http://peej.github.com/phpdoctor/more.html

這裡有詳細的說明該 如何安裝設定及使用

首先我將 phpdoctor 目錄裡的default.ini 複制一份來修改。

改的地方不多,應該說我看不懂的地方太多~哈~

附上我的設定檔 www.ini 的內容,

裡面我把我沒用到的都刪掉了~

; PHPDoctor settings
; ----------------------------------------
files = "*.php"
ignore = "CVS, .svn, .git, _compiled"
source_path = "/home/www/cowork/_inc/php/classes"
subdirs =on 
doclet = standard
default_package = "DB"
overview = readme.html
package_comment_dir = ./

; Standard doclet settings
; ----------------------------------------
d = "/home/www/chingwei/phpdoctor"
windowtitle = "windowTitle"
doctitle = "Doc Title"
header = "Header"
footer = "Footer"
bottom = "This document was generated by Ching-Wei"

設定檔的參數,可以參考下列網址,裡面有詳細的解釋

http://peej.github.com/phpdoctor/more.html#configuration

 

接著應該就可以執行囉~

dev:/tmp/_phpdoc # php phpdoc.php www.ini

 

結果出現錯誤……錯誤訊息是在phpdoc.php的 第 30行。

You need PHP version 4.3.0 or greater with the "tokenizer" extension to run this script, please upgrade'

 

看完後,我想應該是沒有 tokenizer 的關系,因為 PHP 已經是5.25版了,

所以我又重新rebuild php,這次在build的時候加上了 --enable-tokenizer

接著再到 php.ini 裡面加上 extension=tokenizer.so

這些都弄好後,我重新再執行一次指令~~這次就很順利的產生了我要的文件了~耶!!



 

結束~~


附上DB_Base的程式碼 (PHPDoctor 也支援 Javadoc 的 Tags )

/**
 * DB的基礎物件
 * 
 * @author Ching-Wei
 */
class DB_Base{
  /**
   * 傳進不同的dbName,可以連到不同的DB。
   * 
   * @param string dbName 預設值為db
   * @author Ching-Wei
   */
  public static function Get_Con($dbName='db'){
    ....
  }
}

 

順便轉載一下PHPDoctor 的 configuration directives

files
  Names of files to parse. This can be a single filename, or a comma separated list of filenames. Wildcards are allowed.
ignore
  Names of files or directories to ignore. This can be a single filename, or a comma separated list of filenames. Wildcards are NOT allowed.
source_path
  The directory to look for files in, if not used the PHPDoctor will look in the current directory (the directory it is run from).
subdirs
  If you do not want PHPDoctor to look in each sub directory for files uncomment this line.
quiet
  Set how loud PHPDoctor is as it runs. Quiet mode suppresses all output other than warnings and errors.
verbose
  Set how loud PHPDoctor is as it runs. Verbose mode outputs additional messages during execution.
doclet
  Select the doclet to use for generating output.
doclet_path
  The directory to find the doclet in. Doclets are expected to be in a directory named after themselves at the location given.
taglet_path
  The directory to find taglets in. Taglets allow you to make PHPDoctor handle new tags and to alter the behavour of existing tags and their output.
default_package
  If the code you are parsing does not use package tags or not all elements have package tags, use this setting to place unbound elements into a particular package.
overview
  Specifies the name of a HTML file containing text for the overview documentation to be placed on the overview page. The path is relative to "source_path" unless an absolute path is given.
package_comment_dir
  Package comments will be looked for in a file named package.html in the same directory as the first source file parsed in that package or in the directory given below. If package comments are placed in the directory given below then they should be named ".html".
globals
  Parse out global variables.
constants
  Parse out global constants.
private
  Generate documentation for all class members
protected
  Generate documentation for public and protected class members
public
  Generate documentation for only public class members
d
  The directory to place generated documentation in. If the given path is relative to it will be relative to "source_path".
windowtitle
  Specifies the title to be placed in the HTML
doctitle
  Specifies the title to be placed near the top of the overview summary file.
header
  Specifies the header text to be placed at the top of each output file. The header will be placed to the right of the upper navigation bar.
footer
  Specifies the footer text to be placed at the bottom of each output file. The footer will be placed to the right of the lower navigation bar.
bottom
  Specifies the text to be placed at the bottom of each output file. The text will be placed at the bottom of the page, below the lower navigation bar.
tree
  Create a class tree

0 comments:

張貼留言