38 require_once __DIR__ .
'/Maintenance.php';
60 private $excludePatterns;
68 parent::__construct();
75 'Pass a MediaWiki version',
78 "Only process given file or directory. Multiple values " .
79 "accepted with comma separation. Path relative to \$IP.",
82 'Path to write doc to',
85 'Process the extensions/ directory as well (ignored if --file is used)' );
87 'Process the skins/ directory as well (ignored if --file is used)' );
94 protected function init() {
97 $this->doxygen = $this->
getOption(
'doxygen',
'doxygen' );
98 $this->mwVersion = $this->
getOption(
'version',
'master' );
101 $inputs = explode(
',', $this->
getOption(
'file',
'' ) );
102 foreach ( $inputs as $input ) {
103 # Doxygen inputs are space separated and double quoted
104 $this->input .=
" \"$IP/$input\"";
111 $this->inputFilter = Shell::escape( [
113 $IP .
'/maintenance/mwdoc-filter.php'
116 $this->
template = $IP .
'/maintenance/Doxyfile';
121 $this->excludePatterns = [];
122 if ( $this->input ===
'' ) {
125 if ( !$this->
hasOption(
'extensions' ) ) {
126 $this->excludePatterns[] =
'extensions';
129 $this->excludePatterns[] =
'skins';
133 $this->doDot = (bool)shell_exec(
'which dot' );
141 # Build out directories we want to exclude
143 foreach ( $this->excludes as $item ) {
144 $exclude .=
" $IP/$item";
147 $excludePatterns = implode(
' ', $this->excludePatterns );
149 $conf = strtr( file_get_contents( $this->
template ),
151 '{{OUTPUT_DIRECTORY}}' => $this->
output,
152 '{{STRIP_FROM_PATH}}' => $IP,
153 '{{CURRENT_VERSION}}' => $this->mwVersion,
154 '{{INPUT}}' => $this->input,
155 '{{EXCLUDE}}' => $exclude,
156 '{{EXCLUDE_PATTERNS}}' => $excludePatterns,
157 '{{HAVE_DOT}}' => $this->doDot ?
'YES' :
'NO',
158 '{{INPUT_FILTER}}' => $this->inputFilter,
162 $tmpFile = tempnam(
wfTempDir(),
'MWDocGen-' );
163 if ( file_put_contents( $tmpFile, $conf ) ===
false ) {
164 $this->
fatalError(
"Could not write doxygen configuration to file $tmpFile\n" );
167 $command = $this->doxygen .
' ' . $tmpFile;
168 $this->
output(
"Executing command:\n$command\n" );
171 system( $command, $exitcode );
174 ---------------------------------------------------
175 Doxygen execution finished.
176 Check above
for possible errors.
178 You might want to
delete the temporary file:
180 ---------------------------------------------------
185 if ( $exitcode !== 0 ) {
186 $this->
fatalError(
"Something went wrong (exit: $exitcode)\n", $exitcode );
192 require_once RUN_MAINTENANCE_IF_MAIN;
wfTempDir()
Tries to get the system directory for temporary files.
if(!defined( 'MEDIAWIKI')) if(ini_get( 'mbstring.func_overload')) if(!defined( 'MW_ENTRY_POINT')) global $IP
Environment checks.
Maintenance script that builds doxygen documentation.
__construct()
Prepare Maintenance class.
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
execute()
Do the actual work.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
const DB_NONE
Constants for DB access type.
output( $out, $channel=null)
Throw some output to the user.
hasOption( $name)
Checks to see if a particular option was set.
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.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
$wgPhpCli
Config variable stub for the PhpCli setting, for use by phpdoc and IDEs.