* Added wfDie() wrapper, and some manual die(-1), to force the return code
[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 echo "Run me from the command line.";
27 die( -1 );
28 }
29
30 /** Phpdoc script with full path */
31 #$pdExec = '/usr/bin/phpdoc';
32 $pdExec = 'phpdoc';
33
34 /** Figure out the base directory. */
35 $here = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR;
36
37 /** where Phpdoc should output documentation */
38 #$pdOutput = '/var/www/mwdoc/';
39 $pdOutput = "{$here}docs" . DIRECTORY_SEPARATOR . 'html';
40
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';
51
52 /** MediaWiki location */
53 #$mwPath = '/var/www/mediawiki/';
54 $mwPath = "{$here}";
55
56 /** MediaWiki subpaths */
57 $mwPathI = $mwPath.'includes/';
58 $mwPathL = $mwPath.'languages/';
59 $mwPathM = $mwPath.'maintenance/';
60 $mwPathS = $mwPath.'skins/';
61 $mwBaseFiles = $mwPath.'*php ';
62
63
64 /** Variable to get user input */
65 $input = '';
66 /** shell command that will be run */
67 $command = '';
68
69 #
70 # Functions
71 #
72
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;
79 }
80
81 #
82 # Main !
83 #
84
85 unset( $file );
86
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];
98 }
99 break;
100 }
101 }
102
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) )
112 {
113 $input = readaline( "\nEnter your choice [0]:" );
114 if($input == '') {
115 $input = 0;
116 }
117 }
118 }
119
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");
140 }
141 $command .= ' -f '.$mwPath.$file;
142 }
143
144 $command .= " -t $pdOutput ".$pdOthers;
145
146 ?>
147 ---------------------------------------------------
148 Launching the command:
149
150 <?php echo $command ?>
151
152 ---------------------------------------------------
153 <?php
154
155 passthru($command);
156
157 ?>
158 ---------------------------------------------------
159 Phpdoc execution finished.
160 Check above for possible errors.
161 <?php
162
163 # phpdoc -d ./mediawiki/includes/ ./mediawiki/maintenance/ -f ./mediawiki/*php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'
164
165 # phpdoc -f ./mediawiki/includes/GlobalFunctions.php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'
166
167 ?>