X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Fmwdocgen.php;h=1e4eed8ac45194b0f160cee786f1452a3c237f1d;hb=d998f4d43d61f47dbbd784510938ea45d5dc919f;hp=73cd923017d7683555c0d9d6025ac00668236d1b;hpb=0bad506855d49e164ddefe994044d6b3e867bc8e;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/mwdocgen.php b/maintenance/mwdocgen.php old mode 100755 new mode 100644 index 73cd923017..1e4eed8ac4 --- a/maintenance/mwdocgen.php +++ b/maintenance/mwdocgen.php @@ -1,6 +1,6 @@ * @version first release @@ -23,51 +30,37 @@ # if( php_sapi_name() != 'cli' ) { - die( "Run me from the command line." ); + echo 'Run me from the command line.'; + die( -1 ); } -/** Phpdoc script with full path */ -#$pdExec = '/usr/bin/phpdoc'; -$pdExec = 'phpdoc'; - -/** Figure out the base directory. This is harder than it should be. */ -/** Since we're on the command line, don't trust the PWD! */ -$here = null; -$self = $_SERVER['SCRIPT_FILENAME']; -$sep = DIRECTORY_SEPARATOR; -foreach( get_included_files() as $f ) { - if( preg_match( "!^(.*)maintenance$sep$self\$!", $f, $matches ) ) { - $here = $matches[1]; - } -} -if( is_null( $here ) ) { - die( "Couldn't determine current directory.\n" ); -} +/** Figure out the base directory for MediaWiki location */ +$mwPath = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR; -/** where Phpdoc should output documentation */ -#$pdOutput = '/var/www/mwdoc/'; -$pdOutput = "{$here}{$sep}docs{$sep}html"; +/** Global variable: temporary directory */ +$tmpPath = '/tmp/'; + +/** doxygen binary script */ +$doxygenBin = 'doxygen'; -/** Some more Phpdoc settings */ -$pdOthers = ''; -//$pdOthers = ' -dn \'MediaWiki\' '; -$pdOthers .= ' --title \'MediaWiki generated documentation\' -o \'HTML:frames:DOM/earthli\' '; +/** doxygen configuration template for mediawiki */ +$doxygenTemplate = $mwPath . 'maintenance/Doxyfile'; -/** MediaWiki location */ -#$mwPath = '/var/www/mediawiki/'; -$mwPath = "{$here}{$sep}"; +/** where Phpdoc should output documentation */ +#$doxyOutput = '/var/www/mwdoc/'; +$doxyOutput = $mwPath . 'docs' . DIRECTORY_SEPARATOR ; /** 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 = ''; +$command = $doxygenBin; # # Functions @@ -81,23 +74,68 @@ function readaline( $prompt = '') { return $resp; } +/** + * 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 $input String: Path to analyze. + */ +function generateConfigFile($doxygenTemplate, $outputDirectory, $stripFromPath, $input) { + global $tmpPath ; + + $template = file_get_contents($doxygenTemplate); + + // Replace template placeholders by correct values. + $tmpCfg = str_replace( + array( + '{{OUTPUT_DIRECTORY}}', + '{{STRIP_FROM_PATH}}', + '{{INPUT}}', + ), + array( + $outputDirectory, + $stripFromPath, + $input, + ), + $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 ! # -if( is_array( $argv ) && isset( $argv[1] ) && $argv[1] == '--all' ) { - # Quick option - $input = 0; -} else { - print <<Several documentation possibilities: + 0 : whole documentation (1 + 2 + 3 + 4) + 1 : only includes + 2 : only languages + 3 : only maintenance + 4 : only skins + 5 : only a given file --------------------------------------------------- Launching the command: -$command + + + --------------------------------------------------- -END; + --------------------------------------------------- -Phpdoc execution finished. +Doxygen execution finished. Check above for possible errors. -END; +You might want to deleted the temporary file +