* @version first release */ # # Variables / Configuration # if( php_sapi_name() != 'cli' ) { echo 'Run me from the command line.'; die( -1 ); } /** Figure out the base directory for MediaWiki location */ $mwPath = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR; /** Global variable: temporary directory */ $tmpPath = '/tmp/'; /** doxygen binary script */ $doxygenBin = 'doxygen'; /** doxygen configuration template for mediawiki */ $doxygenTemplate = $mwPath . 'maintenance/Doxyfile'; /** where Phpdoc should output documentation */ #$doxyOutput = '/var/www/mwdoc/'; $doxyOutput = $mwPath . 'docs' . DIRECTORY_SEPARATOR ; /** MediaWiki subpaths */ $mwPathI = $mwPath.'includes/'; $mwPathL = $mwPath.'languages/'; $mwPathM = $mwPath.'maintenance/'; $mwPathS = $mwPath.'skins/'; /** Variable to get user input */ $input = ''; /** shell command that will be run */ $command = $doxygenBin; # # Functions # function readaline( $prompt = '') { print $prompt; $fp = fopen( "php://stdin", "r" ); $resp = trim( fgets( $fp, 1024 ) ); fclose( $fp ); return $resp; } /** * Generate a configuration file given user parameters and return the temporary filename. * @param $doxygenTemplate String: full path for the template. * @param $outputDirectory String: directory where the stuff will be output. * @param $stripFromPath String: path that should be stripped out (usually mediawiki base path). * @param $input String: Path to analyze. */ function generateConfigFile($doxygenTemplate, $outputDirectory, $stripFromPath, $input) { global $tmpPath ; $template = file_get_contents($doxygenTemplate); // Replace template placeholders by correct values. $tmpCfg = str_replace( array( '{{OUTPUT_DIRECTORY}}', '{{STRIP_FROM_PATH}}', '{{INPUT}}', ), array( $outputDirectory, $stripFromPath, $input, ), $template ); $tmpFileName = $tmpPath . 'mwdocgen'. rand() .'.tmp'; file_put_contents( $tmpFileName , $tmpCfg ) or die("Could not write doxygen configuration to file $tmpFileName\n"); return $tmpFileName; } # # Main ! # unset( $file ); if( is_array( $argv ) && isset( $argv[1] ) ) { switch( $argv[1] ) { case '--all': $input = 0; break; case '--includes': $input = 1; break; case '--languages': $input = 2; break; case '--maintenance': $input = 3; break; case '--skins': $input = 4; break; case '--file': $input = 5; if( isset( $argv[2] ) ) { $file = $argv[2]; } break; } } if( $input === '' ) { ?>Several documentation possibilities: 0 : whole documentation (1 + 2 + 3 + 4) 1 : only includes 2 : only languages 3 : only maintenance 4 : only skins 5 : only a given file --------------------------------------------------- Launching the command: --------------------------------------------------- --------------------------------------------------- Doxygen execution finished. Check above for possible errors. You might want to deleted the temporary file