This repository was archived by the owner on Feb 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 286
Reading config file from sami.php or sami.php.dist by default #110
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| vendor | ||
| composer.phar | ||
| build | ||
| cache | ||
| composer.lock | ||
| composer.phar | ||
| vendor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,7 +39,7 @@ abstract class Command extends BaseCommand | |
| */ | ||
| protected function configure() | ||
| { | ||
| $this->getDefinition()->addArgument(new InputArgument('config', InputArgument::REQUIRED, 'The configuration')); | ||
| $this->getDefinition()->addOption(new InputOption('config-file', '', InputOption::VALUE_OPTIONAL, 'The path to a sami.php configuration file', null)); | ||
| $this->getDefinition()->addOption(new InputOption('only-version', '', InputOption::VALUE_REQUIRED, 'The version to build')); | ||
| } | ||
|
|
||
|
|
@@ -48,25 +48,34 @@ protected function initialize(InputInterface $input, OutputInterface $output) | |
| $this->input = $input; | ||
| $this->output = $output; | ||
|
|
||
| $config = $input->getArgument('config'); | ||
| $filesystem = new Filesystem(); | ||
|
|
||
| if (!$filesystem->isAbsolutePath($config)) { | ||
| $config = getcwd().'/'.$config; | ||
|
|
||
| $configFile = $input->getOption('config-file'); | ||
| if (null !== $configFile) { | ||
| if (!$filesystem->isAbsolutePath($configFile)) { | ||
| $configFile = realpath($configFile); | ||
| } | ||
| } | ||
|
|
||
| if (!is_file($config)) { | ||
| throw new \InvalidArgumentException(sprintf('Configuration file "%s" does not exist.', $config)); | ||
| else { | ||
| if (file_exists('sami.php')) { | ||
| $configFile = realpath('sami.php'); | ||
| } elseif (file_exists('sami.php.dist')) { | ||
| $configFile = realpath('sami.php.dist'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The generated project documentation isn't like PHPUnit test suite. There is no need to adjust configuration to be able to rebuild documentation locally. |
||
| } | ||
| } | ||
|
|
||
| if (!is_file($configFile)) { | ||
| throw new \InvalidArgumentException(sprintf('Configuration file "%s" does not exist.', $configFile)); | ||
| } | ||
|
|
||
| $this->sami = require $config; | ||
| $this->sami = require $configFile; | ||
|
|
||
| if ($input->getOption('only-version')) { | ||
| $this->sami['versions'] = $input->getOption('only-version'); | ||
| } | ||
|
|
||
| if (!$this->sami instanceof Sami) { | ||
| throw new \RuntimeException(sprintf('Configuration file "%s" must return a Sami instance.', $config)); | ||
| throw new \RuntimeException(sprintf('Configuration file "%s" must return a Sami instance.', $configFile)); | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,5 +32,5 @@ | |
| "dev-master": "2.0-dev" | ||
| } | ||
| }, | ||
| "bin": ["sami.php"] | ||
| "bin": ["bin/sami"] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change looks useful. |
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?php | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file would be inside the PHAR file, so how can it be useful to anybody? I personally set Sami as composer dependency and call |
||
|
|
||
| use Sami\Sami; | ||
| use Sami\Version\GitVersionCollection; | ||
| use Symfony\Component\Finder\Finder; | ||
|
|
||
| $iterator = Finder::create() | ||
| ->files() | ||
| ->name('*.php') | ||
| ->exclude('vendor') | ||
| ->exclude('build') | ||
| ->in($dir = '.'); | ||
|
|
||
| $versions = GitVersionCollection::create($dir) | ||
| ->add('master', 'master branch'); | ||
|
|
||
| return new Sami($iterator, array( | ||
| 'theme' => 'enhanced', | ||
| 'versions' => $versions, | ||
| 'title' => 'Sami API', | ||
| 'build_dir' => __DIR__ . '/build/sami/%version%', | ||
| 'cache_dir' => __DIR__ . '/build/cache/sami/%version%', | ||
| 'include_parent_data' => false, | ||
| 'default_opened_level' => 1, | ||
| )); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You understand that renaming an option is a BC break, yes?