3 * Script to easily generate the mediawiki documentation using doxygen.
5 * By default it will generate the whole documentation but you will be able to
6 * generate just some parts.
11 * Then make a selection from the menu
15 * - pass_thru seems to always use buffering (even with ob_implicit_flush()),
16 * that make output slow when doxygen parses language files.
17 * - the menu doesnt work, got disabled at revision 13740. Need to code it.
21 * @addtogroup Maintenance
23 * @author Ashar Voultoiz <thoane@altern.org>
24 * @version first release
28 # Variables / Configuration
31 if( php_sapi_name() != 'cli' ) {
32 echo 'Run me from the command line.';
36 /** Figure out the base directory for MediaWiki location */
37 $mwPath = dirname( dirname( __FILE__
) ) . DIRECTORY_SEPARATOR
;
39 /** Global variable: temporary directory */
42 /** doxygen binary script */
43 $doxygenBin = 'doxygen';
45 /** doxygen configuration template for mediawiki */
46 $doxygenTemplate = $mwPath . 'maintenance/Doxyfile';
48 /** where Phpdoc should output documentation */
49 #$doxyOutput = '/var/www/mwdoc/';
50 $doxyOutput = $mwPath . 'docs' . DIRECTORY_SEPARATOR
;
52 /** MediaWiki subpaths */
53 $mwPathI = $mwPath.'includes/';
54 $mwPathL = $mwPath.'languages/';
55 $mwPathM = $mwPath.'maintenance/';
56 $mwPathS = $mwPath.'skins/';
58 /** Variable to get user input */
61 /** shell command that will be run */
62 $command = $doxygenBin;
68 function readaline( $prompt = '') {
70 $fp = fopen( "php://stdin", "r" );
71 $resp = trim( fgets( $fp, 1024 ) );
77 * Generate a configuration file given user parameters and return the temporary filename.
78 * @param $doxygenTemplate String: full path for the template.
79 * @param $outputDirectory String: directory where the stuff will be output.
80 * @param $stripFromPath String: path that should be stripped out (usually mediawiki base path).
81 * @param $input String: Path to analyze.
83 function generateConfigFile($doxygenTemplate, $outputDirectory, $stripFromPath, $input) {
86 $template = file_get_contents($doxygenTemplate);
88 // Replace template placeholders by correct values.
89 $tmpCfg = str_replace(
91 '{{OUTPUT_DIRECTORY}}',
92 '{{STRIP_FROM_PATH}}',
102 $tmpFileName = $tmpPath . 'mwdocgen'. rand() .'.tmp';
103 file_put_contents( $tmpFileName , $tmpCfg ) or die("Could not write doxygen configuration to file $tmpFileName\n");
114 if( is_array( $argv ) && isset( $argv[1] ) ) {
116 case '--all': $input = 0; break;
117 case '--includes': $input = 1; break;
118 case '--languages': $input = 2; break;
119 case '--maintenance': $input = 3; break;
120 case '--skins': $input = 4; break;
123 if( isset( $argv[2] ) ) {
130 if( $input === '' ) {
131 ?
>Several documentation possibilities
:
132 0 : whole
documentation (1 +
2 +
3 +
4)
137 5 : only a given file
<?php
138 while ( !is_numeric($input) )
140 $input = readaline( "\nEnter your choice [0]:" );
149 $command .= " -f $mwBaseFiles -d $mwPathI,$mwPathL,$mwPathM,$mwPathS";
152 $command .= "-d $mwPathI";
155 $command .= "-d $mwPathL";
158 $command .= "-d $mwPathM";
161 $command .= "-d $mwPathS";
164 if( !isset( $file ) ) {
165 $file = readaline("Enter file name $mwPath");
167 $command .= ' -f '.$mwPath.$file;
170 $command .= " -t $pdOutput ".$pdOthers;
174 // TODO : generate a list of paths ))
177 $generatedConf = generateConfigFile($doxygenTemplate, $doxyOutput, $mwPath, $input );
178 $command = $doxygenBin . ' ' . $generatedConf ;
181 ---------------------------------------------------
182 Launching the command
:
184 <?php
echo $command ?
>
186 ---------------------------------------------------
192 ---------------------------------------------------
193 Doxygen execution finished
.
194 Check above
for possible errors
.
196 You might want to deleted the temporary file
<?php
echo $generatedConf; ?
>
200 # phpdoc -d ./mediawiki/includes/ ./mediawiki/maintenance/ -f ./mediawiki/*php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'
202 # phpdoc -f ./mediawiki/includes/GlobalFunctions.php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'