2004-09-03 23:07:58 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
2010-12-27 16:56:50 +00:00
|
|
|
* Generate class and file reference documentation for MediaWiki using doxygen.
|
2004-09-03 23:07:58 +00:00
|
|
|
*
|
2010-12-27 16:56:50 +00:00
|
|
|
* If the dot DOT language processor is available, attempt call graph
|
|
|
|
|
* generation.
|
2004-09-03 23:07:58 +00:00
|
|
|
*
|
|
|
|
|
* Usage:
|
|
|
|
|
* php mwdocgen.php
|
|
|
|
|
*
|
2010-12-16 19:15:12 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2006-04-19 15:46:24 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
2004-09-03 23:07:58 +00:00
|
|
|
* @todo document
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Maintenance
|
2004-09-03 23:07:58 +00:00
|
|
|
*
|
2011-10-24 09:08:13 +00:00
|
|
|
* @author Antoine Musso <hashar at free dot fr>
|
2010-09-27 18:46:16 +00:00
|
|
|
* @author Brion Vibber
|
|
|
|
|
* @author Alexandre Emsenhuber
|
2004-09-03 23:07:58 +00:00
|
|
|
* @version first release
|
|
|
|
|
*/
|
|
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
2008-06-25 13:42:01 +00:00
|
|
|
|
2006-04-19 15:46:24 +00:00
|
|
|
/**
|
2013-05-21 22:04:11 +00:00
|
|
|
* Maintenance script that builds doxygen documentation.
|
|
|
|
|
* @ingroup Maintenance
|
2006-04-19 15:46:24 +00:00
|
|
|
*/
|
2013-05-21 22:04:11 +00:00
|
|
|
class MWDocGen extends Maintenance {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prepare Maintenance class
|
|
|
|
|
*/
|
|
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
2016-01-30 02:48:47 +00:00
|
|
|
$this->addDescription( 'Build doxygen documentation' );
|
2013-05-21 22:04:11 +00:00
|
|
|
|
|
|
|
|
$this->addOption( 'doxygen',
|
|
|
|
|
'Path to doxygen',
|
|
|
|
|
false, true );
|
|
|
|
|
$this->addOption( 'version',
|
|
|
|
|
'Pass a MediaWiki version',
|
|
|
|
|
false, true );
|
|
|
|
|
$this->addOption( 'generate-man',
|
|
|
|
|
'Whether to generate man files' );
|
|
|
|
|
$this->addOption( 'file',
|
2013-05-30 18:41:27 +00:00
|
|
|
"Only process given file or directory. Multiple values " .
|
|
|
|
|
"accepted with comma separation. Path relative to \$IP.",
|
2013-05-21 22:04:11 +00:00
|
|
|
false, true );
|
|
|
|
|
$this->addOption( 'output',
|
|
|
|
|
'Path to write doc to',
|
|
|
|
|
false, true );
|
|
|
|
|
$this->addOption( 'no-extensions',
|
|
|
|
|
'Ignore extensions' );
|
|
|
|
|
}
|
2004-09-04 08:54:59 +00:00
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
public function getDbType() {
|
|
|
|
|
return Maintenance::DB_NONE;
|
|
|
|
|
}
|
2011-09-14 21:38:26 +00:00
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
protected function init() {
|
|
|
|
|
global $IP;
|
|
|
|
|
|
|
|
|
|
$this->doxygen = $this->getOption( 'doxygen', 'doxygen' );
|
|
|
|
|
$this->mwVersion = $this->getOption( 'version', 'master' );
|
2013-05-30 18:41:27 +00:00
|
|
|
|
|
|
|
|
$this->input = '';
|
|
|
|
|
$inputs = explode( ',', $this->getOption( 'file', '' ) );
|
2013-08-24 15:06:25 +00:00
|
|
|
foreach ( $inputs as $input ) {
|
2013-05-30 18:41:27 +00:00
|
|
|
# Doxygen inputs are space separted and double quoted
|
|
|
|
|
$this->input .= " \"$IP/$input\"";
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
$this->output = $this->getOption( 'output', "$IP/docs" );
|
|
|
|
|
|
2015-11-23 20:33:01 +00:00
|
|
|
$this->inputFilter = wfShellWikiCmd( $IP . '/maintenance/mwdoc-filter.php' );
|
2013-05-21 22:04:11 +00:00
|
|
|
$this->template = $IP . '/maintenance/Doxyfile';
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->excludes = [
|
2013-06-08 11:07:57 +00:00
|
|
|
'vendor',
|
2015-03-31 23:44:53 +00:00
|
|
|
'node_modules',
|
2013-05-21 22:04:11 +00:00
|
|
|
'images',
|
|
|
|
|
'static',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
|
|
|
|
$this->excludePatterns = [];
|
2013-05-21 22:04:11 +00:00
|
|
|
if ( $this->hasOption( 'no-extensions' ) ) {
|
|
|
|
|
$this->excludePatterns[] = 'extensions';
|
|
|
|
|
}
|
2011-09-14 21:38:26 +00:00
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
$this->doDot = `which dot`;
|
|
|
|
|
$this->doMan = $this->hasOption( 'generate-man' );
|
|
|
|
|
}
|
2011-09-14 21:38:26 +00:00
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
public function execute() {
|
|
|
|
|
global $IP;
|
2011-09-14 21:38:26 +00:00
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
$this->init();
|
2011-09-14 21:38:26 +00:00
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
# Build out directories we want to exclude
|
|
|
|
|
$exclude = '';
|
|
|
|
|
foreach ( $this->excludes as $item ) {
|
|
|
|
|
$exclude .= " $IP/$item";
|
2004-09-04 08:54:59 +00:00
|
|
|
}
|
2008-06-25 13:42:01 +00:00
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
$excludePatterns = implode( ' ', $this->excludePatterns );
|
|
|
|
|
|
|
|
|
|
$conf = strtr( file_get_contents( $this->template ),
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2013-05-21 22:04:11 +00:00
|
|
|
'{{OUTPUT_DIRECTORY}}' => $this->output,
|
|
|
|
|
'{{STRIP_FROM_PATH}}' => $IP,
|
|
|
|
|
'{{CURRENT_VERSION}}' => $this->mwVersion,
|
|
|
|
|
'{{INPUT}}' => $this->input,
|
|
|
|
|
'{{EXCLUDE}}' => $exclude,
|
|
|
|
|
'{{EXCLUDE_PATTERNS}}' => $excludePatterns,
|
|
|
|
|
'{{HAVE_DOT}}' => $this->doDot ? 'YES' : 'NO',
|
|
|
|
|
'{{GENERATE_MAN}}' => $this->doMan ? 'YES' : 'NO',
|
|
|
|
|
'{{INPUT_FILTER}}' => $this->inputFilter,
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2013-05-21 22:04:11 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$tmpFile = tempnam( wfTempDir(), 'MWDocGen-' );
|
|
|
|
|
if ( file_put_contents( $tmpFile, $conf ) === false ) {
|
|
|
|
|
$this->error( "Could not write doxygen configuration to file $tmpFile\n",
|
|
|
|
|
/** exit code: */ 1 );
|
2004-09-04 01:58:17 +00:00
|
|
|
}
|
2004-09-03 23:07:58 +00:00
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
$command = $this->doxygen . ' ' . $tmpFile;
|
|
|
|
|
$this->output( "Executing command:\n$command\n" );
|
2011-02-08 22:33:57 +00:00
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
$exitcode = 1;
|
|
|
|
|
system( $command, $exitcode );
|
2006-04-19 15:46:24 +00:00
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
$this->output( <<<TEXT
|
2004-09-03 23:07:58 +00:00
|
|
|
---------------------------------------------------
|
2013-05-21 22:04:11 +00:00
|
|
|
Doxygen execution finished.
|
|
|
|
|
Check above for possible errors.
|
2005-04-07 19:46:06 +00:00
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
You might want to delete the temporary file:
|
|
|
|
|
$tmpFile
|
2004-09-03 23:07:58 +00:00
|
|
|
---------------------------------------------------
|
|
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
TEXT
|
2014-04-23 18:09:13 +00:00
|
|
|
);
|
2008-06-25 13:42:01 +00:00
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
if ( $exitcode !== 0 ) {
|
|
|
|
|
$this->error( "Something went wrong (exit: $exitcode)\n",
|
|
|
|
|
$exitcode );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-03-15 05:43:56 +00:00
|
|
|
|
2013-05-21 22:04:11 +00:00
|
|
|
$maintClass = 'MWDocGen';
|
|
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|