X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Fmwdocgen.php;h=378229e0cdcb111520f9cee6d597f921da0a39cb;hb=d7f7a5052f3923d5db96d7e337fccd506a5ab478;hp=8d0c8e3846d83c95ff88d84f70ce955adab94b1d;hpb=b30b717463776b620f0b75084249d7c65b4f38f4;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/mwdocgen.php b/maintenance/mwdocgen.php old mode 100755 new mode 100644 index 8d0c8e3846..378229e0cd --- a/maintenance/mwdocgen.php +++ b/maintenance/mwdocgen.php @@ -1,6 +1,6 @@ * @version first release @@ -22,103 +29,210 @@ # Variables / Configuration # -/** Phpdoc script with full path */ -$pdExec = '/usr/bin/phpdoc'; -/** where Phpdoc should output documentation */ -$pdOutput = '/var/www/mwdoc/'; +if( php_sapi_name() != 'cli' ) { + echo 'Run me from the command line.'; + die( -1 ); +} -/** Some more Phpdoc settings */ -//$pdOthers = ' -dn \'MediaWiki\' '; -$pdOthers .= ' --title \'Mediawiki generated documentation\' -o \'HTML:frames:DOM/earthli\' '; +/** Figure out the base directory for MediaWiki location */ +$mwPath = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR; -/** Mediawiki location */ -$mwPath = '/var/www/mediawiki/'; +/** Global variable: temporary directory */ +$tmpPath = '/tmp/'; + +/** doxygen binary script */ +$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 ; -/** Mediawiki subpaths */ +/** MediaWiki subpaths */ $mwPathI = $mwPath.'includes/'; +$mwPathL = $mwPath.'languages/'; $mwPathM = $mwPath.'maintenance/'; $mwPathS = $mwPath.'skins/'; -$mwBaseFiles = $mwPath.'*php '; - /** Variable to get user input */ $input = ''; -/** shell command that will be run */ -$command = ''; # # 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, $currentVersion, $svnstat, $input ){ + global $tmpPath; + + $template = file_get_contents( $doxygenTemplate ); + + // Replace template placeholders by correct values. + $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"); + + return $tmpFileName; +} # # Main ! # -print << +TEXT;