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

drop ignoring @internal #823

Merged
merged 7 commits into from Mar 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
75 changes: 0 additions & 75 deletions CONTRIBUTING.md

This file was deleted.

15 changes: 10 additions & 5 deletions README.md
Expand Up @@ -24,7 +24,7 @@ Run ApiGen with source and destination options:
vendor/bin/apigen generate --source /src --destination /docs
```

To omit cli options just create `apigen.yaml` or `apigen.neon` file in your project's root folder:
To omit cli options just create `apigen.neon` file in your project's root folder:

```yaml
source:
Expand All @@ -41,15 +41,20 @@ vendor/bin/apigen generate --help

*NOTE: In config files, options are camelCased (i.e. `accessLevel` for `--access-level`).*

Refer to the [wiki](https://github.com/ApiGen/ApiGen/wiki/supported-annotations) for all supported annotations.


## Testing

```sh
vendor/bin/phpunit
composer complete-check
```


## Contributing

Please refer to [CONTRIBUTING](https://github.com/apigen/apigen/blob/master/CONTRIBUTING.md) for details.
Rules are simple:

- **new feature needs tests**
- **all tests must pass**
- **1 feature per PR**

We would be happy to merge your feature then.
22 changes: 2 additions & 20 deletions bin/apigen
@@ -1,7 +1,6 @@
#!/usr/bin/env php
<?php

use ApiGen\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand All @@ -10,32 +9,19 @@ require __DIR__ . '/bootstrap.php';

// Create temp dir
$tempDir = sys_get_temp_dir() . '/_apigen';
if (function_exists("posix_getuid")) {
$tempDir .= posix_getuid();
}

$fileSystem = new ApiGen\Utils\FileSystem;
$fileSystem->purgeDir($tempDir);


// Init debugger
Tracy\Debugger::$strictMode = TRUE;
if (isset($_SERVER['argv']) && ($tmp = array_search('--debug', $_SERVER['argv'], TRUE))) {
Tracy\Debugger::enable(Tracy\Debugger::DEVELOPMENT);

} else {
Tracy\Debugger::enable(Tracy\Debugger::PRODUCTION);
Tracy\Debugger::$onFatalError[] = function() use ($fileSystem, $tempDir) {
echo "For more information turn on the debug mode using the --debug option.\n";
$fileSystem->deleteDir($tempDir);
};
}

Tracy\Debugger::enable(Tracy\Debugger::DEVELOPMENT);

$configurator = new Nette\Configurator;
$configurator->setDebugMode( ! Tracy\Debugger::$productionMode);
$configurator->setTempDirectory($tempDir);
$configurator->addConfig(__DIR__ . '/../src/DI/config.neon');
$configurator->addParameters(['rootDir' => __DIR__ . '/..']);
$container = $configurator->createContainer();


Expand All @@ -45,7 +31,3 @@ $application->setAutoExit(false);
$input = $container->getByType(InputInterface::class);
$output = $container->getByType(OutputInterface::class);
$application->run($input, $output);


// Remove temp data
$fileSystem->deleteDir($tempDir);
25 changes: 10 additions & 15 deletions src/Configuration/Configuration.php
Expand Up @@ -65,69 +65,64 @@ public function setOptions(array $options): void

public function getVisibilityLevel(): int
{
return $this->options['visibilityLevels'];
return $this->options[ConfigurationOptions::VISIBILITY_LEVELS];
}

public function getMain(): string
{
return $this->getOption('main');
}

public function isInternalDocumented(): bool
{
return (bool) $this->getOption('internal');
return $this->options[ConfigurationOptions::MAIN];
}

/**
* @return string[]
*/
public function getAnnotationGroups(): array
{
return $this->options['annotationGroups'];
return $this->options[ConfigurationOptions::ANNOTATION_GROUPS];
}

public function getDestination(): string
{
return $this->options['destination'];
return $this->options[ConfigurationOptions::DESTINATION];
}

public function getTitle(): string
{
return $this->options['title'];
return $this->options[ConfigurationOptions::TITLE];
}

public function getBaseUrl(): string
{
return $this->options['baseUrl'];
return $this->options[ConfigurationOptions::BASE_URL];
}

public function getGoogleCseId(): string
{
return $this->options['googleCseId'];
return $this->options[ConfigurationOptions::GOOGLE_CSE_ID];
}

/**
* @return array|string[]
*/
public function getSource(): array
{
return $this->options['source'];
return $this->options[ConfigurationOptions::SOURCE];
}

/**
* @return array|string[]
*/
public function getExclude(): array
{
return $this->options['exclude'];
return $this->options[ConfigurationOptions::EXCLUDE];
}

/**
* @return string[]
*/
public function getExtensions(): array
{
return $this->options['extensions'];
return $this->options[ConfigurationOptions::EXTENSIONS];
}

/**
Expand Down
10 changes: 0 additions & 10 deletions src/Configuration/ConfigurationOptions.php
Expand Up @@ -54,21 +54,11 @@ final class ConfigurationOptions
*/
public const GOOGLE_ANALYTICS = 'googleAnalytics';

/**
* @var string
*/
public const GROUPS = 'groups';

/**
* @var string
*/
public const MAIN = 'main';

/**
* @var string
*/
public const INTERNAL = 'internal';

/**
* @var string
*/
Expand Down
35 changes: 22 additions & 13 deletions src/Configuration/ConfigurationOptionsResolver.php
Expand Up @@ -30,22 +30,24 @@ final class ConfigurationOptionsResolver
* @var mixed[]
*/
private $defaults = [
ConfigurationOptions::ANNOTATION_GROUPS => [],
ConfigurationOptions::ACCESS_LEVELS => ['public'],
ConfigurationOptions::BASE_URL => '',
ConfigurationOptions::CONFIG => '',
// required
ConfigurationOptions::SOURCE => [],
ConfigurationOptions::DESTINATION => null,
ConfigurationOptions::FORCE_OVERWRITE => false,
// file finder
ConfigurationOptions::EXCLUDE => [],
ConfigurationOptions::EXTENSIONS => ['php'],
// template parameters
ConfigurationOptions::TITLE => '',
ConfigurationOptions::GOOGLE_CSE_ID => '',
ConfigurationOptions::GOOGLE_ANALYTICS => '',
// filtering generated content
ConfigurationOptions::ACCESS_LEVELS => [self::AL_PUBLIC],
ConfigurationOptions::ANNOTATION_GROUPS => [],
ConfigurationOptions::BASE_URL => '',
ConfigurationOptions::CONFIG => '',
ConfigurationOptions::FORCE_OVERWRITE => false,
ConfigurationOptions::MAIN => '',
ConfigurationOptions::INTERNAL => false,
ConfigurationOptions::SOURCE => [],
ConfigurationOptions::TEMPLATE => null,
ConfigurationOptions::TEMPLATE_CONFIG => null,
ConfigurationOptions::TITLE => '',
// helpers
ConfigurationOptions::VISIBILITY_LEVELS => [],
];
Expand Down Expand Up @@ -166,8 +168,11 @@ private function setAllowedValues(): void
private function setNormalizers(): void
{
$this->resolver->setNormalizer(ConfigurationOptions::ANNOTATION_GROUPS, function (Options $options, $value) {
$value = (array) $value;
return array_unique($value);
if ($value === '') {
return [];
}

return $value;
});

$this->resolver->setNormalizer(ConfigurationOptions::DESTINATION, function (Options $options, $value) {
Expand Down Expand Up @@ -202,7 +207,9 @@ private function setNormalizers(): void
private function allowedValuesForDestination(?string $destination): bool
{
if (! $destination) {
throw new ConfigurationException("Destination is not set. Use '-d <dir>' or config to set it");
throw new ConfigurationException(
'Destination is not set. Use "--destination <directory>" or config to set it.'
);
} elseif (! is_dir($destination)) {
mkdir($destination, 0755, true);
}
Expand All @@ -224,7 +231,9 @@ private function allowedValuesForDestination(?string $destination): bool
private function allowedValuesForSource($source): bool
{
if (! $source) {
throw new ConfigurationException("Source is not set. Use '-s <dir>' or config to set it");
throw new ConfigurationException(
'Source is not set. Use "--source <directory>" or config to set it.'
);
} elseif (! is_array($source)) {
$source = [$source];
}
Expand Down