fix field names in PRIMARY KEY spec
[lhc/web/wiklou.git] / maintenance / mwdocgen.php
1 <?php
2 /**
3 * Script to easily generate the mediawiki documentation.
4 *
5 * By default it will generate the whole documentation but you will be able to
6 * generate just some parts.
7 *
8 * Usage:
9 * php mwdocgen.php
10 *
11 * Then make a selection from the menu
12 *
13 * @todo document
14 * @package MediaWiki
15 * @subpackage Maintenance
16 *
17 * @author Ashar Voultoiz <thoane@altern.org>
18 * @version first release
19 */
20
21 #
22 # Variables / Configuration
23 #
24
25 if( php_sapi_name() != 'cli' ) {
26 die( "Run me from the command line." );
27 }
28
29 /** Phpdoc script with full path */
30 #$pdExec = '/usr/bin/phpdoc';
31 $pdExec = 'phpdoc';
32
33 /** Figure out the base directory. */
34 $sep = DIRECTORY_SEPARATOR;
35 $here = dirname( dirname( __FILE__ ) ) . $sep;
36
37 /** where Phpdoc should output documentation */
38 #$pdOutput = '/var/www/mwdoc/';
39 $pdOutput = "{$here}{$sep}docs{$sep}html";
40
41 /** Some more Phpdoc settings */
42 $pdOthers = ' -dn \'MediaWiki\' ';
43 $pdOthers .= ' --title \'MediaWiki generated documentation\' -o \'HTML:frames:DOM/earthli\' --ignore AdminSettings.php,LocalSettings.php,tests/LocalTestSettings.php --parseprivate on ';
44
45 /** MediaWiki location */
46 #$mwPath = '/var/www/mediawiki/';
47 $mwPath = "{$here}{$sep}";
48
49 /** MediaWiki subpaths */
50 $mwPathI = $mwPath.'includes/';
51 $mwPathM = $mwPath.'maintenance/';
52 $mwPathS = $mwPath.'skins/';
53 $mwBaseFiles = $mwPath.'*php ';
54
55
56 /** Variable to get user input */
57 $input = '';
58 /** shell command that will be run */
59 $command = '';
60
61 #
62 # Functions
63 #
64
65 function readaline( $prompt = '') {
66 print $prompt;
67 $fp = fopen( "php://stdin", "r" );
68 $resp = trim( fgets( $fp, 1024 ) );
69 fclose( $fp );
70 return $resp;
71 }
72
73 #
74 # Main !
75 #
76
77 unset( $file );
78
79 if( is_array( $argv ) && isset( $argv[1] ) ) {
80 switch( $argv[1] ) {
81 case '--all': $input = 0; break;
82 case '--includes': $input = 1; break;
83 case '--maintenance': $input = 2; break;
84 case '--skins': $input = 3; break;
85 case '--file':
86 $input = 4;
87 if( isset( $argv[2] ) ) {
88 $file = $argv[2];
89 }
90 break;
91 }
92 }
93
94 if( $input === '' ) {
95 print <<<END
96 Several documentation possibilities:
97 0 : whole documentation (1 + 2 + 3)
98 1 : only includes
99 2 : only maintenance
100 3 : only skins
101 4 : only a given file
102 END;
103
104 while ( !is_numeric($input) )
105 {
106 $input = readaline( "\nEnter your choice [0]:" );
107 if($input == '') {
108 $input = 0;
109 }
110 }
111 }
112
113 $command = 'phpdoc ';
114 switch ($input) {
115 case 0:
116 $command .= " -f $mwBaseFiles -d $mwPathI,$mwPathM,$mwPathS ";
117 break;
118 case 1:
119 $command .= "-d $mwPathI ";
120 break;
121 case 2:
122 $command .= "-d $mwPathM ";
123 break;
124 case 3:
125 $command .= "-d $mwPathS ";
126 break;
127 case 4:
128 if( !isset( $file ) ) {
129 $file = readaline("\Enter file name $mwPath");
130 }
131 $command .= ' -f '.$mwPath.$file;
132 }
133
134 $command .= " -t $pdOutput ".$pdOthers;
135
136 print <<<END
137 ---------------------------------------------------
138 Launching the command:
139 $command
140 ---------------------------------------------------
141 END;
142
143 passthru( $command);
144
145 print <<<END
146 ---------------------------------------------------
147 Phpdoc execution finished.
148 Check above for possible errors.
149
150 END;
151
152
153 # phpdoc -d ./mediawiki/includes/ ./mediawiki/maintenance/ -f ./mediawiki/*php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'
154
155 # phpdoc -f ./mediawiki/includes/GlobalFunctions.php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'
156
157 ?>