Skip to content
This repository was archived by the owner on Feb 16, 2019. It is now read-only.
Closed
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor
composer.phar
build
cache
composer.lock
composer.phar
vendor
29 changes: 19 additions & 10 deletions Sami/Console/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Copy link
Contributor

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?

$this->getDefinition()->addOption(new InputOption('only-version', '', InputOption::VALUE_REQUIRED, 'The version to build'));
}

Expand All @@ -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');
Copy link
Contributor

Choose a reason for hiding this comment

The 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));
}
}

Expand Down
4 changes: 2 additions & 2 deletions sami.php → bin/sami
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<?php

// installed via composer?
if (file_exists($a = __DIR__.'/../../autoload.php')) {
if (file_exists($a = __DIR__.'/../../../autoload.php')) {
require_once $a;
} else {
require_once __DIR__.'/vendor/autoload.php';
require_once __DIR__.'/../vendor/autoload.php';
}

use Sami\Console\Application;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
"dev-master": "2.0-dev"
}
},
"bin": ["sami.php"]
"bin": ["bin/sami"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks useful.

}
25 changes: 25 additions & 0 deletions sami.php.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
Copy link
Contributor

Choose a reason for hiding this comment

The 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 ./vendor/bin/sami to generate documentation.


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,
));