Use handy-dandy __FILE__ constant to get the pathname instead of more
[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 = '';
43 //$pdOthers = ' -dn \'MediaWiki\' ';
44 $pdOthers .= ' --title \'MediaWiki generated documentation\' -o \'HTML:frames:DOM/earthli\' ';
45
46 /** MediaWiki location */
47 #$mwPath = '/var/www/mediawiki/';
48 $mwPath = "{$here}{$sep}";
49
50 /** MediaWiki subpaths */
51 $mwPathI = $mwPath.'includes/';
52 $mwPathM = $mwPath.'maintenance/';
53 $mwPathS = $mwPath.'skins/';
54 $mwBaseFiles = $mwPath.'*php ';
55
56
57 /** Variable to get user input */
58 $input = '';
59 /** shell command that will be run */
60 $command = '';
61
62 #
63 # Functions
64 #
65
66 function readaline( $prompt = '') {
67 print $prompt;
68 $fp = fopen( "php://stdin", "r" );
69 $resp = trim( fgets( $fp, 1024 ) );
70 fclose( $fp );
71 return $resp;
72 }
73
74 #
75 # Main !
76 #
77
78 unset( $file );
79
80 if( is_array( $argv ) && isset( $argv[1] ) ) {
81 switch( $argv[1] ) {
82 case '--all': $input = 0; break;
83 case '--includes': $input = 1; break;
84 case '--maintenance': $input = 2; break;
85 case '--skins': $input = 3; break;
86 case '--file':
87 $input = 4;
88 if( isset( $argv[2] ) ) {
89 $file = $argv[2];
90 }
91 break;
92 }
93 }
94
95 if( $input === '' ) {
96 print <<<END
97 Several documentation possibilities:
98 0 : whole documentation (1 + 2 + 3)
99 1 : only includes
100 2 : only maintenance
101 3 : only skins
102 4 : only a given file
103 END;
104
105 while ( !is_numeric($input) )
106 {
107 $input = readaline( "\nEnter your choice [0]:" );
108 if($input == '') {
109 $input = 0;
110 }
111 }
112 }
113
114 $command = 'phpdoc ';
115 switch ($input) {
116 case 0:
117 $command .= " -f $mwBaseFiles -d $mwPathI,$mwPathM,$mwPathS ";
118 break;
119 case 1:
120 $command .= "-d $mwPathI ";
121 break;
122 case 2:
123 $command .= "-d $mwPathM ";
124 break;
125 case 3:
126 $command .= "-d $mwPathS ";
127 break;
128 case 4:
129 if( !isset( $file ) ) {
130 $file = readaline("\Enter file name $mwPath");
131 }
132 $command .= ' -f '.$mwPath.$file;
133 }
134
135 $command .= " -t $pdOutput ".$pdOthers;
136
137 print <<<END
138 ---------------------------------------------------
139 Launching the command:
140 $command
141 ---------------------------------------------------
142 END;
143
144 passthru( $command);
145
146 print <<<END
147 ---------------------------------------------------
148 Phpdoc execution finished.
149 Check above for possible errors.
150
151 END;
152
153
154 # phpdoc -d ./mediawiki/includes/ ./mediawiki/maintenance/ -f ./mediawiki/*php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'
155
156 # phpdoc -f ./mediawiki/includes/GlobalFunctions.php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'
157
158 ?>