I've gone and done something naughty. I've just bumped $wgVersion
[lhc/web/wiklou.git] / maintenance / mwdocgen.php
index 3a78f67..05fbdf9 100644 (file)
@@ -29,7 +29,7 @@
 # Variables / Configuration
 #
 
-if( php_sapi_name() != 'cli' ) {
+if ( php_sapi_name() != 'cli' ) {
        echo 'Run me from the command line.';
        die( -1 );
 }
@@ -50,17 +50,18 @@ $doxygenTemplate = $mwPath . 'maintenance/Doxyfile';
 $svnstat = $mwPath . 'bin/svnstat';
 
 /** where Phpdoc should output documentation */
-#$doxyOutput = '/var/www/mwdoc/';
+# $doxyOutput = '/var/www/mwdoc/';
 $doxyOutput = $mwPath . 'docs' . DIRECTORY_SEPARATOR ;
 
 /** MediaWiki subpaths */
-$mwPathI = $mwPath.'includes/';
-$mwPathL = $mwPath.'languages/';
-$mwPathM = $mwPath.'maintenance/';
-$mwPathS = $mwPath.'skins/';
+$mwPathI = $mwPath . 'includes/';
+$mwPathL = $mwPath . 'languages/';
+$mwPathM = $mwPath . 'maintenance/';
+$mwPathS = $mwPath . 'skins/';
 
 /** Variable to get user input */
 $input = '';
+$exclude = '';
 
 #
 # Functions
@@ -70,7 +71,7 @@ $input = '';
  * Read a line from the shell
  * @param $prompt String
  */
-function readaline( $prompt = '' ){
+function readaline( $prompt = '' ) {
        print $prompt;
        $fp = fopen( "php://stdin", "r" );
        $resp = trim( fgets( $fp, 1024 ) );
@@ -87,27 +88,27 @@ function getSvnRevision( $dir ) {
        // http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html
        $entries = $dir . '/.svn/entries';
 
-       if( !file_exists( $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] ) ) {
+       if ( preg_match( '/^<\?xml/', $content[0] ) ) {
                // subversion is release <= 1.3
-               if( !function_exists( 'simplexml_load_file' ) ) {
+               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'] == '' ) {
+               if ( $xml ) {
+                       foreach ( $xml->entry as $entry ) {
+                               if ( $xml->entry[0]['name'] == '' ) {
                                        // The directory entry should always have a revision marker.
-                                       if( $entry['revision'] ) {
+                                       if ( $entry['revision'] ) {
                                                return intval( $entry['revision'] );
                                        }
                                }
@@ -128,8 +129,10 @@ function getSvnRevision( $dir ) {
  * @param $currentVersion String: Version number of the software
  * @param $svnstat String: path to the svnstat file
  * @param $input String: Path to analyze.
+ * @param $exclude String: Additionals path regex to exlcude 
+ *                 (LocalSettings.php, AdminSettings.php and .svn directories are always excluded)
  */
-function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $svnstat, $input ){
+function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $svnstat, $input, $exclude ) {
        global $tmpPath;
 
        $template = file_get_contents( $doxygenTemplate );
@@ -141,10 +144,11 @@ function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath,
                '{{CURRENT_VERSION}}'  => $currentVersion,
                '{{SVNSTAT}}'          => $svnstat,
                '{{INPUT}}'            => $input,
+               '{{EXCLUDE}}'          => $exclude,
        );
        $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");
+       $tmpFileName = $tmpPath . 'mwdocgen' . rand() . '.tmp';
+       file_put_contents( $tmpFileName , $tmpCfg ) or die( "Could not write doxygen configuration to file $tmpFileName\n" );
 
        return $tmpFileName;
 }
@@ -155,7 +159,7 @@ function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath,
 
 unset( $file );
 
-if( is_array( $argv ) && isset( $argv[1] ) ) {
+if ( is_array( $argv ) && isset( $argv[1] ) ) {
        switch( $argv[1] ) {
        case '--all':         $input = 0; break;
        case '--includes':    $input = 1; break;
@@ -164,16 +168,17 @@ if( is_array( $argv ) && isset( $argv[1] ) ) {
        case '--skins':       $input = 4; break;
        case '--file':
                $input = 5;
-               if( isset( $argv[2] ) ) {
+               if ( isset( $argv[2] ) ) {
                        $file = $argv[2];
                }
                break;
+       case '--no-extensions': $input = 6; break;
        }
 }
 
 // TODO : generate a list of paths ))
 
-if( $input === '' ) {
+if ( $input === '' ) {
        echo <<<OPTIONS
 Several documentation possibilities:
  0 : whole documentation (1 + 2 + 3 + 4)
@@ -182,38 +187,42 @@ Several documentation possibilities:
  3 : only maintenance
  4 : only skins
  5 : only a given file
+ 6 : all but the extensions directory
 OPTIONS;
-       while ( !is_numeric($input) )
+       while ( !is_numeric( $input ) )
        {
                $input = readaline( "\nEnter your choice [0]:" );
-               if($input == '') {
+               if ( $input == '' ) {
                        $input = 0;
                }
        }
 }
 
-switch ($input) {
+switch ( $input ) {
 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 ) ) {
+       if ( !isset( $file ) ) {
                $file = readaline( "Enter file name $mwPath" );
        }
-       $input = $mwPath.$file;
+       $input = $mwPath . $file;
+case 6:
+       $input = $mwPath;
+       $exclude = 'extensions';
 }
 
 $versionNumber = getSvnRevision( $input );
-if( $versionNumber === false ){ #Not using subversion ?
+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, $version, $svnstat, $input );
+$generatedConf = generateConfigFile( $doxygenTemplate, $doxyOutput, $mwPath, $version, $svnstat, $input, $exclude );
 $command = $doxygenBin . ' ' . $generatedConf;
 
 echo <<<TEXT