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.
22 * @ingroup Maintenance
24 * @author Ashar Voultoiz <thoane@altern.org>
25 * @version first release
29 # Variables / Configuration
32 if( php_sapi_name() != 'cli' ) {
33 echo 'Run me from the command line.';
37 /** Figure out the base directory for MediaWiki location */
38 $mwPath = dirname( dirname( __FILE__
) ) . DIRECTORY_SEPARATOR
;
40 /** Global variable: temporary directory */
43 /** doxygen binary script */
44 $doxygenBin = 'doxygen';
46 /** doxygen configuration template for mediawiki */
47 $doxygenTemplate = $mwPath . 'maintenance/Doxyfile';
49 /** where Phpdoc should output documentation */
50 #$doxyOutput = '/var/www/mwdoc/';
51 $doxyOutput = $mwPath . 'docs' . DIRECTORY_SEPARATOR
;
53 /** MediaWiki subpaths */
54 $mwPathI = $mwPath.'includes/';
55 $mwPathL = $mwPath.'languages/';
56 $mwPathM = $mwPath.'maintenance/';
57 $mwPathS = $mwPath.'skins/';
59 /** Variable to get user input */
62 /** shell command that will be run */
63 $command = $doxygenBin;
69 function readaline( $prompt = '') {
71 $fp = fopen( "php://stdin", "r" );
72 $resp = trim( fgets( $fp, 1024 ) );
78 * Generate a configuration file given user parameters and return the temporary filename.
79 * @param $doxygenTemplate String: full path for the template.
80 * @param $outputDirectory String: directory where the stuff will be output.
81 * @param $stripFromPath String: path that should be stripped out (usually mediawiki base path).
82 * @param $input String: Path to analyze.
84 function generateConfigFile($doxygenTemplate, $outputDirectory, $stripFromPath, $input) {
87 $template = file_get_contents($doxygenTemplate);
89 // Replace template placeholders by correct values.
90 $tmpCfg = str_replace(
92 '{{OUTPUT_DIRECTORY}}',
93 '{{STRIP_FROM_PATH}}',
103 $tmpFileName = $tmpPath . 'mwdocgen'. rand() .'.tmp';
104 file_put_contents( $tmpFileName , $tmpCfg ) or die("Could not write doxygen configuration to file $tmpFileName\n");
115 if( is_array( $argv ) && isset( $argv[1] ) ) {
117 case '--all': $input = 0; break;
118 case '--includes': $input = 1; break;
119 case '--languages': $input = 2; break;
120 case '--maintenance': $input = 3; break;
121 case '--skins': $input = 4; break;
124 if( isset( $argv[2] ) ) {
131 if( $input === '' ) {
132 ?
>Several documentation possibilities
:
133 0 : whole
documentation (1 +
2 +
3 +
4)
138 5 : only a given file
<?php
139 while ( !is_numeric($input) )
141 $input = readaline( "\nEnter your choice [0]:" );
150 $command .= " -f $mwBaseFiles -d $mwPathI,$mwPathL,$mwPathM,$mwPathS";
153 $command .= "-d $mwPathI";
156 $command .= "-d $mwPathL";
159 $command .= "-d $mwPathM";
162 $command .= "-d $mwPathS";
165 if( !isset( $file ) ) {
166 $file = readaline("Enter file name $mwPath");
168 $command .= ' -f '.$mwPath.$file;
171 $command .= " -t $pdOutput ".$pdOthers;
175 // TODO : generate a list of paths ))
178 $generatedConf = generateConfigFile($doxygenTemplate, $doxyOutput, $mwPath, $input );
179 $command = $doxygenBin . ' ' . $generatedConf ;
182 ---------------------------------------------------
183 Launching the command
:
185 <?php
echo $command ?
>
187 ---------------------------------------------------
193 ---------------------------------------------------
194 Doxygen execution finished
.
195 Check above
for possible errors
.
197 You might want to deleted the temporary file
<?php
echo $generatedConf; ?
>
201 # phpdoc -d ./mediawiki/includes/ ./mediawiki/maintenance/ -f ./mediawiki/*php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'
203 # phpdoc -f ./mediawiki/includes/GlobalFunctions.php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'