Repository: phpDocumentor/phpDocumentor (language: php)

Issue:
Make usesPackages configurable
# Feature request

It seems like I cannot disable "usePackages"? https://github.com/phpDocumentor/phpDocumentor/blob/master/src/phpDocumentor/Transformer/Writer/Twig.php#L234

However TYPO3 would prefere not to display packages as there is only one package, "Application" and it is not really helpful



Discussion / hints:

Fix patch:
diff --git a/data/xsd/phpdoc.xsd b/data/xsd/phpdoc.xsd
index 1a385c750..8e6125f32 100644
--- a/data/xsd/phpdoc.xsd
+++ b/data/xsd/phpdoc.xsd
@@ -91,6 +91,7 @@
             <xs:element name="examples" type="pd:sourceType" minOccurs="0" maxOccurs="1"/>
         </xs:sequence>
         <xs:attribute name="format" type="xs:string" default="php" />
+        <xs:attribute name="ignore-packages" type="xs:boolean" default="false"/>
     </xs:complexType>
 
     <xs:complexType name="rstGuideType">
diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml
index 08376ea9c..aa627c0de 100644
--- a/phpdoc.dist.xml
+++ b/phpdoc.dist.xml
@@ -11,7 +11,7 @@
     </paths>
     <version number="3.0.0">
         <folder>latest</folder>
-        <api>
+        <api ignore-packages="true">
             <source dsn=".">
                 <path>src</path>
             </source>
diff --git a/src/phpDocumentor/Compiler/ApiDocumentation/Pass/PackageTreeBuilder.php b/src/phpDocumentor/Compiler/ApiDocumentation/Pass/PackageTreeBuilder.php
index c4cb59c4e..c94aceba0 100644
--- a/src/phpDocumentor/Compiler/ApiDocumentation/Pass/PackageTreeBuilder.php
+++ b/src/phpDocumentor/Compiler/ApiDocumentation/Pass/PackageTreeBuilder.php
@@ -56,6 +56,10 @@ public function __construct(private readonly Parser $parser)
 
     protected function process(ApiSetDescriptor $subject): ApiSetDescriptor
     {
+        if ($subject->getSettings()->ignorePackages()) {
+            return $subject;
+        }
+
         $package = $subject->getPackage();
         Assert::isInstanceOf($package, PackageInterface::class);
 
diff --git a/src/phpDocumentor/Configuration/ApiSpecification.php b/src/phpDocumentor/Configuration/ApiSpecification.php
index 4bfb07bad..78d58bd4a 100644
--- a/src/phpDocumentor/Configuration/ApiSpecification.php
+++ b/src/phpDocumentor/Configuration/ApiSpecification.php
@@ -51,6 +51,7 @@ private function __construct(
         private Source|null $examples,
         private string $encoding,
         private bool $validate,
+        private bool $ignorePackages,
     ) {
     }
 
@@ -81,6 +82,7 @@ public static function createFromArray(array $api): self
                 : null,
             $api['encoding'],
             $api['validate'],
+            $api['ignore-packages'],
         );
     }
 
@@ -106,6 +108,7 @@ public static function createDefault(): ApiSpecification
             null,
             'utf8',
             false,
+            false,
         );
     }
 
@@ -126,7 +129,12 @@ public function setIgnore(array $ignore): void
     /** @return string[] */
     public function getIgnoredTags(): array
     {
-        return $this->ignoreTags;
+        $tags =  $this->ignoreTags;
+        if ($this->ignorePackages) {
+            $tags[] = 'package';
+        }
+
+        return $tags;
     }
 
     public function calculateVisiblity(): int
@@ -174,4 +182,9 @@ public function source(): Source
     {
         return $this->source;
     }
+
+    public function ignorePackages(): bool
+    {
+        return $this->ignorePackages;
+    }
 }
diff --git a/src/phpDocumentor/Configuration/Definition/Version3.php b/src/phpDocumentor/Configuration/Definition/Version3.php
index fbce18632..aea548537 100644
--- a/src/phpDocumentor/Configuration/Definition/Version3.php
+++ b/src/phpDocumentor/Configuration/Definition/Version3.php
@@ -45,7 +45,8 @@
  *     examples?: array{dsn: string, paths: array<string>},
  *     include-source: bool,
  *     validate: bool,
- *     visibility: non-empty-array<array-key, string>
+ *     visibility: non-empty-array<array-key, string>,
+ *     ignore-packages: bool
  * }
  * @psalm-type ConfigurationMap = array{
  *     configVersion: string,
@@ -245,6 +246,10 @@ private function apiSection(): ArrayNodeDefinition
                         ->values(['php'])
                         ->defaultValue('php')
                     ->end()
+                    ->booleanNode('ignore-packages')
+                        ->info('Whether to ignore packages in the documentation')
+                        ->defaultFalse()
+                    ->end()
                     ->arrayNode('visibilities')
                         ->prototype('enum')
                             ->info('What is the deepest level of visibility to include in the documentation?')


Test patch:
diff --git a/tests/unit/phpDocumentor/Configuration/Definition/Version3Test.php b/tests/unit/phpDocumentor/Configuration/Definition/Version3Test.php
index c5fbdf219..44b9b5d7a 100644
--- a/tests/unit/phpDocumentor/Configuration/Definition/Version3Test.php
+++ b/tests/unit/phpDocumentor/Configuration/Definition/Version3Test.php
@@ -195,6 +195,7 @@ private static function defaultConfigurationOutput(): array
                             'markers' => ['markers' => ['TODO', 'FIXME']],
                             'ignore-tags' => ['ignore_tags' => []],
                             'output' => '.',
+                            'ignore-packages' => false,
                         ],
                     ],
                     'guides' => [],