docs: Ignore extensions/ and skins/ in mwdocgen.php by default
authorTimo Tijhof <krinklemail@gmail.com>
Sat, 14 Sep 2019 18:31:53 +0000 (19:31 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Sat, 14 Sep 2019 20:58:03 +0000 (21:58 +0100)
The default was previously to index all of core and extensions,
which is likely not the intent of someone running this for the
first time (which can then easily take over half an hour).

Even in CI, we never do this, and we never have afaik.

Generally, local use is to replicate CI (all of core), or a subset
of core by passing e.g. '--file includes/libs' or some such.

Indexing an extension is still possible, same way as before,
by passing '--file extensions/FooBar'. And, if one really wants
to index all of core and all extensions, the new '--extensions'
option allows one to opt back in to the old behaviour.

Also:
* Exclude all of 'resources/'. There are no PHP or Markdown files
  here that need to be indexed.

Bug: T232104
Change-Id: I55617776ac86f3fdcb6c1ba1eebe892edcb5fafb

maintenance/mwdocgen.php

index 3713fdc..6b22097 100644 (file)
@@ -83,8 +83,10 @@ class MWDocGen extends Maintenance {
                $this->addOption( 'output',
                        'Path to write doc to',
                        false, true );
-               $this->addOption( 'no-extensions',
-                       'Ignore extensions' );
+               $this->addOption( 'extensions',
+                       'Process the extensions/ directory as well (ignored if --file is used)' );
+               $this->addOption( 'skins',
+                       'Process the skins/ directory as well (ignored if --file is used)' );
        }
 
        public function getDbType() {
@@ -115,18 +117,23 @@ class MWDocGen extends Maintenance {
 
                $this->template = $IP . '/maintenance/Doxyfile';
                $this->excludes = [
-                       'vendor',
-                       'node_modules',
-                       'resources/lib',
                        'images',
+                       'node_modules',
+                       'resources',
                        'static',
                        'tests',
-                       'resources/src/mediawiki.ui/styleguide.md',
+                       'vendor',
                ];
                $this->excludePatterns = [];
-               if ( $this->hasOption( 'no-extensions' ) ) {
-                       $this->excludePatterns[] = 'extensions';
-                       $this->excludePatterns[] = 'skins';
+               if ( $this->input === '' ) {
+                       // If no explicit --file filter is set, we're indexing all of $IP,
+                       // but any extension or skin submodules should be excluded by default.
+                       if ( !$this->hasOption( 'extensions' ) ) {
+                               $this->excludePatterns[] = 'extensions';
+                       }
+                       if ( !$this->hasOption( 'skins' ) ) {
+                               $this->excludePatterns[] = 'skins';
+                       }
                }
 
                $this->doDot = shell_exec( 'which dot' );