Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent doc generation when generate_always is false #584

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/Console/GenerateDocsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace L5Swagger\Console;

use Illuminate\Console\Command;
use L5Swagger\ConfigFactory;
use L5Swagger\Exceptions\L5SwaggerException;
use L5Swagger\GeneratorFactory;

Expand Down Expand Up @@ -31,19 +32,20 @@ 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');

if ($all) {
$documentations = array_keys(config('l5-swagger.documentations', []));

foreach ($documentations as $documentation) {
$this->generateDocumentation($generatorFactory, $documentation);
$this->generateDocumentation($generatorFactory, $documentation, $configFactory);
}

return;
Expand All @@ -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();
}
Expand Down
Loading