1

嗨,我已经使用 codeigniter 创建了一个项目。现在我正在尝试生成 phpdoc。这是我第一次使用 phpdoc,我已经阅读了他们的文档和其他教程。当我尝试生成时,我得到的主要是错误列表

....没有页面级别的DocBlock,在第一个DocBlock中使用@package创建一个

并没有产生任何东西。但是当我在控制器或模型文件夹中运行 phpdoc 时,它可以工作,但不会从根文件夹或应用程序文件夹运行。我哪里错了?

这是 docblock 开始的示例

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 *
 * Project 1 files
 *
 * @package     Project1
 * @subpackage  projectControllers
 * @author      Abhishek Salian
 * @copyright   Copyright (c) 2013, AS.
 * @link        http://localhost/project1/
 * @since       Version 1.0
 */
?>

对于每种方法

/**
 * index
 *
 * This loads the index page
 *
 * @access public
 */

错误:

Abhis-MacBook-Pro:~ abhishek$ sudo phpdoc -d /Applications/mamp/htdocs/NewFrontend/ -t /Applications/mamp/htdocs/Docs/
PHP Version 5.4.10
phpDocumentor version 1.4.4

Parsing configuration file phpDocumentor.ini...
   (found in /Applications/MAMP/bin/php/php5.4.10/lib/php/data/PhpDocumentor/)...

done
Maximum memory usage set at 256M after considering php.ini...
using tokenizer Parser
Hidden /Applications/mamp/htdocs/NewFrontend/.DS_Store Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/.git Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/.gitignore Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/.htaccess Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/.travis.yml Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/application/.DS_Store Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/application/config/.DS_Store Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/application/libraries/tcpdf/tools/.htaccess Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/images/.DS_Store Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/lp/.htaccess Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/lp/m/.htaccess Ignored


Grabbing README/INSTALL/CHANGELOG

done


Tutorial/Extended Documentation Parsing Stage

done

一般解析阶段

Reading file /Applications/mamp/htdocs/NewFrontend/application/cache/index.html -- File not parsed, not a php file
Reading file /Applications/mamp/htdocs/NewFrontend/application/config/autoload.php -- Parsing file
WARNING in autoload.php on line 115: File "/Applications/mamp/htdocs/NewFrontend/application/config/autoload.php" has no page-level DocBlock, use @package in the first DocBlock to create one
Reading file /Applications/mamp/htdocs/NewFrontend/application/config/constants.php -- Parsing file
WARNING in constants.php on line 40: File "/Applications/mamp/htdocs/NewFrontend/application/config/constants.php" has no page-level DocBlock, use @package in the first DocBlock to create one
Reading file /Applications/mamp/htdocs/NewFrontend/application/config/database.php -- Parsing file
WARNING in database.php on line 135: File "/Applications/mamp/htdocs/NewFrontend/application/config/database.php" has no page-level DocBlock, use @package in the first DocBlock to create one
Reading file /Applications/mamp/htdocs/NewFrontend/application/config/development/config.php -- Parsing file
WARNING in config.php on line 611: File "/Applications/mamp/htdocs/NewFrontend/application/config/development/config.php" has no page-level DocBlock, use @package in the first DocBlock to create one
Reading file /Applications/mamp/htdocs/NewFrontend/application/config/doctypes.php -- Parsing file
4

1 回答 1

0

phpDoc 寻找出现在任何代码之前的文件级文档块。因为第 1 行中的“if”之前没有 docblock,所以您会收到该错误。在“if”行之后,您拥有的文档块将与恰好出现在它之后的任何代码元素相关联,无论它是一个类、一个函数,甚至只是一个 include/require 行。

您可以“解决”该错误的唯一方法是在顶部的“if”行之前放置一个 docblock。该 docblock 至少需要其中的 @package 标记,如果没有别的,因为这似乎不是命名空间代码。

像这样:

<?php
/**
 *
 * Project 1 files
 *
 * @package     Project1
 * @subpackage  projectControllers
 * @author      Abhishek Salian
 * @copyright   Copyright (c) 2013, AS.
 * @link        http://localhost/project1/
 * @since       Version 1.0
 */

/** no direct access */
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// now more stuff...

可能需要在 IF 行前面有一个像“/** no direct access */”这样的文档块,以便解析器不会将“Project 1 files”文档块绑定到“IF”行本身。

于 2013-08-30T15:57:30.807 回答