Hi I have created a project using codeigniter. Now I am trying to generate phpdoc. This is my first time using phpdoc and i have read their documentation and other tutorials. When I try to generate i get list of error mostly it is
.... has no page-level DocBlock, use @package in the first DocBlock to create one
and nothing has been generated. But when i run phpdoc inside controllers or models folder it works but doesnt run from root folder nor from application folder. Where Am I going wrong?
Here is the sample of docblock starting
<?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
*/
?>
For every method
/**
* index
*
* This loads the index page
*
* @access public
*/
Error:
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
General Parsing Stage
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
phpDoc looks for a file-level docblock to appear before any code. Because that "if" in line 1 has no docblock before it, you get that error. The docblock that you do have, after that "if" line, would be associated with whatever code element happens to appear after it, whether it's a class, a function, even just an include/require line.
The only way you can "solve" that error is to put a docblock before that top "if" line. That docblock will need at least the @package tag in it, if nothing else, since this appears to not be namespaced code.
Like this:
<?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...
It might be necessary to have a docblock like that "/** no direct access */" in front of the IF line to, so that the parser does not tie the "Project 1 files" docblock to the "IF" line itself.