diff --git a/.gitignore b/.gitignore index 68138eb..e2efc87 100755 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,8 @@ composer.phar /composer.lock .DS_Store .php_cs.cache -/build \ No newline at end of file +/build +/tests/documentor-doc/ +/tests/psr-doc/ +/tests/self-doc/ +/.phpunit.result.cache diff --git a/.travis.yml b/.travis.yml index 1a7236f..4b97515 100755 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ before_script: script: - php vendor/bin/phpunit --coverage-clover build/logs/clover.xml -after_script: +after_success: - php vendor/bin/codacycoverage 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 \ No newline at end of file diff --git a/composer.json b/composer.json index b6704e2..5e6e901 100755 --- a/composer.json +++ b/composer.json @@ -65,6 +65,7 @@ "# END BUILD - ALL OK" ], - "test": "vendor\\bin\\phpunit" + "test-win": "vendor\\bin\\phpunit", + "test": "vendor/bin/phpunit" } } diff --git a/src/Builder/NamespaceIndexBuilder.php b/src/Builder/NamespaceIndexBuilder.php index 4ac33d8..e029fee 100755 --- a/src/Builder/NamespaceIndexBuilder.php +++ b/src/Builder/NamespaceIndexBuilder.php @@ -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; } @@ -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]; @@ -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); @@ -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 + ); } } } diff --git a/src/GenerateDocumentationCommand.php b/src/GenerateDocumentationCommand.php index 988a57a..1d27be2 100755 --- a/src/GenerateDocumentationCommand.php +++ b/src/GenerateDocumentationCommand.php @@ -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) diff --git a/tests/DocGenerationTest.php b/tests/DocGenerationTest.php index 5fa92d4..47d4fe2 100755 --- a/tests/DocGenerationTest.php +++ b/tests/DocGenerationTest.php @@ -28,6 +28,8 @@ public function testBuildDocumentation() 'http://github.com/abbadon1334/phpdoc-to-rst/', ]); $apiDocBuilder->build(); + + $this->addToAssertionCount(1); } public function testDocumentingSelf() @@ -40,6 +42,8 @@ public function testDocumentingSelf() $apiDocBuilder->setDebugOutput(true); $apiDocBuilder->addExtension(InterfaceImplementors::class); $apiDocBuilder->build(); + + $this->addToAssertionCount(1); } public function testDocumentingPSR() @@ -52,6 +56,8 @@ public function testDocumentingPSR() $apiDocBuilder->setDebugOutput(true); $apiDocBuilder->addExtension(InterfaceImplementors::class); $apiDocBuilder->build(); + + $this->addToAssertionCount(1); } public function testDocumentingDocumentor() @@ -64,6 +70,8 @@ public function testDocumentingDocumentor() $apiDocBuilder->setDebugOutput(true); $apiDocBuilder->addExtension(InterfaceImplementors::class); $apiDocBuilder->build(); + + $this->addToAssertionCount(1); } public function testDocumentingWithExtension() @@ -84,5 +92,7 @@ public function testDocumentingWithExtension() 'master', ]); $apiDocBuilder->build(); + + $this->addToAssertionCount(1); } }