MediaWiki REL1_30
mwdocgen.php
Go to the documentation of this file.
1<?php
36require_once __DIR__ . '/Maintenance.php';
37
42class MWDocGen extends Maintenance {
43
47 public function __construct() {
48 parent::__construct();
49 $this->addDescription( 'Build doxygen documentation' );
50
51 $this->addOption( 'doxygen',
52 'Path to doxygen',
53 false, true );
54 $this->addOption( 'version',
55 'Pass a MediaWiki version',
56 false, true );
57 $this->addOption( 'generate-man',
58 'Whether to generate man files' );
59 $this->addOption( 'file',
60 "Only process given file or directory. Multiple values " .
61 "accepted with comma separation. Path relative to \$IP.",
62 false, true );
63 $this->addOption( 'output',
64 'Path to write doc to',
65 false, true );
66 $this->addOption( 'no-extensions',
67 'Ignore extensions' );
68 }
69
70 public function getDbType() {
72 }
73
74 protected function init() {
75 global $wgPhpCli, $IP;
76
77 $this->doxygen = $this->getOption( 'doxygen', 'doxygen' );
78 $this->mwVersion = $this->getOption( 'version', 'master' );
79
80 $this->input = '';
81 $inputs = explode( ',', $this->getOption( 'file', '' ) );
82 foreach ( $inputs as $input ) {
83 # Doxygen inputs are space separted and double quoted
84 $this->input .= " \"$IP/$input\"";
85 }
86
87 $this->output = $this->getOption( 'output', "$IP/docs" );
88
89 // Do not use wfShellWikiCmd, because mwdoc-filter.php is not
90 // a Maintenance script.
91 $this->inputFilter = wfEscapeShellArg( [
93 $IP . '/maintenance/mwdoc-filter.php'
94 ] );
95
96 $this->template = $IP . '/maintenance/Doxyfile';
97 $this->excludes = [
98 'vendor',
99 'node_modules',
100 'images',
101 'static',
102 ];
103 $this->excludePatterns = [];
104 if ( $this->hasOption( 'no-extensions' ) ) {
105 $this->excludePatterns[] = 'extensions';
106 }
107
108 $this->doDot = shell_exec( 'which dot' );
109 $this->doMan = $this->hasOption( 'generate-man' );
110 }
111
112 public function execute() {
113 global $IP;
114
115 $this->init();
116
117 # Build out directories we want to exclude
118 $exclude = '';
119 foreach ( $this->excludes as $item ) {
120 $exclude .= " $IP/$item";
121 }
122
123 $excludePatterns = implode( ' ', $this->excludePatterns );
124
125 $conf = strtr( file_get_contents( $this->template ),
126 [
127 '{{OUTPUT_DIRECTORY}}' => $this->output,
128 '{{STRIP_FROM_PATH}}' => $IP,
129 '{{CURRENT_VERSION}}' => $this->mwVersion,
130 '{{INPUT}}' => $this->input,
131 '{{EXCLUDE}}' => $exclude,
132 '{{EXCLUDE_PATTERNS}}' => $excludePatterns,
133 '{{HAVE_DOT}}' => $this->doDot ? 'YES' : 'NO',
134 '{{GENERATE_MAN}}' => $this->doMan ? 'YES' : 'NO',
135 '{{INPUT_FILTER}}' => $this->inputFilter,
136 ]
137 );
138
139 $tmpFile = tempnam( wfTempDir(), 'MWDocGen-' );
140 if ( file_put_contents( $tmpFile, $conf ) === false ) {
141 $this->error( "Could not write doxygen configuration to file $tmpFile\n",
142 1 );
143 }
144
145 $command = $this->doxygen . ' ' . $tmpFile;
146 $this->output( "Executing command:\n$command\n" );
147
148 $exitcode = 1;
149 system( $command, $exitcode );
150
151 $this->output( <<<TEXT
152---------------------------------------------------
153Doxygen execution finished.
154Check above for possible errors.
155
156You might want to delete the temporary file:
157 $tmpFile
158---------------------------------------------------
159
160TEXT
161 );
162
163 if ( $exitcode !== 0 ) {
164 $this->error( "Something went wrong (exit: $exitcode)\n",
165 $exitcode );
166 }
167 }
168}
169
170$maintClass = 'MWDocGen';
171require_once RUN_MAINTENANCE_IF_MAIN;
this section has the sole purpose of protecting the integrity of the free software distribution system
Definition COPYING.txt:218
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a and you may at your option offer warranty protection in exchange for a fee You may modify your copy or copies of the Program or any portion of thus forming a work based on the and copy and distribute such modifications or work under the terms of Section above
Definition COPYING.txt:93
$wgPhpCli
Executable path of the PHP cli binary (php/php5).
wfTempDir()
Tries to get the system directory for temporary files.
wfEscapeShellArg()
Version of escapeshellarg() that works better on Windows.
$command
Definition cdb.php:64
Maintenance script that builds doxygen documentation.
Definition mwdocgen.php:42
__construct()
Prepare Maintenance class.
Definition mwdocgen.php:47
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
Definition mwdocgen.php:70
execute()
Do the actual work.
Definition mwdocgen.php:112
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
const DB_NONE
Constants for DB access type.
hasOption( $name)
Checks to see if a particular param exists.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
Definition hooks.txt:2581
$IP
Definition update.php:3
require_once RUN_MAINTENANCE_IF_MAIN
$maintClass
Definition mwdocgen.php:170
if(is_array($mode)) switch( $mode) $input