首页 > 解决方案 > 自动代码文档的问题 | PHP

问题描述

我有一个 CodeIgniter 项目,其中包含许多模块和代码。

现在我想为其他新同事创建文档。

例如

/**
 * inline tags demonstration
 *
 * This class generates bars using the main algorithm, which also 
 * works heavily with {@link foo()} to rule the world. If I want
 * to use the characters "{@link" in a docblock, I just use "{@}link."  If
 * I want the characters "{@*}" I use "{@}*}"
 *
 * @author ahobbit
 * @copyright middleearth.org XVII
 * @version 1.2.3
 */
class bar
{
    // beginning of docblock template area
    /**#@+
    * @access private
    * @var string
    */
    var $_var1 = 'hello';
    var $_var2 = 'my';
    var $_var3 = 'name';
    var $_var4 = 'is';
    var $_var5 = 'Bob';
    var $_var6 = 'and';
    var $_var7 = 'I';
    /**
    * Two words
    */
    var $_var8 = 'like strings';
    /**#@-*/
    var $publicvar = 'Lookee me!';
}

/**
 * Makes chocolate bars
 *
 * There are two aspects to this class.
 * {@inheritdoc }  In addition, the foo class
 * makes the bars chocolate
 */
class foo extends bar
{

    /**
    * Check if a Sql row exists. (with two values)
    *
    * This function will check if a selected sql row exists that contains two
    * known values.
    *
    * @param  string  $tblname  Sql Table Name
    * @param  string  $colname  Sql Column Name 1
    * @param  string  $value    Sql value 1
    * @param  string  $colname2 Sql Column Name 2
    * @param  string  $value2   Sql value 2
    * @return boolean           returns true if the sql row does exist
    */
    function tableHasRow2D($tblname, $colname, $value, $colname2, $value2) { 
        $row = sqlQuery("SELECT COUNT(*) AS count FROM $tblname WHERE " . "$colname 
            LIKE '$value' AND $colname2 LIKE '$value2'"); 
        return $row['count'] ? true : false; 
    } 
}

我已经使用了以下命令

一、PHPdoc

E:\xampp\htdocs\CI_Proj> php phpDocumentor.phar -d application

PHP Warning:  count(): Parameter must be an array or an object that implements Countable in phar://E:/xampp/htdocs/CI_Proj/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293
  Execute transformation using writer "twig"
  Execute transformation using writer "twig"
  Execute transformation using writer "twig"
  Execute transformation using writer "twig"
  Execute transformation using writer "twig"
  Execute transformation using writer "Graph"
Unable to find the `dot` command of the GraphViz package. Is GraphViz correctly installed and present in your path? 222.041s
Analyze results and write a report to log 

                       ..    0.004s

在此处输入图像描述


二、ApiGen

E:\xampp\htdocs\CI_Proj\vendor\bin>apigen generate src "E:\xampp\htdocs\CI_Proj\application" --destination "E:\xampp\htdocs\CI_Proj\docs-apigen" --debug

Fatal error: Cannot use 'Object' as class name as it is reserved in E:\xampp\htdocs\CI_Proj\vendor\latte\latte\src\Latte\Object.php on line 14
ErrorException: Cannot use 'Object' as class name as it is reserved in E:\xampp\htdocs\CI_Proj\vendor\latte\latte\src\Latte\Object.php:14
Stack trace:
#0 [internal function]: Tracy\Debugger::shutdownHandler()
#1 {main}
Unable to log error: Logging directory is not specified.

是否可以在代码生成之前或之后向模块添加注释?因为我希望在文档本身中为特定模块添加注释,并且可以选择在正确的位置自动插入到源代码中。

我应该如何管理项目中的模块和代码以及如何创建可浏览的 HTML 文档?

任何其他可以直接从您的 PHP 源代码生成文档的工具,这将是很好的建议

标签: documentationphpdocdocumentation-generationphpdocumentor2phpdocx

解决方案


推荐阅读