MediaWiki  1.23.8
mwdocgen.php
Go to the documentation of this file.
1 <?php
36 require_once __DIR__ . '/Maintenance.php';
37 
42 class MWDocGen extends Maintenance {
43 
47  public function __construct() {
48  parent::__construct();
49  $this->mDescription = '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() {
71  return Maintenance::DB_NONE;
72  }
73 
74  protected function init() {
75  global $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  $this->inputFilter = wfShellWikiCmd(
90  $IP . '/maintenance/mwdoc-filter.php' );
91  $this->template = $IP . '/maintenance/Doxyfile';
92  $this->excludes = array(
93  'vendor',
94  'images',
95  'static',
96  );
97  $this->excludePatterns = array();
98  if ( $this->hasOption( 'no-extensions' ) ) {
99  $this->excludePatterns[] = 'extensions';
100  }
101 
102  $this->doDot = `which dot`;
103  $this->doMan = $this->hasOption( 'generate-man' );
104  }
105 
106  public function execute() {
107  global $IP;
108 
109  $this->init();
110 
111  # Build out directories we want to exclude
112  $exclude = '';
113  foreach ( $this->excludes as $item ) {
114  $exclude .= " $IP/$item";
115  }
116 
117  $excludePatterns = implode( ' ', $this->excludePatterns );
118 
119  $conf = strtr( file_get_contents( $this->template ),
120  array(
121  '{{OUTPUT_DIRECTORY}}' => $this->output,
122  '{{STRIP_FROM_PATH}}' => $IP,
123  '{{CURRENT_VERSION}}' => $this->mwVersion,
124  '{{INPUT}}' => $this->input,
125  '{{EXCLUDE}}' => $exclude,
126  '{{EXCLUDE_PATTERNS}}' => $excludePatterns,
127  '{{HAVE_DOT}}' => $this->doDot ? 'YES' : 'NO',
128  '{{GENERATE_MAN}}' => $this->doMan ? 'YES' : 'NO',
129  '{{INPUT_FILTER}}' => $this->inputFilter,
130  )
131  );
132 
133  $tmpFile = tempnam( wfTempDir(), 'MWDocGen-' );
134  if ( file_put_contents( $tmpFile, $conf ) === false ) {
135  $this->error( "Could not write doxygen configuration to file $tmpFile\n", 1 );
137  }
138 
139  $command = $this->doxygen . ' ' . $tmpFile;
140  $this->output( "Executing command:\n$command\n" );
141 
142  $exitcode = 1;
143  system( $command, $exitcode );
144 
145  $this->output( <<<TEXT
146 ---------------------------------------------------
147 Doxygen execution finished.
148 Check above for possible errors.
149 
150 You might want to delete the temporary file:
151  $tmpFile
152 ---------------------------------------------------
153 
154 TEXT
155  );
156 
157  if ( $exitcode !== 0 ) {
158  $this->error( "Something went wrong (exit: $exitcode)\n",
159  $exitcode );
160  }
161 
162  }
163 
164 }
165 
166 $maintClass = 'MWDocGen';
167 require_once RUN_MAINTENANCE_IF_MAIN;
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
MWDocGen\getDbType
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
Definition: mwdocgen.php:70
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
Definition: Maintenance.php:169
system
processing should stop and the error should be shown to the user if you wanted to authenticate users to a custom system(LDAP, another PHP program, whatever)
MWDocGen
Maintenance script that builds doxygen documentation.
Definition: mwdocgen.php:42
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
MWDocGen\init
init()
Definition: mwdocgen.php:74
file
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
Definition: hooks.txt:93
MWDocGen\execute
execute()
Do the actual work.
Definition: mwdocgen.php:106
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
MWDocGen\__construct
__construct()
Prepare Maintenance class.
Definition: mwdocgen.php:47
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
$exclude
if(! $in) $exclude
Definition: UtfNormalGenerate.php:65
errors
if the prop value should be in the metadata multi language array can modify can modify indexed by page_id indexed by prefixed DB keys can modify can modify can modify this should be populated with an alert message to that effect to be fed to an HTMLForm object and populate $result with the reason in the form of error messages should be plain text with no special etc to show that they re errors
Definition: hooks.txt:1318
$command
$command
Definition: cdb.php:63
wfShellWikiCmd
wfShellWikiCmd( $script, array $parameters=array(), array $options=array())
Generate a shell-escaped command line string to run a MediaWiki cli script.
Definition: GlobalFunctions.php:3071
Maintenance\DB_NONE
const DB_NONE
Constants for DB access type.
Definition: Maintenance.php:57
wfTempDir
wfTempDir()
Tries to get the system directory for temporary files.
Definition: GlobalFunctions.php:2564
Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition: Maintenance.php:191
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:333
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
Maintenance\hasOption
hasOption( $name)
Checks to see if a particular param exists.
Definition: Maintenance.php:181
$IP
$IP
Definition: WebStart.php:88
$maintClass
$maintClass
Definition: mwdocgen.php:157