MediaWiki REL1_33
mwdocgen.php
Go to the documentation of this file.
1<?php
37
38require_once __DIR__ . '/Maintenance.php';
39
44class MWDocGen extends Maintenance {
45
49 public function __construct() {
50 parent::__construct();
51 $this->addDescription( 'Build doxygen documentation' );
52
53 $this->addOption( 'doxygen',
54 'Path to doxygen',
55 false, true );
56 $this->addOption( 'version',
57 'Pass a MediaWiki version',
58 false, true );
59 $this->addOption( 'generate-man',
60 'Whether to generate man files' );
61 $this->addOption( 'file',
62 "Only process given file or directory. Multiple values " .
63 "accepted with comma separation. Path relative to \$IP.",
64 false, true );
65 $this->addOption( 'output',
66 'Path to write doc to',
67 false, true );
68 $this->addOption( 'no-extensions',
69 'Ignore extensions' );
70 }
71
72 public function getDbType() {
74 }
75
76 protected function init() {
77 global $wgPhpCli, $IP;
78
79 $this->doxygen = $this->getOption( 'doxygen', 'doxygen' );
80 $this->mwVersion = $this->getOption( 'version', 'master' );
81
82 $this->input = '';
83 $inputs = explode( ',', $this->getOption( 'file', '' ) );
84 foreach ( $inputs as $input ) {
85 # Doxygen inputs are space separted and double quoted
86 $this->input .= " \"$IP/$input\"";
87 }
88
89 $this->output = $this->getOption( 'output', "$IP/docs" );
90
91 // Do not use wfShellWikiCmd, because mwdoc-filter.php is not
92 // a Maintenance script.
93 $this->inputFilter = Shell::escape( [
95 $IP . '/maintenance/mwdoc-filter.php'
96 ] );
97
98 $this->template = $IP . '/maintenance/Doxyfile';
99 $this->excludes = [
100 'vendor',
101 'node_modules',
102 'images',
103 'static',
104 ];
105 $this->excludePatterns = [];
106 if ( $this->hasOption( 'no-extensions' ) ) {
107 $this->excludePatterns[] = 'extensions';
108 }
109
110 $this->doDot = shell_exec( 'which dot' );
111 $this->doMan = $this->hasOption( 'generate-man' );
112 }
113
114 public function execute() {
115 global $IP;
116
117 $this->init();
118
119 # Build out directories we want to exclude
120 $exclude = '';
121 foreach ( $this->excludes as $item ) {
122 $exclude .= " $IP/$item";
123 }
124
125 $excludePatterns = implode( ' ', $this->excludePatterns );
126
127 $conf = strtr( file_get_contents( $this->template ),
128 [
129 '{{OUTPUT_DIRECTORY}}' => $this->output,
130 '{{STRIP_FROM_PATH}}' => $IP,
131 '{{CURRENT_VERSION}}' => $this->mwVersion,
132 '{{INPUT}}' => $this->input,
133 '{{EXCLUDE}}' => $exclude,
134 '{{EXCLUDE_PATTERNS}}' => $excludePatterns,
135 '{{HAVE_DOT}}' => $this->doDot ? 'YES' : 'NO',
136 '{{GENERATE_MAN}}' => $this->doMan ? 'YES' : 'NO',
137 '{{INPUT_FILTER}}' => $this->inputFilter,
138 ]
139 );
140
141 $tmpFile = tempnam( wfTempDir(), 'MWDocGen-' );
142 if ( file_put_contents( $tmpFile, $conf ) === false ) {
143 $this->fatalError( "Could not write doxygen configuration to file $tmpFile\n" );
144 }
145
146 $command = $this->doxygen . ' ' . $tmpFile;
147 $this->output( "Executing command:\n$command\n" );
148
149 $exitcode = 1;
150 system( $command, $exitcode );
151
152 $this->output( <<<TEXT
153---------------------------------------------------
154Doxygen execution finished.
155Check above for possible errors.
156
157You might want to delete the temporary file:
158 $tmpFile
159---------------------------------------------------
160
161TEXT
162 );
163
164 if ( $exitcode !== 0 ) {
165 $this->fatalError( "Something went wrong (exit: $exitcode)\n", $exitcode );
166 }
167 }
168}
169
170$maintClass = MWDocGen::class;
171require_once RUN_MAINTENANCE_IF_MAIN;
within a display generated by the Derivative if and wherever such third party notices normally appear The contents of the NOTICE file are for informational purposes only and do not modify the License You may add Your own attribution notices within Derivative Works that You alongside or as an addendum to the NOTICE text from the provided that such additional attribution notices cannot be construed as modifying the License You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for or distribution of Your or for any such Derivative Works as a provided Your and distribution of the Work otherwise complies with the conditions stated in this License Submission of Contributions Unless You explicitly state any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this without any additional terms or conditions Notwithstanding the above
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgPhpCli
Executable path of the PHP cli binary.
wfTempDir()
Tries to get the system directory for temporary files.
$IP
Definition WebStart.php:41
$command
Definition cdb.php:65
Maintenance script that builds doxygen documentation.
Definition mwdocgen.php:44
__construct()
Prepare Maintenance class.
Definition mwdocgen.php:49
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
Definition mwdocgen.php:72
execute()
Do the actual work.
Definition mwdocgen.php:114
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 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.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
Executes shell commands.
Definition Shell.php:44
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
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)
the value of this variable comes from LanguageConverter indexed by page_id indexed by prefixed DB keys on which the links will be shown 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[messagename, param1, param2,...] or a MessageSpecifier error messages should be plain text with no special etc to show that they re errors
Definition hooks.txt:1750
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function 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:106
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
require_once RUN_MAINTENANCE_IF_MAIN
$maintClass
Definition mwdocgen.php:170
if(is_array($mode)) switch( $mode) $input