]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - maintenance/mwdocgen.php
MediaWiki 1.5.8 (initial commit)
[autoinstalls/mediawiki.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 $here = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR;
35
36 /** where Phpdoc should output documentation */
37 #$pdOutput = '/var/www/mwdoc/';
38 $pdOutput = "{$here}docs" . DIRECTORY_SEPARATOR . 'html';
39
40 /** Some more Phpdoc settings */
41 # This will be used as the default for all files that don't have a package,
42 # it's useful to set it to something like 'untagged' to hunt down and fix files
43 # that don't have a package name declared.
44 $pdOthers = " -dn MediaWiki"; 
45 $pdOthers .= ' --title "MediaWiki generated documentation"'; 
46 $pdOthers .= ' --output "HTML:Smarty:HandS"'; #,HTML:Smarty:HandS"'; ###### HTML:frames:DOM/earthli
47 $pdOthers .= ' --ignore AdminSettings.php,LocalSettings.php,tests/LocalTestSettings.php';
48 $pdOthers .= ' --parseprivate on';
49 $pdOthers .= ' --sourcecode on';
50
51 /** MediaWiki location */
52 #$mwPath = '/var/www/mediawiki/';
53 $mwPath = "{$here}";
54
55 /** MediaWiki subpaths */
56 $mwPathI = $mwPath.'includes/';
57 $mwPathL = $mwPath.'languages/';
58 $mwPathM = $mwPath.'maintenance/';
59 $mwPathS = $mwPath.'skins/';
60 $mwBaseFiles = $mwPath.'*php ';
61
62
63 /** Variable to get user input */
64 $input = '';
65 /** shell command that will be run */
66 $command = '';
67
68 #
69 # Functions
70 #
71
72 function readaline( $prompt = '') {
73         print $prompt;
74         $fp = fopen( "php://stdin", "r" );
75         $resp = trim( fgets( $fp, 1024 ) );
76         fclose( $fp );
77         return $resp;
78         }
79
80 #
81 # Main !
82 #
83
84 unset( $file );
85
86 if( is_array( $argv ) && isset( $argv[1] ) ) {
87         switch( $argv[1] ) {
88         case '--all':         $input = 0; break;
89         case '--includes':    $input = 1; break;
90         case '--languages':   $input = 2; break;
91         case '--maintenance': $input = 3; break;
92         case '--skins':       $input = 4; break;
93         case '--file':
94                 $input = 5;
95                 if( isset( $argv[2] ) ) {
96                         $file = $argv[2];
97                 }
98                 break;
99         }
100 }
101
102 if( $input === '' ) {
103 ?>Several documentation possibilities:
104  0 : whole documentation (1 + 2 + 3)
105  1 : only includes
106  2 : only languages
107  3 : only maintenance
108  4 : only skins
109  5 : only a given file<?php
110         while ( !is_numeric($input) )
111         {
112                 $input = readaline( "\nEnter your choice [0]:" );
113                 if($input == '') {
114                         $input = 0;
115                 }
116         }
117 }
118
119 $command = 'phpdoc ';
120 switch ($input) {
121 case 0:
122         $command .= " -f $mwBaseFiles -d $mwPathI,$mwPathL,$mwPathM,$mwPathS";
123         break;
124 case 1:
125         $command .= "-d $mwPathI";
126         break;
127 case 2: 
128         $command .= "-d $mwPathL";
129         break;
130 case 3:
131         $command .= "-d $mwPathM";
132         break;
133 case 4:
134         $command .= "-d $mwPathS";
135         break;
136 case 5:
137         if( !isset( $file ) ) {
138                 $file = readaline("Enter file name $mwPath");
139         }
140         $command .= ' -f '.$mwPath.$file;
141 }
142
143 $command .= " -t $pdOutput ".$pdOthers;
144
145 ?>
146 ---------------------------------------------------
147 Launching the command:
148
149 <?php echo $command ?>
150
151 ---------------------------------------------------
152 <?php
153
154 passthru($command);
155
156 ?>
157 ---------------------------------------------------
158 Phpdoc execution finished.
159 Check above for possible errors.
160 <?php
161
162 # phpdoc -d ./mediawiki/includes/ ./mediawiki/maintenance/ -f ./mediawiki/*php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'
163
164 # phpdoc -f ./mediawiki/includes/GlobalFunctions.php -t ./mwdoc/ -dn 'MediaWiki' --title 'MediaWiki generated documentation' -o 'HTML:frames:DOM/earthli'
165
166 ?>