summaryrefslogtreecommitdiff
path: root/maintenance/mwdocgen.php
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/mwdocgen.php')
-rw-r--r--maintenance/mwdocgen.php56
1 files changed, 19 insertions, 37 deletions
diff --git a/maintenance/mwdocgen.php b/maintenance/mwdocgen.php
index 0c3b262e..583249a5 100644
--- a/maintenance/mwdocgen.php
+++ b/maintenance/mwdocgen.php
@@ -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,6 +57,9 @@ $doxygenBin = 'doxygen';
/** doxygen configuration template for mediawiki */
$doxygenTemplate = $mwPath . 'maintenance/Doxyfile';
+/** doxygen input filter to tweak source file before they are parsed */
+$doxygenInputFilter = "php {$mwPath}maintenance/mwdoc-filter.php";
+
/** svnstat command, used to get the version of each file */
$svnstat = $mwPath . 'bin/svnstat';
@@ -77,7 +80,9 @@ $mwExcludePaths = array(
/** Variable to get user input */
$input = '';
-$exclude_patterns = '';
+$excludePatterns = '';
+/** Whether to generates man pages: */
+$doxyGenerateMan = false;
#
# Functions
@@ -114,31 +119,7 @@ function getSvnRevision( $dir ) {
$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] );
- }
+ return intval( $content[3] );
}
/**
@@ -150,16 +131,15 @@ function getSvnRevision( $dir ) {
* @param $svnstat String: path to the svnstat file
* @param $input String: Path to analyze.
* @param $exclude String: Additionals path regex to exclude
- * @param $exclude_patterns String: Additionals path regex to exclude
+ * @param $excludePatterns String: Additionals path regex to exclude
* (LocalSettings.php, AdminSettings.php, .svn and .git directories are always excluded)
+ * @param $doxyGenerateMan Boolean
* @return string
*/
-function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $svnstat, $input, $exclude, $exclude_patterns ) {
-
- global $wgDoxyGenerateMan;
+function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $svnstat, $input, $exclude, $excludePatterns, $doxyGenerateMan ) {
+ global $doxygenInputFilter;
$template = file_get_contents( $doxygenTemplate );
-
// Replace template placeholders by correct values.
$replacements = array(
'{{OUTPUT_DIRECTORY}}' => $outputDirectory,
@@ -168,9 +148,10 @@ function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath,
'{{SVNSTAT}}' => $svnstat,
'{{INPUT}}' => $input,
'{{EXCLUDE}}' => $exclude,
- '{{EXCLUDE_PATTERNS}}' => $exclude_patterns,
+ '{{EXCLUDE_PATTERNS}}' => $excludePatterns,
'{{HAVE_DOT}}' => `which dot` ? 'YES' : 'NO',
- '{{GENERATE_MAN}}' => $wgDoxyGenerateMan ? 'YES' : 'NO',
+ '{{GENERATE_MAN}}' => $doxyGenerateMan ? 'YES' : 'NO',
+ '{{INPUT_FILTER}}' => $doxygenInputFilter,
);
$tmpCfg = str_replace( array_keys( $replacements ), array_values( $replacements ), $template );
$tmpFileName = tempnam( wfTempDir(), 'mwdocgen-' );
@@ -208,7 +189,7 @@ if ( is_array( $argv ) ) {
}
break;
case '--generate-man':
- $wgDoxyGenerateMan = true;
+ $doxyGenerateMan = true;
break;
case '--help':
print <<<END
@@ -271,9 +252,10 @@ case 5:
$file = readaline( "Enter file name $mwPath" );
}
$input = $mwPath . $file;
+ break;
case 6:
$input = $mwPath;
- $exclude_patterns = 'extensions';
+ $excludePatterns = 'extensions';
}
$versionNumber = getSvnRevision( $input );
@@ -289,7 +271,7 @@ if ( $versionNumber === false ) { # Not using subversion ?
$excludedPaths = $mwPath . join( " $mwPath", $mwExcludePaths );
print "EXCLUDE: $excludedPaths\n\n";
-$generatedConf = generateConfigFile( $doxygenTemplate, $doxyOutput, $mwPath, $version, $svnstat, $input, $excludedPaths, $exclude_patterns );
+$generatedConf = generateConfigFile( $doxygenTemplate, $doxyOutput, $mwPath, $version, $svnstat, $input, $excludedPaths, $excludePatterns, $doxyGenerateMan );
$command = $doxygenBin . ' ' . $generatedConf;
echo <<<TEXT