Skip to content

Commit

Permalink
Merge 586e6db into 33bff21
Browse files Browse the repository at this point in the history
  • Loading branch information
abbadon1334 committed Dec 26, 2020
2 parents 33bff21 + 586e6db commit a654c1c
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -18,6 +18,6 @@ script:
- php vendor/bin/phpunit --coverage-clover build/logs/clover.xml

after_script:
- php vendor/bin/codacycoverage clover build/logs/clover.xml
- bash <(curl -Ls https://coverage.codacy.com/get.sh) clover build/logs/clover.xml
- sh -c 'if( [ "$TRAVIS_PHP_VERSION" != "hhvm" ] ); then php vendor/bin/coveralls -v; fi;'
- ./cc-test-reporter after-build --coverage-input-type clover --exit-code $TRAVIS_TEST_RESULT
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -17,7 +17,7 @@ Now working as intended, with good coverage.
This project is heavily based on [phpDocumentor/Reflection](https://github.com/phpDocumentor/Reflection)
and makes use of [sphinxcontrib-phpdomain](https://github.com/markstory/sphinxcontrib-phpdomain).

An example for the documentation output can be found in our [own documentation](http://phpdoc-to-rst.readthedocs.io/en/latest/api_docs.html)
An example for the documentation output can be found in our [own documentation](https://phpdoc-to-rst.readthedocs.io/en/latest/)

## Quickstart

Expand Down
1 change: 0 additions & 1 deletion composer.json
Expand Up @@ -8,7 +8,6 @@
"symfony/console": "^4.0"
},
"require-dev": {
"codacy/coverage": "dev-master",
"phpunit/phpunit": "*"
},
"license": "AGPL-3.0-or-later",
Expand Down
41 changes: 26 additions & 15 deletions src/Builder/NamespaceIndexBuilder.php
Expand Up @@ -74,15 +74,21 @@ private function findChildNamespaces()
/** @var Namespace_ $namespace */
foreach ($this->namespaces as $namespace) {
// check if not root and doesn't start with current namespace
if ($currentNamespaceFqsen !== '\\' && strpos((string) $namespace->getFqsen(),
$currentNamespaceFqsen.'\\') !== 0) {
if ($currentNamespaceFqsen !== '\\' && strpos(
(string) $namespace->getFqsen(),
$currentNamespaceFqsen.'\\'
) !== 0) {
continue;
}
if ((string) $namespace->getFqsen() !== $currentNamespaceFqsen && strpos((string) $namespace->getFqsen(),
$currentNamespaceFqsen) === 0) {
if ((string) $namespace->getFqsen() !== $currentNamespaceFqsen && strpos(
(string) $namespace->getFqsen(),
$currentNamespaceFqsen
) === 0) {
// only keep first level children
$childrenPath = substr((string) $namespace->getFqsen(),
strlen((string) $this->currentNamespace->getFqsen()) + 1);
$childrenPath = substr(
(string) $namespace->getFqsen(),
strlen((string) $this->currentNamespace->getFqsen()) + 1
);
if (strpos($childrenPath, '\\') === false) {
$this->childNamespaces[] = $namespace;
}
Expand Down Expand Up @@ -188,11 +194,11 @@ private function getElementList($type)
private function getHeaderForType($type)
{
$headers = [self::RENDER_INDEX_NAMESPACE => 'Namespaces',
self::RENDER_INDEX_INTERFACES => 'Interfaces',
self::RENDER_INDEX_CLASSES => 'Classes',
self::RENDER_INDEX_TRAITS => 'Traits',
self::RENDER_INDEX_FUNCTIONS => 'Functions',
self::RENDER_INDEX_CONSTANTS => 'Constants',
self::RENDER_INDEX_INTERFACES => 'Interfaces',
self::RENDER_INDEX_CLASSES => 'Classes',
self::RENDER_INDEX_TRAITS => 'Traits',
self::RENDER_INDEX_FUNCTIONS => 'Functions',
self::RENDER_INDEX_CONSTANTS => 'Constants',
];

return $headers[$type];
Expand All @@ -202,8 +208,11 @@ private function addElementTocEntry(Fqsen $entry)
{
$currentNamespaceFqsen = (string) $this->currentNamespace->getFqsen();
$subPath = $entry;
if ($currentNamespaceFqsen !== '\\' && substr($entry, 0,
strlen($currentNamespaceFqsen)) === $currentNamespaceFqsen) {
if ($currentNamespaceFqsen !== '\\' && substr(
$entry,
0,
strlen($currentNamespaceFqsen)
) === $currentNamespaceFqsen) {
$subPath = substr($entry, strlen($currentNamespaceFqsen));
}
$path = substr(str_replace('\\', '/', $subPath), 1);
Expand Down Expand Up @@ -244,8 +253,10 @@ private function addFunctions()
/** @var Param $param */
$param = $params[$argument->getName()];
if ($param !== null) {
$this->addMultiline(':param '.self::escape($param->getType()).' $'.$argument->getName().': '.$param->getDescription(),
true);
$this->addMultiline(
':param '.self::escape($param->getType()).' $'.$argument->getName().': '.$param->getDescription(),
true
);
}
}
}
Expand Down
42 changes: 33 additions & 9 deletions src/GenerateDocumentationCommand.php
Expand Up @@ -39,15 +39,39 @@ class GenerateDocumentationCommand extends Command
{
protected function configure()
{
$this->setName('generate')->setDescription('Generate documentation')->setHelp('This command allows you to generate sphinx/rst based documentation from PHPDoc annotations.')->addArgument('target',
InputArgument::REQUIRED, 'Destination for the generated rst files')->addArgument('src',
InputArgument::IS_ARRAY, 'Source directories to parse')->addOption('public-only', 'p',
InputOption::VALUE_NONE)->addOption('show-private', null,
InputOption::VALUE_NONE)->addOption('element-toc', 't',
InputOption::VALUE_NONE)->addOption('repo-github', null, InputOption::VALUE_REQUIRED,
'Github URL of the projects git repository (requires --repo-base as well)',
false)->addOption('repo-base', null, InputOption::VALUE_REQUIRED,
'Base path of the project git repository', false);
$this->setName('generate')->setDescription('Generate documentation')->setHelp('This command allows you to generate sphinx/rst based documentation from PHPDoc annotations.')->addArgument(
'target',
InputArgument::REQUIRED,
'Destination for the generated rst files'
)->addArgument(
'src',
InputArgument::IS_ARRAY,
'Source directories to parse'
)->addOption(
'public-only',
'p',
InputOption::VALUE_NONE
)->addOption(
'show-private',
null,
InputOption::VALUE_NONE
)->addOption(
'element-toc',
't',
InputOption::VALUE_NONE
)->addOption(
'repo-github',
null,
InputOption::VALUE_REQUIRED,
'Github URL of the projects git repository (requires --repo-base as well)',
false
)->addOption(
'repo-base',
null,
InputOption::VALUE_REQUIRED,
'Base path of the project git repository',
false
);
}

protected function execute(InputInterface $input, OutputInterface $output)
Expand Down
10 changes: 10 additions & 0 deletions tests/DocGenerationTest.php
Expand Up @@ -28,6 +28,8 @@ public function testBuildDocumentation()
'http://github.com/abbadon1334/phpdoc-to-rst/',
]);
$apiDocBuilder->build();

$this->addToAssertionCount(1);
}

public function testDocumentingSelf()
Expand All @@ -40,6 +42,8 @@ public function testDocumentingSelf()
$apiDocBuilder->setDebugOutput(true);
$apiDocBuilder->addExtension(InterfaceImplementors::class);
$apiDocBuilder->build();

$this->addToAssertionCount(1);
}

public function testDocumentingPSR()
Expand All @@ -52,6 +56,8 @@ public function testDocumentingPSR()
$apiDocBuilder->setDebugOutput(true);
$apiDocBuilder->addExtension(InterfaceImplementors::class);
$apiDocBuilder->build();

$this->addToAssertionCount(1);
}

public function testDocumentingDocumentor()
Expand All @@ -64,6 +70,8 @@ public function testDocumentingDocumentor()
$apiDocBuilder->setDebugOutput(true);
$apiDocBuilder->addExtension(InterfaceImplementors::class);
$apiDocBuilder->build();

$this->addToAssertionCount(1);
}

public function testDocumentingWithExtension()
Expand All @@ -84,5 +92,7 @@ public function testDocumentingWithExtension()
'master',
]);
$apiDocBuilder->build();

$this->addToAssertionCount(1);
}
}

0 comments on commit a654c1c

Please sign in to comment.