0

im trying to get the hang out of YUIdoc, but i cant get it to work: This is a part of my PHP code:

/**
* Estimates whether a number is odd or even
*
*@method odd_or_even
*@param num {number} String to fix
*@return {Boolean} Returns True on even number, False on odd
*/
function odd_or_even($num)
{
return ($num%2); // Returns 0 for odd and 1 for even
}

/**
* Detects if user runs one of the most common browsers
*
*@method detect_browser
*@return {string} Returns the browser name. 'Undefined' for undefined
*/
function detect_browser()
    {
$useragent = $_SERVER['HTTP_USER_AGENT'];

if(strpos($useragent, 'MSIE'))
    $browser = 'Internet explorer';

elseif(strpos($useragent, 'Firefox'))
    $browser = 'Firefox';

elseif(strpos($useragent, 'Chrome'))
    $browser = 'Google Chrome';

elseif(strpos($useragent, 'Opera'))
    $browser = 'Opera';

elseif(strpos($useragent, 'Safari'))
    $browser = 'Safari';

elseif(strpos($useragent, 'SeaMonkey'))
    $browser = 'SeaMonkey';

elseif(strpos($useragent, 'Flock'))
    $browser = 'Flock';

elseif(strpos($useragent, 'Prism'))
    $browser = 'Prism';

elseif(strpos($useragent, 'Deepnet Explorer'))
    $browser = 'Deepnet Explorer';

elseif(strpos($useragent, 'Maxthon'))
    $browser = 'Maxthon';

elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Avant'))
    $browser = 'Avant';

elseif(strpos($useragent, 'Camino'))
    $browser = 'Camino';

elseif(strpos($useragent, 'Shiira'))
    $browser = 'Shiira';

elseif(strpos($useragent, 'OmniWeb'))
    $browser = 'OmniWeb';

elseif(strpos($useragent, 'iCab'))
    $browser = 'iCab';

elseif(strpos($useragent, 'Stainless'))
    $browser = 'Stainless';

elseif(strpos($useragent, 'Fluid'))
    $browser = 'Fluid';

elseif(strpos($useragent, 'Konqueror'))
    $browser = 'Konqueror';

elseif(strpos($useragent, 'Galeon'))
    $browser = 'Galeon';

elseif(strpos($useragent, 'Epiphany'))
    $browser = 'Epiphany';

elseif(strpos($useragent, 'Swiftfox'))
    $browser = 'Swiftfox';

elseif(strpos($useragent, 'Swiftweasel'))
    $browser = 'Swiftweasel';

else
    $browser = 'Undefined';

return $browser;

}

Saved as lib.php Then i run 'yuidoc .' and this is the output:

info: (yuidoc): Starting YUIDoc@0.3.13 using YUI@3.5.1 with NodeJS@0.6.12
info: (yuidoc): Scanning for yuidoc.json file.
info: (yuidoc): Starting YUIDoc with the following options:
info: (yuidoc): { port: 3000, nocode: false, paths: [ '.' ], outdir: './out' }
info: (yuidoc): YUIDoc Starting from: .
info: (yuidoc): Making out dir: ./out
info: (yuidoc): Parsed 0 files in 0.004 seconds
info: (builder): Building..
info: (builder): Compiling Templates
info: (builder): Making default directories: classes,modules,files
info: (builder): Copying Assets
info: (builder): Rendering and writing 0 modules pages.
info: (builder): Finished writing module files
info: (builder): Rendering and writing 0 class pages.
info: (builder): Finished writing class files
info: (builder): Rendering and writing 0 source files.
info: (builder): Finished writing source files
info: (builder): Preparing index.html
info: (builder): Loading theme from/usr/local/lib/node_modules/yuidocjs/themes/default/theme.json
info: (builder): Writing API Meta Data
info: (builder): Writing index.html
info: (builder): Finished writing 1 files in 0.077 seconds
info: (yuidoc): Completed in 0.085 seconds

And the documentation is empty. I've also tried with javascript, with the same result. What im i dong wrong?

Thank you in advance Adam

Theadamlt
  • 310
  • 1
  • 5
  • 18

1 Answers1

-1

Your YUIDoc syntax is not formatted correctly. You must have spaces between the asterix's and the @ tags. The following header works fine for me:

/**
* Estimates whether a number is odd or even
*
* @method odd_or_even
* @param num {number} String to fix
* @return {Boolean} Returns True on even number, False on odd
*/
function odd_or_even($num)
{
return ($num%2); // Returns 0 for odd and 1 for even
}

/**
* Detects if user runs one of the most common browsers
*
* @method detect_browser
* @return {string} Returns the browser name. 'Undefined' for undefined
*/
olan
  • 3,568
  • 5
  • 24
  • 30
  • I doubt that YUIDoc can be used for PHP documentation. Your example does not work for me, can you please provide a working example? – alkar Mar 04 '13 at 14:25
  • As you can see from the docs, it *should* work: http://yui.github.com/yuidoc/ The latest node-based yuidoc seems to have a few issues with my sample though. It parses the php code correctly when it's renamed as a js file however. Probably worth raising a bug: https://github.com/yui/yuidoc/issues – olan Mar 11 '13 at 00:58
  • It needs the --extension=.php argument or something like that, after all :) – alkar Mar 11 '13 at 13:11