-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Theme: split classes and exceptions in namespace summary (#919)
- Loading branch information
1 parent
479b9ea
commit 24d3745
Showing
19 changed files
with
307 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,17 @@ | ||
{layout '@layout.latte'} | ||
|
||
{block title}{$pageTitle}{/block} | ||
|
||
{block content} | ||
<h1>{$pageTitle}</h1> | ||
|
||
<table class="summary table table-bordered table-responsive table-striped"> | ||
{foreach $exceptions as $exception} | ||
<tr> | ||
<td class="name"> | ||
<a href="{$exception|linkReflection}">{$exception->getName()}</a> | ||
</td> | ||
</tr> | ||
{/foreach} | ||
</table> | ||
{/block} |
This file contains 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 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 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 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 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 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 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,82 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace ApiGen\Generator; | ||
|
||
use ApiGen\Configuration\Configuration; | ||
use ApiGen\Contract\Generator\GeneratorInterface; | ||
use ApiGen\Reflection\Contract\Reflection\Class_\ClassReflectionInterface; | ||
use ApiGen\Reflection\ReflectionStorage; | ||
use ApiGen\SourceCodeHighlighter\SourceCodeHighlighter; | ||
use ApiGen\Templating\TemplateRenderer; | ||
|
||
final class ExceptionGenerator implements GeneratorInterface | ||
{ | ||
/** | ||
* @var ReflectionStorage | ||
*/ | ||
private $reflectionStorage; | ||
|
||
/** | ||
* @var Configuration | ||
*/ | ||
private $configuration; | ||
|
||
/** | ||
* @var SourceCodeHighlighter | ||
*/ | ||
private $sourceCodeHighlighter; | ||
|
||
/** | ||
* @var TemplateRenderer | ||
*/ | ||
private $templateRenderer; | ||
|
||
public function __construct( | ||
ReflectionStorage $reflectionStorage, | ||
Configuration $configuration, | ||
SourceCodeHighlighter $sourceCodeHighlighter, | ||
TemplateRenderer $templateRenderer | ||
) { | ||
$this->reflectionStorage = $reflectionStorage; | ||
$this->configuration = $configuration; | ||
$this->sourceCodeHighlighter = $sourceCodeHighlighter; | ||
$this->templateRenderer = $templateRenderer; | ||
} | ||
|
||
public function generate(): void | ||
{ | ||
foreach ($this->reflectionStorage->getExceptionReflections() as $exceptionReflection) { | ||
$this->generateForException($exceptionReflection); | ||
$this->generateSourceCodeForException($exceptionReflection); | ||
} | ||
} | ||
|
||
private function generateForException(ClassReflectionInterface $exceptionReflection): void | ||
{ | ||
$this->templateRenderer->renderToFile( | ||
$this->configuration->getTemplateByName('class'), | ||
$this->configuration->getDestinationWithPrefixName('exception-', $exceptionReflection->getName()), | ||
[ | ||
'activePage' => 'exception', | ||
'class' => $exceptionReflection, | ||
] | ||
); | ||
} | ||
|
||
private function generateSourceCodeForException(ClassReflectionInterface $exceptionReflection): void | ||
{ | ||
$content = file_get_contents($exceptionReflection->getFileName()); | ||
$highlightedContent = $this->sourceCodeHighlighter->highlightAndAddLineNumbers($content); | ||
|
||
$this->templateRenderer->renderToFile( | ||
$this->configuration->getTemplateByName('source'), | ||
$this->configuration->getDestinationWithPrefixName('source-exception-', $exceptionReflection->getName()), | ||
[ | ||
'activePage' => 'class', | ||
'activeClass' => $exceptionReflection, | ||
'fileName' => $exceptionReflection->getFileName(), | ||
'source' => $highlightedContent | ||
] | ||
); | ||
} | ||
} |
This file contains 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,58 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace ApiGen\Generator; | ||
|
||
use ApiGen\Configuration\Configuration; | ||
use ApiGen\Contract\Generator\GeneratorInterface; | ||
use ApiGen\Reflection\ReflectionStorage; | ||
use ApiGen\Templating\TemplateRenderer; | ||
|
||
final class ExceptionsGenerator implements GeneratorInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private const NAME = 'exceptions'; | ||
|
||
/** | ||
* @var Configuration | ||
*/ | ||
private $configuration; | ||
|
||
/** | ||
* @var TemplateRenderer | ||
*/ | ||
private $templateRenderer; | ||
|
||
/** | ||
* @var ReflectionStorage | ||
*/ | ||
private $reflectionStorage; | ||
|
||
public function __construct( | ||
ReflectionStorage $reflectionStorage, | ||
Configuration $configuration, | ||
TemplateRenderer $templateRenderer | ||
) { | ||
$this->configuration = $configuration; | ||
$this->templateRenderer = $templateRenderer; | ||
$this->reflectionStorage = $reflectionStorage; | ||
} | ||
|
||
public function generate(): void | ||
{ | ||
if (count($this->reflectionStorage->getExceptionReflections()) < 1) { | ||
return; | ||
} | ||
|
||
$this->templateRenderer->renderToFile( | ||
$this->configuration->getTemplateByName(self::NAME), | ||
$this->configuration->getDestinationWithName(self::NAME), | ||
[ | ||
'activePage' => self::NAME, | ||
'pageTitle' => ucfirst(self::NAME), | ||
self::NAME => $this->reflectionStorage->getExceptionReflections() | ||
] | ||
); | ||
} | ||
} |
Oops, something went wrong.