* @author Brion Vibber * @author Alexandre Emsenhuber * @version first release */ # # Variables / Configuration # if ( PHP_SAPI != 'cli' ) { echo 'Run "' . __FILE__ . '" from the command line.'; die( -1 ); } /** Figure out the base directory for MediaWiki location */ $mwPath = dirname( __DIR__ ) . DIRECTORY_SEPARATOR; /** doxygen binary script */ $doxygenBin = 'doxygen'; /** doxygen configuration template for mediawiki */ $doxygenTemplate = $mwPath . 'maintenance/Doxyfile'; /** doxygen input filter to tweak source file before they are parsed */ $doxygenInputFilter = "php {$mwPath}maintenance/mwdoc-filter.php"; /** where Phpdoc should output documentation */ $doxyOutput = $mwPath . 'docs' . DIRECTORY_SEPARATOR ; $doxyVersion = 'master'; /** MediaWiki subpaths */ $mwPathI = $mwPath . 'includes/'; $mwPathL = $mwPath . 'languages/'; $mwPathM = $mwPath . 'maintenance/'; $mwPathS = $mwPath . 'skins/'; /** Ignored paths relative to $mwPath */ $mwExcludePaths = array( 'images', 'static', ); /** Variable to get user input */ $input = ''; $excludePatterns = ''; /** Whether to generates man pages: */ $doxyGenerateMan = false; # # Functions # define( 'MEDIAWIKI', true ); require_once( "$mwPath/includes/GlobalFunctions.php" ); /** * Read a line from the shell * @param $prompt String * @return string */ 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 $currentVersion String: Version number of the software * @param $input String: Path to analyze. * @param $exclude String: Additionals path regex to exclude * @param $excludePatterns String: Additionals path regex to exclude * (LocalSettings.php, AdminSettings.php, .svn and .git directories are always excluded) * @param $doxyGenerateMan Boolean * @return string */ function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $input, $exclude, $excludePatterns, $doxyGenerateMan, $doxygenInputFilter ) { $template = file_get_contents( $doxygenTemplate ); // Replace template placeholders by correct values. $replacements = array( '{{OUTPUT_DIRECTORY}}' => $outputDirectory, '{{STRIP_FROM_PATH}}' => $stripFromPath, '{{CURRENT_VERSION}}' => $currentVersion, '{{INPUT}}' => $input, '{{EXCLUDE}}' => $exclude, '{{EXCLUDE_PATTERNS}}' => $excludePatterns, '{{HAVE_DOT}}' => `which dot` ? 'YES' : 'NO', '{{GENERATE_MAN}}' => $doxyGenerateMan ? 'YES' : 'NO', '{{INPUT_FILTER}}' => $doxygenInputFilter, ); $tmpCfg = str_replace( array_keys( $replacements ), array_values( $replacements ), $template ); $tmpFileName = tempnam( wfTempDir(), 'mwdocgen-' ); 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 ) ) { for ($i = 0; $i < count($argv); $i++ ) { switch( $argv[$i] ) { 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; $i++; if ( isset( $argv[$i] ) ) { $file = $argv[$i]; } break; case '--no-extensions': $input = 6; break; case '--output': $i++; if ( isset( $argv[$i] ) ) { $doxyOutput = realpath( $argv[$i] ); } break; case '--version': $i++; if ( isset( $argv[$i] ) ) { $doxyVersion = $argv[$i]; } break; case '--generate-man': $doxyGenerateMan = true; break; case '--help': print <<] [] Commands: --all Process entire codebase --includes Process only files in includes/ dir --languages Process only files in languages/ dir --maintenance Process only files in maintenance/ dir --skins Process only files in skins/ dir --file Process only the given file --no-extensions Process everything but extensions directorys If no command is given, you will be prompted. Other options: --output Set output directory (default: $doxyOutput) --generate-man Generates man page documentation --version Project version to display in the outut (default: $doxyVersion) --help Show this help and exit. END; exit(0); break; } } } // TODO : generate a list of paths )) if ( $input === '' ) { echo <<