diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2008-08-15 01:29:47 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2008-08-15 01:29:47 +0200 |
commit | 370e83bb0dfd0c70de268c93bf07ad5ee0897192 (patch) | |
tree | 491674f4c242e4d6ba0d04eafa305174c35a3391 /maintenance/mwdocgen.php | |
parent | f4debf0f12d0524d2b2427c55ea3f16b680fad97 (diff) |
Update auf 1.13.0
Diffstat (limited to 'maintenance/mwdocgen.php')
-rw-r--r-- | maintenance/mwdocgen.php | 158 |
1 files changed, 96 insertions, 62 deletions
diff --git a/maintenance/mwdocgen.php b/maintenance/mwdocgen.php index d66e6874..378229e0 100644 --- a/maintenance/mwdocgen.php +++ b/maintenance/mwdocgen.php @@ -17,8 +17,9 @@ * - the menu doesnt work, got disabled at revision 13740. Need to code it. * * + * @file * @todo document - * @addtogroup Maintenance + * @ingroup Maintenance * * @author Ashar Voultoiz <thoane@altern.org> * @version first release @@ -45,6 +46,9 @@ $doxygenBin = 'doxygen'; /** doxygen configuration template for mediawiki */ $doxygenTemplate = $mwPath . 'maintenance/Doxyfile'; +/** svnstat command, used to get the version of each file */ +$svnstat = $mwPath . 'bin/svnstat'; + /** where Phpdoc should output documentation */ #$doxyOutput = '/var/www/mwdoc/'; $doxyOutput = $mwPath . 'docs' . DIRECTORY_SEPARATOR ; @@ -58,47 +62,87 @@ $mwPathS = $mwPath.'skins/'; /** Variable to get user input */ $input = ''; -/** shell command that will be run */ -$command = $doxygenBin; - # # Functions # -function readaline( $prompt = '') { +/** + * Read a line from the shell + * @param $prompt String + */ +function readaline( $prompt = '' ){ print $prompt; $fp = fopen( "php://stdin", "r" ); $resp = trim( fgets( $fp, 1024 ) ); fclose( $fp ); return $resp; +} + +/** + * Copied from SpecialVersion::getSvnRevision() + * @param $dir String + * @return Mixed: string or false + */ +function getSvnRevision( $dir ) { + // http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html + $entries = $dir . '/.svn/entries'; + + if( !file_exists( $entries ) ) { + return false; } + $content = file( $entries ); + + // check if file is xml (subversion release <= 1.3) or not (subversion release = 1.4) + if( preg_match( '/^<\?xml/', $content[0] ) ) { + // subversion is release <= 1.3 + if( !function_exists( 'simplexml_load_file' ) ) { + // We could fall back to expat... YUCK + return false; + } + + $xml = simplexml_load_file( $entries ); + + if( $xml ) { + foreach( $xml->entry as $entry ) { + if( $xml->entry[0]['name'] == '' ) { + // The directory entry should always have a revision marker. + if( $entry['revision'] ) { + return intval( $entry['revision'] ); + } + } + } + } + return false; + } else { + // subversion is release 1.4 + return intval( $content[3] ); + } +} + /** * 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 $svnstat String: path to the svnstat file * @param $input String: Path to analyze. */ -function generateConfigFile($doxygenTemplate, $outputDirectory, $stripFromPath, $input) { - global $tmpPath ; +function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $svnstat, $input ){ + global $tmpPath; - $template = file_get_contents($doxygenTemplate); + $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 - ); + $replacements = array( + '{{OUTPUT_DIRECTORY}}' => $outputDirectory, + '{{STRIP_FROM_PATH}}' => $stripFromPath, + '{{CURRENT_VERSION}}' => $currentVersion, + '{{SVNSTAT}}' => $svnstat, + '{{INPUT}}' => $input, + ); + $tmpCfg = str_replace( array_keys( $replacements ), array_values( $replacements ), $template ); $tmpFileName = $tmpPath . 'mwdocgen'. rand() .'.tmp'; file_put_contents( $tmpFileName , $tmpCfg ) or die("Could not write doxygen configuration to file $tmpFileName\n"); @@ -127,14 +171,18 @@ if( is_array( $argv ) && isset( $argv[1] ) ) { } } +// TODO : generate a list of paths )) + if( $input === '' ) { -?>Several documentation possibilities: + echo <<<OPTIONS +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<?php + 5 : only a given file +OPTIONS; while ( !is_numeric($input) ) { $input = readaline( "\nEnter your choice [0]:" ); @@ -143,62 +191,48 @@ if( $input === '' ) { } } } -/* + switch ($input) { -case 0: - $command .= " -f $mwBaseFiles -d $mwPathI,$mwPathL,$mwPathM,$mwPathS"; - break; -case 1: - $command .= "-d $mwPathI"; - break; -case 2: - $command .= "-d $mwPathL"; - break; -case 3: - $command .= "-d $mwPathM"; - break; -case 4: - $command .= "-d $mwPathS"; - break; +case 0: $input = $mwPath; break; +case 1: $input = $mwPathI; break; +case 2: $input = $mwPathL; break; +case 3: $input = $mwPathM; break; +case 4: $input = $mwPathS; break; case 5: if( !isset( $file ) ) { - $file = readaline("Enter file name $mwPath"); + $file = readaline( "Enter file name $mwPath" ); } - $command .= ' -f '.$mwPath.$file; + $input = $mwPath.$file; } -$command .= " -t $pdOutput ".$pdOthers; - -*/ - -// TODO : generate a list of paths )) -$input = $mwPath; +$versionNumber = getSvnRevision( $input ); +if( $versionNumber === false ){ #Not using subversion ? + $svnstat = ''; # Not really useful if subversion not available + $version = 'trunk'; # FIXME +} else { + $version = "trunk (r$versionNumber)"; +} -$generatedConf = generateConfigFile($doxygenTemplate, $doxyOutput, $mwPath, $input ); -$command = $doxygenBin . ' ' . $generatedConf ; +$generatedConf = generateConfigFile( $doxygenTemplate, $doxyOutput, $mwPath, $version, $svnstat, $input ); +$command = $doxygenBin . ' ' . $generatedConf; -?> +echo <<<TEXT --------------------------------------------------- Launching the command: -<?php echo $command ?> +$command --------------------------------------------------- -<?php -passthru($command); +TEXT; -?> +passthru( $command ); + +echo <<<TEXT --------------------------------------------------- Doxygen execution finished. Check above for possible errors. -You might want to deleted the temporary file <?php echo $generatedConf; ?> - -<?php - -# phpdoc -d ./mediawiki/includes/ ./mediawiki/maintenance/ -f ./mediawiki/*php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli' - -# phpdoc -f ./mediawiki/includes/GlobalFunctions.php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli' +You might want to deleted the temporary file $generatedConf -?> +TEXT; |