From 9cc4c4863cf5451f0966329609f9aadd0f2290fa Mon Sep 17 00:00:00 2001 From: abbadon1334 Date: Thu, 11 Jul 2019 19:04:01 +0300 Subject: [PATCH 1/2] add documentation in read me --- README.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d50f046..1c9dc99 100755 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Forked and refactor by Francesco "Abbadon1334" Danti. Now working as intended, with good coverage. -Generate reStructuredText for Sphinx based documentation from PHPDoc annotations. +##Generate reStructuredText for Sphinx based documentation from PHPDoc annotations. 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). @@ -25,7 +25,65 @@ Install phpdoc-to-rst to your project directory: composer require --dev abbadon1334/phpdoc-to-rst +Command line usage +- Run the command line tool to parse the folders containing your PHP tree and render the reStructuredText files to the output directory: - ./vendor/bin/phpdoc-to-rst docs/api/ src/ + php vendor/bin/phpdoc-to-rst generate --repo-base "$PWD" --repo-github https://github.com/abbadon1334/phpdoc-to-rst -t docs/rst/ src/ + +Programatically usage to generate documentation rst +- +```PHP + + // your source path or multiple path to be parsed + $src = [__DIR__.'/../src']; + + // destination path for the documentation + $dst = __DIR__.'/../docs/api'; + + $apiDocBuilder = new ApiDocBuilder($src, $dst); + + // DEBUG FATURES : optional + // optional : activate verbosity + $apiDocBuilder->setVerboseOutput(true); + // optional : activate debug + $apiDocBuilder->setDebugOutput(true); + + // EXTENSIONS : optional + + /** + * Do not render classes marked with phpDoc internal tag + * Do only render public methods/properties. + */ + $apiDocBuilder->addExtension(PublicOnlyExtension::class); + + /** + * Do not render classes marked with phpDoc internal tag + * Do only render public methods/properties. + */ + $apiDocBuilder->addExtension(NoPrivateExtension::class); + + /** + * This extension will render a list of methods for easy access + * at the beginning of classes, interfaces and traits. + */ + $apiDocBuilder->addExtension(TocExtension::class); + + /** + * This extension adds a link to the source at github to all elements. + * + * Arguments + * 0 => Url to the github repo (required) + * 1 => Path to the git repository (required) + * 2 => Branch to link to (default=master) + */ + $apiDocBuilder->addExtension(GithubLocationExtension::class, [ + __DIR__.'/../src', + 'http://github.com/abbadon1334/phpdoc-to-rst/', + ]); + + // Build documentation + $apiDocBuilder->build(); + +``` From 3ca37e9984306977bd37a778a393b578bff86961 Mon Sep 17 00:00:00 2001 From: Francesco Danti Date: Thu, 11 Jul 2019 16:04:30 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- src/Middleware/ErrorHandlingMiddleware.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Middleware/ErrorHandlingMiddleware.php b/src/Middleware/ErrorHandlingMiddleware.php index 0d926ee..d416875 100755 --- a/src/Middleware/ErrorHandlingMiddleware.php +++ b/src/Middleware/ErrorHandlingMiddleware.php @@ -24,7 +24,6 @@ use JuliusHaertl\PHPDocToRst\ApiDocBuilder; use phpDocumentor\Reflection\Middleware\Command; use phpDocumentor\Reflection\Middleware\Middleware; -use phpDocumentor\Reflection\Php\Factory\File\CreateCommand; /** * Class ErrorHandlingMiddleware. @@ -43,8 +42,8 @@ public function __construct(ApiDocBuilder $apiDocBuilder) /** * Executes this middleware class. * - * @param Command $command - * @param callable $next + * @param Command $command + * @param callable $next * * @return object */