Merge "Make EditPage robust against null content."
[lhc/web/wiklou.git] / maintenance / mwdocgen.php
index 2edeaba..e36674e 100644 (file)
@@ -49,7 +49,7 @@ if ( php_sapi_name() != 'cli' ) {
 }
 
 /** Figure out the base directory for MediaWiki location */
-$mwPath = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR;
+$mwPath = dirname( __DIR__ ) . DIRECTORY_SEPARATOR;
 
 /** doxygen binary script */
 $doxygenBin = 'doxygen';
@@ -57,8 +57,8 @@ $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';
+/** 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 ;
@@ -101,31 +101,12 @@ function readaline( $prompt = '' ) {
        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 );
-
-       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.
  * @param $exclude String: Additionals path regex to exclude
  * @param $excludePatterns String: Additionals path regex to exclude
@@ -133,21 +114,21 @@ function getSvnRevision( $dir ) {
  * @param $doxyGenerateMan Boolean
  * @return string
  */
-function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $svnstat, $input, $exclude, $excludePatterns, $doxyGenerateMan ) {
+function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $input, $exclude, $excludePatterns, $doxyGenerateMan ) {
+       global $doxygenInputFilter;
 
        $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,
                '{{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-' );
@@ -254,20 +235,14 @@ case 6:
        $excludePatterns = 'extensions';
 }
 
-$versionNumber = getSvnRevision( $input );
-if ( $versionNumber === false ) { # Not using subversion ?
-       $svnstat = ''; # Not really useful if subversion not available
-       # @todo FIXME
-       $version = 'trunk';
-} else {
-       $version = "trunk (r$versionNumber)";
-}
+// @todo FIXME to work on git
+$version = 'master';
 
 // Generate path exclusions
 $excludedPaths = $mwPath . join( " $mwPath", $mwExcludePaths );
 print "EXCLUDE: $excludedPaths\n\n";
 
-$generatedConf = generateConfigFile( $doxygenTemplate, $doxyOutput, $mwPath, $version, $svnstat, $input, $excludedPaths, $excludePatterns, $doxyGenerateMan );
+$generatedConf = generateConfigFile( $doxygenTemplate, $doxyOutput, $mwPath, $version, $input, $excludedPaths, $excludePatterns, $doxyGenerateMan );
 $command = $doxygenBin . ' ' . $generatedConf;
 
 echo <<<TEXT