Recentchanges optimization: avoid a lot of senseless parsing of link text coming...
[lhc/web/wiklou.git] / maintenance / mwdocgen.php
index 8d0c8e3..ba95e9f 100755 (executable)
 # Variables / Configuration
 #
 
+if( php_sapi_name() != 'cli' ) {
+       die( "Run me from the command line." );
+}
+
 /** Phpdoc script with full path */
-$pdExec        = '/usr/bin/phpdoc';
+#$pdExec       = '/usr/bin/phpdoc';
+$pdExec = 'phpdoc';
+
+/** Figure out the base directory. */
+$sep = DIRECTORY_SEPARATOR;
+$here = dirname( dirname( __FILE__ ) ) . $sep;
+
 /** where Phpdoc should output documentation */
-$pdOutput = '/var/www/mwdoc/';
+#$pdOutput = '/var/www/mwdoc/';
+$pdOutput = "{$here}{$sep}docs{$sep}html";
 
 /** Some more Phpdoc settings */
-//$pdOthers = ' -dn \'MediaWiki\' ';
-$pdOthers .= ' --title \'Mediawiki generated documentation\' -o \'HTML:frames:DOM/earthli\' ';
+$pdOthers = ' -dn \'MediaWiki\' ';
+$pdOthers .= ' --title \'MediaWiki generated documentation\' -o \'HTML:frames:DOM/earthli\' --ignore AdminSettings.php,LocalSettings.php,tests/LocalTestSettings.php --parseprivate on ';
 
-/** Mediawiki location */
-$mwPath = '/var/www/mediawiki/';
+/** MediaWiki location */
+#$mwPath = '/var/www/mediawiki/';
+$mwPath = "{$here}{$sep}";
 
-/** Mediawiki subpaths */
+/** MediaWiki subpaths */
 $mwPathI = $mwPath.'includes/';
 $mwPathM = $mwPath.'maintenance/';
 $mwPathS = $mwPath.'skins/';
@@ -62,7 +74,25 @@ function readaline( $prompt = '') {
 # Main !
 #
 
-print <<<END
+unset( $file );
+
+if( is_array( $argv ) && isset( $argv[1] ) ) {
+       switch( $argv[1] ) {
+       case '--all':         $input = 0; break;
+       case '--includes':    $input = 1; break;
+       case '--maintenance': $input = 2; break;
+       case '--skins':       $input = 3; break;
+       case '--file':
+               $input = 4;
+               if( isset( $argv[2] ) ) {
+                       $file = $argv[2];
+               }
+               break;
+       }
+}
+
+if( $input === '' ) {
+       print <<<END
 Several documentation possibilities:
  0 : whole documentation (1 + 2 + 3)
  1 : only includes
@@ -71,11 +101,12 @@ Several documentation possibilities:
  4 : only a given file
 END;
 
-while ( !is_numeric($input) )
-{
-       $input = readaline( "\nEnter your choice [0]:" );
-       if($input == '') {
-               $input = 0;
+       while ( !is_numeric($input) )
+       {
+               $input = readaline( "\nEnter your choice [0]:" );
+               if($input == '') {
+                       $input = 0;
+               }
        }
 }
 
@@ -94,7 +125,9 @@ case 3:
        $command .= "-d $mwPathS ";
        break;
 case 4:
-       $file = readaline("\Enter file name $mwPath");
+       if( !isset( $file ) ) {
+               $file = readaline("\Enter file name $mwPath");
+       }
        $command .= ' -f '.$mwPath.$file;
 }
 
@@ -117,8 +150,8 @@ Check above for possible errors.
 END;
 
 
-# phpdoc -d ./mediawiki/includes/ ./mediawiki/maintenance/ -f ./mediawiki/*php -t ./mwdoc/ -dn 'MediaWiki' --title 'Mediawiki generated documentation' -o 'HTML:frames:DOM/earthli'
+# 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'
+# phpdoc -f ./mediawiki/includes/GlobalFunctions.php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'
 
 ?>