diff --git a/src/Console/GenerateDocsCommand.php b/src/Console/GenerateDocsCommand.php index 2af91c5..7807826 100644 --- a/src/Console/GenerateDocsCommand.php +++ b/src/Console/GenerateDocsCommand.php @@ -3,6 +3,7 @@ namespace L5Swagger\Console; use Illuminate\Console\Command; +use L5Swagger\ConfigFactory; use L5Swagger\Exceptions\L5SwaggerException; use L5Swagger\GeneratorFactory; @@ -31,11 +32,12 @@ public function __construct() * Execute the console command. * * @param GeneratorFactory $generatorFactory + * @param ConfigFactory $configFactory * @return void * * @throws L5SwaggerException */ - public function handle(GeneratorFactory $generatorFactory) + public function handle(GeneratorFactory $generatorFactory, ConfigFactory $configFactory) { $all = $this->option('all'); @@ -43,7 +45,7 @@ public function handle(GeneratorFactory $generatorFactory) $documentations = array_keys(config('l5-swagger.documentations', [])); foreach ($documentations as $documentation) { - $this->generateDocumentation($generatorFactory, $documentation); + $this->generateDocumentation($generatorFactory, $documentation, $configFactory); } return; @@ -55,19 +57,31 @@ public function handle(GeneratorFactory $generatorFactory) $documentation = config('l5-swagger.default'); } - $this->generateDocumentation($generatorFactory, $documentation); + $this->generateDocumentation($generatorFactory, $documentation, $configFactory); } /** * @param GeneratorFactory $generatorFactory * @param string $documentation + * @param ConfigFactory $configFactory * * @throws L5SwaggerException */ - private function generateDocumentation(GeneratorFactory $generatorFactory, string $documentation) - { + private function generateDocumentation( + GeneratorFactory $generatorFactory, + string $documentation, + ConfigFactory $configFactory + ) { $this->info('Regenerating docs '.$documentation); + $config = $configFactory->documentationConfig($documentation); + + if (! $config['generate_always']) { + $this->info('Config generate_always false - skipping doc generation'); + + return; + } + $generator = $generatorFactory->make($documentation); $generator->generateDocs(); }