use wfRegexReplacement() which was added a little while ago to cover this silly regex...
[mediawiki.git] / maintenance / mwdocgen.php
blob135f7ed4dd89976a94ad575775cc322675ce7fd2
1 <?php
2 /**
3 * Script to easily generate the mediawiki documentation.
5 * By default it will generate the whole documentation but you will be able to
6 * generate just some parts.
8 * Usage:
9 * php mwdocgen.php
11 * Then make a selection from the menu
13 * @todo document
14 * @package MediaWiki
15 * @subpackage Maintenance
17 * @author Ashar Voultoiz <thoane@altern.org>
18 * @version first release
22 # Variables / Configuration
25 if( php_sapi_name() != 'cli' ) {
26 echo "Run me from the command line.";
27 die( -1 );
30 /** Phpdoc script with full path */
31 #$pdExec = '/usr/bin/phpdoc';
32 $pdExec = 'phpdoc';
34 /** Figure out the base directory. */
35 $here = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR;
37 /** where Phpdoc should output documentation */
38 #$pdOutput = '/var/www/mwdoc/';
39 $pdOutput = "{$here}docs" . DIRECTORY_SEPARATOR . 'html';
41 /** Some more Phpdoc settings */
42 # This will be used as the default for all files that don't have a package,
43 # it's useful to set it to something like 'untagged' to hunt down and fix files
44 # that don't have a package name declared.
45 $pdOthers = " -dn MediaWiki";
46 $pdOthers .= ' --title "MediaWiki generated documentation"';
47 $pdOthers .= ' --output "HTML:Smarty:HandS"'; #,HTML:Smarty:HandS"'; ###### HTML:frames:DOM/earthli
48 $pdOthers .= ' --ignore AdminSettings.php,LocalSettings.php,tests/LocalTestSettings.php';
49 $pdOthers .= ' --parseprivate on';
50 $pdOthers .= ' --sourcecode on';
52 /** MediaWiki location */
53 #$mwPath = '/var/www/mediawiki/';
54 $mwPath = "{$here}";
56 /** MediaWiki subpaths */
57 $mwPathI = $mwPath.'includes/';
58 $mwPathL = $mwPath.'languages/';
59 $mwPathM = $mwPath.'maintenance/';
60 $mwPathS = $mwPath.'skins/';
61 $mwBaseFiles = $mwPath.'*php ';
64 /** Variable to get user input */
65 $input = '';
66 /** shell command that will be run */
67 $command = '';
70 # Functions
73 function readaline( $prompt = '') {
74 print $prompt;
75 $fp = fopen( "php://stdin", "r" );
76 $resp = trim( fgets( $fp, 1024 ) );
77 fclose( $fp );
78 return $resp;
82 # Main !
85 unset( $file );
87 if( is_array( $argv ) && isset( $argv[1] ) ) {
88 switch( $argv[1] ) {
89 case '--all': $input = 0; break;
90 case '--includes': $input = 1; break;
91 case '--languages': $input = 2; break;
92 case '--maintenance': $input = 3; break;
93 case '--skins': $input = 4; break;
94 case '--file':
95 $input = 5;
96 if( isset( $argv[2] ) ) {
97 $file = $argv[2];
99 break;
103 if( $input === '' ) {
104 ?>Several documentation possibilities:
105 0 : whole documentation (1 + 2 + 3)
106 1 : only includes
107 2 : only languages
108 3 : only maintenance
109 4 : only skins
110 5 : only a given file<?php
111 while ( !is_numeric($input) )
113 $input = readaline( "\nEnter your choice [0]:" );
114 if($input == '') {
115 $input = 0;
120 $command = 'phpdoc ';
121 switch ($input) {
122 case 0:
123 $command .= " -f $mwBaseFiles -d $mwPathI,$mwPathL,$mwPathM,$mwPathS";
124 break;
125 case 1:
126 $command .= "-d $mwPathI";
127 break;
128 case 2:
129 $command .= "-d $mwPathL";
130 break;
131 case 3:
132 $command .= "-d $mwPathM";
133 break;
134 case 4:
135 $command .= "-d $mwPathS";
136 break;
137 case 5:
138 if( !isset( $file ) ) {
139 $file = readaline("Enter file name $mwPath");
141 $command .= ' -f '.$mwPath.$file;
144 $command .= " -t $pdOutput ".$pdOthers;
147 ---------------------------------------------------
148 Launching the command:
150 <?php echo $command ?>
152 ---------------------------------------------------
153 <?php
155 passthru($command);
158 ---------------------------------------------------
159 Phpdoc execution finished.
160 Check above for possible errors.
161 <?php
163 # phpdoc -d ./mediawiki/includes/ ./mediawiki/maintenance/ -f ./mediawiki/*php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'
165 # phpdoc -f ./mediawiki/includes/GlobalFunctions.php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'