diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 6fe67e7..0a7f737 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,9 @@ -/vendor/ +/vendor .idea/ composer.lock docs/_build +composer.phar +/composer.lock +.DS_Store +.php_cs.cache +/build \ No newline at end of file diff --git a/.readthedocs.yml b/.readthedocs.yml old mode 100644 new mode 100755 diff --git a/.travis.yml b/.travis.yml old mode 100644 new mode 100755 index 202157d..1a7236f --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,23 @@ -dist: trusty -sudo: required language: php + php: - - 7.1 - 7.2 + - 7.3 -install: - - composer install --dev --no-interaction +before_script: + - curl -s http://getcomposer.org/installer | php + - php composer.phar install -n + - composer require satooshi/php-coveralls:~1.0@stable # Require phpCoveralls + - mkdir -p coverage/xml # Create a folder to store clover files #1 + - mkdir -p build/logs # Create a folder to store clover files #2 + - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + - chmod +x ./cc-test-reporter + - ./cc-test-reporter before-build script: - - mkdir build - - cd tests - - phpunit --coverage-clover ../build/clover.xml --configuration phpunit.xml - - cd .. - + - php vendor/bin/phpunit --coverage-clover build/logs/clover.xml after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover build/clover.xml + - 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/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 index 890a7ad..5ceaae3 --- a/Makefile +++ b/Makefile @@ -1,12 +1,11 @@ default: test docs - docs: clean ./bin/phpdoc-to-rst generate --repo-base $(CURDIR) --repo-github https://github.com/juliushaertl/phpdoc-to-rst -t ./docs/api src cd docs && make html test: - phpunit -c tests/phpunit.xml + phpunit -c phpunit.xml clean: rm -fr docs/api/ diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 31f2e0e..374e21a --- a/README.md +++ b/README.md @@ -1,7 +1,17 @@ # phpdoc-to-rst -[![Documentation Status](https://readthedocs.org/projects/phpdoc-to-rst/badge/?version=latest)](http://phpdoc-to-rst.readthedocs.io/en/latest/?badge=latest) [![Build Status](https://scrutinizer-ci.com/g/juliushaertl/phpdoc-to-rst/badges/build.png?b=master)](https://scrutinizer-ci.com/g/juliushaertl/phpdoc-to-rst/build-status/master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/juliushaertl/phpdoc-to-rst/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/juliushaertl/phpdoc-to-rst/?branch=master) +[![Build Status](https://travis-ci.org/abbadon1334/phpdoc-to-rst.svg?branch=master)](https://travis-ci.org/abbadon1334/phpdoc-to-rst) +[![Coverage Status](https://coveralls.io/repos/github/abbadon1334/phpdoc-to-rst/badge.svg?branch=master)](https://coveralls.io/github/abbadon1334/phpdoc-to-rst?branch=master) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/4b4264eb36ca49ed81d29f5102a64a39)](https://www.codacy.com/app/abbadon1334/phpdoc-to-rst?utm_source=github.com&utm_medium=referral&utm_content=abbadon1334/phpdoc-to-rst&utm_campaign=Badge_Grade) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/abbadon1334/phpdoc-to-rst/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/abbadon1334/phpdoc-to-rst/?branch=master) +[![Code Coverage](https://scrutinizer-ci.com/g/abbadon1334/phpdoc-to-rst/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/abbadon1334/phpdoc-to-rst/?branch=master) +[![Build Status](https://scrutinizer-ci.com/g/abbadon1334/phpdoc-to-rst/badges/build.png?b=master)](https://scrutinizer-ci.com/g/abbadon1334/phpdoc-to-rst/build-status/master) +[![Code Intelligence Status](https://scrutinizer-ci.com/g/abbadon1334/phpdoc-to-rst/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence) + +Forked and refactor by Francesco "Abbadon1334" Danti. + +Now working as intended, with good coverage. Generate reStructuredText for Sphinx based documentation from PHPDoc annotations. diff --git a/bin/phpdoc-to-rst b/bin/phpdoc-to-rst index 44c9d41..56ea92e 100755 --- a/bin/phpdoc-to-rst +++ b/bin/phpdoc-to-rst @@ -1,31 +1,33 @@ #!/usr/bin/env php - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -require 'vendor/autoload.php'; + +if (!ini_get('date.timezone')) { + ini_set('date.timezone', 'UTC'); +} + +foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) { + if (file_exists($file)) { + define('PHPUNIT_COMPOSER_INSTALL', $file); + break; + } +} + +unset($file); + +if (!defined('PHPUNIT_COMPOSER_INSTALL')) { + fwrite(STDERR, + 'You need to set up the project dependencies using the following commands:' . PHP_EOL . + 'wget http://getcomposer.org/composer.phar' . PHP_EOL . + 'php composer.phar install' . PHP_EOL + ); + die(1); +} + +require PHPUNIT_COMPOSER_INSTALL; + use Symfony\Component\Console\Application; $application = new Application(); -$application->add(new \JuliusHaertl\PHPDocToRst\GenerateDocumentationCommand()); +$application->add(new JuliusHaertl\PHPDocToRst\GenerateDocumentationCommand()); $application->run(); \ No newline at end of file diff --git a/composer.json b/composer.json old mode 100644 new mode 100755 index 7447ad1..9caa5e2 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "symfony/console": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^4.8|^7.0" + "phpunit/phpunit": "*" }, "license": "AGPL-3.0-or-later", "authors": [ @@ -36,10 +36,5 @@ "JuliusHaertl\\PHPDocToRst\\Test\\": "tests/" } }, - "config": { - "bin-dir": "bin/" - }, - "bin": [ - "bin/phpdoc-to-rst" - ] + "bin": ["bin/phpdoc-to-rst"] } diff --git a/docs/Makefile b/docs/Makefile old mode 100644 new mode 100755 diff --git a/docs/_static/style.css b/docs/_static/style.css old mode 100644 new mode 100755 diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html old mode 100644 new mode 100755 diff --git a/docs/api/JuliusHaertl/PHPDocToRst/ApiDocBuilder.rst b/docs/api/JuliusHaertl/PHPDocToRst/ApiDocBuilder.rst new file mode 100644 index 0000000..db6a13e --- /dev/null +++ b/docs/api/JuliusHaertl/PHPDocToRst/ApiDocBuilder.rst @@ -0,0 +1,238 @@ +.. rst-class:: phpdoctorst + +.. role:: php(code) + :language: php + + +ApiDocBuilder +============= + + +.. php:namespace:: JuliusHaertl\PHPDocToRst + +.. rst-class:: final + +.. php:class:: ApiDocBuilder + + + .. rst-class:: phpdoc-description + + | This class is used to parse a project tree and generate rst files + | for all of the containing PHP structures + + | Example usage is documented in examples/example\.php + + + +Properties +---------- + +.. php:attr:: private static project + + :Type: :any:`\\phpDocumentor\\Reflection\\Php\\Project ` + + +.. php:attr:: private static docFiles + + :Type: array + + +.. php:attr:: private static constants + + :Type: array + + +.. php:attr:: private static functions + + :Type: array + + +.. php:attr:: private static extensions + + :Type: :any:`\\JuliusHaertl\\PHPDocToRst\\Extension\\Extension\[\] ` + + +.. php:attr:: private static extensionNames + + :Type: string[] + + +.. php:attr:: private static extensionArguments + + :Type: array[] + + +.. php:attr:: private static srcDir + + :Type: string[] + + +.. php:attr:: private static dstDir + + :Type: string + + +.. php:attr:: private static verboseOutput + + :Type: bool + + +.. php:attr:: private static debugOutput + + :Type: bool + + +Methods +------- + +.. rst-class:: public + + .. php:method:: public __construct( $srcDir, $dstDir) + + .. rst-class:: phpdoc-description + + | ApiDocBuilder constructor\. + + + + :Parameters: + * **$srcDir** (string[]) array of paths that should be analysed + * **$dstDir** (string) path where the output documentation should be stored + + + + + +.. rst-class:: public + + .. php:method:: public build() + + .. rst-class:: phpdoc-description + + | Run this to build the documentation + + + + + + +.. rst-class:: private + + .. php:method:: private setupReflection() + + + :Throws: :any:`\\Exception ` + + + +.. rst-class:: public + + .. php:method:: public log( $message) + + .. rst-class:: phpdoc-description + + | Log a message + + + + :Parameters: + * **$message** (string) Message to be logged + + + + + +.. rst-class:: private + + .. php:method:: private createDirectoryStructure() + + .. rst-class:: phpdoc-description + + | Create directory structure for the rst output + + + + :Throws: :any:`\\JuliusHaertl\\PHPDocToRst\\WriteException ` + + + +.. rst-class:: private + + .. php:method:: private parseFiles() + + + + + +.. rst-class:: public + + .. php:method:: public debug( $message) + + .. rst-class:: phpdoc-description + + | Log a debug message + + + + :Parameters: + * **$message** (string) Message to be logged + + + + + +.. rst-class:: private + + .. php:method:: private buildIndexes() + + + + + +.. rst-class:: public + + .. php:method:: public setVerboseOutput( $v) + + .. rst-class:: phpdoc-description + + | Enable verbose logging output + + + + :Parameters: + * **$v** (bool) Set to true to enable + + + + + +.. rst-class:: public + + .. php:method:: public setDebugOutput( $v) + + .. rst-class:: phpdoc-description + + | Enable debug logging output + + + + :Parameters: + * **$v** (bool) Set to true to enable + + + + + +.. rst-class:: public + + .. php:method:: public addExtension( $class, $arguments=\[\]) + + + :Parameters: + * **$class** (string) name of the extension class + + + :Throws: :any:`\\Exception ` + + + diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Builder/ClassFileBuilder.rst b/docs/api/JuliusHaertl/PHPDocToRst/Builder/ClassFileBuilder.rst old mode 100644 new mode 100755 index a649303..5f6298f --- a/docs/api/JuliusHaertl/PHPDocToRst/Builder/ClassFileBuilder.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Builder/ClassFileBuilder.rst @@ -13,24 +13,10 @@ ClassFileBuilder .. php:class:: ClassFileBuilder - :Source: - `src/Builder/ClassFileBuilder.php#30 `_ - :Parent: :php:class:`JuliusHaertl\\PHPDocToRst\\Builder\\FileBuilder` - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`protected render\(\)` -* :php:meth:`protected addImplementedInterfaces\($element\)` - - Methods ------- @@ -38,9 +24,6 @@ Methods .. php:method:: protected render() - :Source: - `src/Builder/ClassFileBuilder.php#32 `_ - @@ -49,9 +32,6 @@ Methods .. php:method:: protected addImplementedInterfaces( $element) - :Source: - `src/Builder/ClassFileBuilder.php#60 `_ - :Parameters: * **$element** (:any:`phpDocumentor\\Reflection\\Php\\Class\_ `) diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Builder/ExtensionBuilder.rst b/docs/api/JuliusHaertl/PHPDocToRst/Builder/ExtensionBuilder.rst old mode 100644 new mode 100755 index bfc6715..aaaac11 --- a/docs/api/JuliusHaertl/PHPDocToRst/Builder/ExtensionBuilder.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Builder/ExtensionBuilder.rst @@ -13,18 +13,12 @@ ExtensionBuilder .. php:trait:: ExtensionBuilder - :Source: - `src/Builder/ExtensionBuilder.php#13 `_ - Properties ---------- .. php:attr:: protected static extensions - :Source: - `src/Builder/ExtensionBuilder.php#16 `_ - :Type: :any:`\\JuliusHaertl\\PHPDocToRst\\Extension\\Extension\[\] ` @@ -35,9 +29,6 @@ Methods .. php:method:: public __construct( $extensions) - :Source: - `src/Builder/ExtensionBuilder.php#18 `_ - @@ -46,9 +37,6 @@ Methods .. php:method:: protected callExtensions( $type, $element) - :Source: - `src/Builder/ExtensionBuilder.php#22 `_ - diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Builder/FileBuilder.rst b/docs/api/JuliusHaertl/PHPDocToRst/Builder/FileBuilder.rst old mode 100644 new mode 100755 index 24d0e66..0309937 --- a/docs/api/JuliusHaertl/PHPDocToRst/Builder/FileBuilder.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Builder/FileBuilder.rst @@ -20,74 +20,43 @@ FileBuilder | Abstract building class to build sphinxcontrib\-phpdomain from a php file - :Source: - `src/Builder/FileBuilder.php#35 `_ - :Parent: :php:class:`JuliusHaertl\\PHPDocToRst\\Builder\\PhpDomainBuilder` - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`protected abstract render\(\)` -* :php:meth:`public \_\_construct\($file, $element, $extensions\)` -* :php:meth:`public getElement\(\)` -* :php:meth:`public getFile\(\)` - - Properties ---------- .. php:attr:: protected static file - :Source: - `src/Builder/FileBuilder.php#38 `_ - :Type: :any:`\\phpDocumentor\\Reflection\\Php\\File ` .. php:attr:: protected static element - :Source: - `src/Builder/FileBuilder.php#41 `_ - :Type: :any:`\\phpDocumentor\\Reflection\\Element ` .. php:attr:: protected static extensions - :Source: - `src/Builder/FileBuilder.php#44 `_ - :Type: :any:`\\JuliusHaertl\\PHPDocToRst\\Extension\\Extension\[\] ` Methods ------- -.. rst-class:: protected abstract +.. rst-class:: public - .. php:method:: protected abstract render() + .. php:method:: public __construct( $file, $element, $extensions) - :Source: - `src/Builder/FileBuilder.php#46 `_ - -.. rst-class:: public +.. rst-class:: protected abstract - .. php:method:: public __construct( $file, $element, $extensions) + .. php:method:: protected abstract render() - :Source: - `src/Builder/FileBuilder.php#48 `_ - @@ -96,9 +65,6 @@ Methods .. php:method:: public getElement() - :Source: - `src/Builder/FileBuilder.php#58 `_ - :Returns: :any:`\\phpDocumentor\\Reflection\\Element ` that is used to build the rst file @@ -108,9 +74,6 @@ Methods .. php:method:: public getFile() - :Source: - `src/Builder/FileBuilder.php#65 `_ - :Returns: :any:`\\phpDocumentor\\Reflection\\Php\\File ` diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Builder/InterfaceFileBuilder.rst b/docs/api/JuliusHaertl/PHPDocToRst/Builder/InterfaceFileBuilder.rst old mode 100644 new mode 100755 index 68a59ca..8fda206 --- a/docs/api/JuliusHaertl/PHPDocToRst/Builder/InterfaceFileBuilder.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Builder/InterfaceFileBuilder.rst @@ -13,23 +13,10 @@ InterfaceFileBuilder .. php:class:: InterfaceFileBuilder - :Source: - `src/Builder/InterfaceFileBuilder.php#30 `_ - :Parent: :php:class:`JuliusHaertl\\PHPDocToRst\\Builder\\FileBuilder` - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`protected render\(\)` - - Methods ------- @@ -37,9 +24,6 @@ Methods .. php:method:: protected render() - :Source: - `src/Builder/InterfaceFileBuilder.php#32 `_ - diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Builder/MainIndexBuilder.rst b/docs/api/JuliusHaertl/PHPDocToRst/Builder/MainIndexBuilder.rst old mode 100644 new mode 100755 index 079d0db..06e6760 --- a/docs/api/JuliusHaertl/PHPDocToRst/Builder/MainIndexBuilder.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Builder/MainIndexBuilder.rst @@ -18,26 +18,17 @@ MainIndexBuilder | This class builds a list of all available namespaces in the project\. - :Source: - `src/Builder/MainIndexBuilder.php#35 `_ - :Parent: :php:class:`JuliusHaertl\\PHPDocToRst\\Builder\\RstBuilder` +Properties +---------- -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`public \_\_construct\($namespaces\)` -* :php:meth:`public render\(\)` +.. php:attr:: private static namespaces + :Type: :any:`\\phpDocumentor\\Reflection\\Php\\Namespace\_\[\] ` -Properties ----------- Methods ------- @@ -46,9 +37,6 @@ Methods .. php:method:: public __construct( $namespaces) - :Source: - `src/Builder/MainIndexBuilder.php#40 `_ - @@ -57,9 +45,6 @@ Methods .. php:method:: public render() - :Source: - `src/Builder/MainIndexBuilder.php#44 `_ - diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Builder/NamespaceIndexBuilder.rst b/docs/api/JuliusHaertl/PHPDocToRst/Builder/NamespaceIndexBuilder.rst old mode 100644 new mode 100755 index 227ecb1..639e764 --- a/docs/api/JuliusHaertl/PHPDocToRst/Builder/NamespaceIndexBuilder.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Builder/NamespaceIndexBuilder.rst @@ -20,88 +20,84 @@ NamespaceIndexBuilder | It contains a toc for child namespaces, classes, traits, interfaces and functions - :Source: - `src/Builder/NamespaceIndexBuilder.php#40 `_ - :Parent: :php:class:`JuliusHaertl\\PHPDocToRst\\Builder\\PhpDomainBuilder` - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`public \_\_construct\($extensions, $namespaces, $current, $functions, $constants\)` -* :php:meth:`private findChildNamespaces\(\)` -* :php:meth:`public render\(\)` -* :php:meth:`protected addIndex\($type\)` -* :php:meth:`private addFunctions\(\)` -* :php:meth:`private addElementTocEntry\($entry\)` -* :php:meth:`private shouldRenderIndex\($type, $element\)` -* :php:meth:`private getHeaderForType\($type\)` -* :php:meth:`private getElementList\($type\)` - - Constants --------- .. php:const:: RENDER_INDEX_NAMESPACE = 0 - :Source: - `src/Builder/NamespaceIndexBuilder.php#42 `_ - .. php:const:: RENDER_INDEX_CLASSES = 1 - :Source: - `src/Builder/NamespaceIndexBuilder.php#43 `_ - .. php:const:: RENDER_INDEX_TRAITS = 2 - :Source: - `src/Builder/NamespaceIndexBuilder.php#44 `_ - .. php:const:: RENDER_INDEX_INTERFACES = 3 - :Source: - `src/Builder/NamespaceIndexBuilder.php#45 `_ - .. php:const:: RENDER_INDEX_FUNCTIONS = 4 - :Source: - `src/Builder/NamespaceIndexBuilder.php#46 `_ - .. php:const:: RENDER_INDEX_CONSTANTS = 5 - :Source: - `src/Builder/NamespaceIndexBuilder.php#47 `_ - Properties ---------- +.. php:attr:: private static currentNamespace + + :Type: :any:`\\phpDocumentor\\Reflection\\Php\\Namespace\_ ` + + +.. php:attr:: private static namespaces + + :Type: :any:`\\phpDocumentor\\Reflection\\Php\\Namespace\_\[\] ` + + +.. php:attr:: private static childNamespaces + + :Type: :any:`\\phpDocumentor\\Reflection\\Php\\Namespace\_\[\] ` + + +.. php:attr:: private static functions + + :Type: :any:`\\phpDocumentor\\Reflection\\Php\\Function\_\[\] ` + + +.. php:attr:: private static constants + + :Type: :any:`\\phpDocumentor\\Reflection\\Php\\Constant\[\] ` + + Methods ------- .. rst-class:: public - .. php:method:: public __construct( $extensions, $namespaces, phpDocumentor\\Reflection\\Php\\Namespace\_ $current, $functions, $constants) + .. php:method:: public __construct( $extensions, $namespaces, $current, $functions, $constants) + + + + + +.. rst-class:: private + + .. php:method:: private findChildNamespaces() - :Source: - `src/Builder/NamespaceIndexBuilder.php#64 `_ + .. rst-class:: phpdoc-description + + | Find child namespaces for current namespace + @@ -111,9 +107,6 @@ Methods .. php:method:: public render() - :Source: - `src/Builder/NamespaceIndexBuilder.php#94 `_ - @@ -122,9 +115,51 @@ Methods .. php:method:: protected addIndex( $type) - :Source: - `src/Builder/NamespaceIndexBuilder.php#119 `_ + + + +.. rst-class:: private + + .. php:method:: private shouldRenderIndex( $type, $element=NULL) + + + + + +.. rst-class:: private + + .. php:method:: private getElementList( $type) + + + :Parameters: + * **$type** (int) + + + :Returns: array + + + +.. rst-class:: private + + .. php:method:: private getHeaderForType( $type) + + + + + +.. rst-class:: private + + .. php:method:: private addElementTocEntry( $entry) + + + + + +.. rst-class:: private + + .. php:method:: private addFunctions() + diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Builder/PhpDomainBuilder.rst b/docs/api/JuliusHaertl/PHPDocToRst/Builder/PhpDomainBuilder.rst old mode 100644 new mode 100755 index 7a77164..f3da230 --- a/docs/api/JuliusHaertl/PHPDocToRst/Builder/PhpDomainBuilder.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Builder/PhpDomainBuilder.rst @@ -18,9 +18,6 @@ PhpDomainBuilder | Class to build reStructuredText file with sphinxcontrib\-phpdomain syntax - :Source: - `src/Builder/PhpDomainBuilder.php#49 `_ - :Parent: :php:class:`JuliusHaertl\\PHPDocToRst\\Builder\\RstBuilder` @@ -28,64 +25,23 @@ PhpDomainBuilder :php:trait:`JuliusHaertl\\PHPDocToRst\\Builder\\ExtensionBuilder` - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`public \_\_construct\($extensions\)` -* :php:meth:`public static getNamespace\($element\)` -* :php:meth:`protected addPageHeader\($element\)` -* :php:meth:`private getTypeForClass\($element\)` -* :php:meth:`protected addAfterIntroduction\($element\)` -* :php:meth:`protected addConstants\($constants\)` -* :php:meth:`private addConstant\($constant\)` -* :php:meth:`protected addProperties\($properties\)` -* :php:meth:`private addProperty\($property\)` -* :php:meth:`protected addParent\($element\)` -* :php:meth:`protected addUsedTraits\($element\)` -* :php:meth:`protected addMethods\($methods\)` -* :php:meth:`private addMethod\($method\)` -* :php:meth:`public static getLink\($type, $fqsen, $description\)` -* :php:meth:`public beginPhpDomain\($type, $name, $indent\)` -* :php:meth:`public endPhpDomain\($type\)` -* :php:meth:`public addDocBlockDescription\($element\)` -* :php:meth:`protected addDocblockTag\($tagName, $docBlock\)` -* :php:meth:`public static typesToRst\($typesString\)` -* :php:meth:`public shouldRenderElement\($element\)` - - Constants --------- .. php:const:: SECTION_BEFORE_DESCRIPTION = self::class \. ::SECTION\_BEFORE\_DESCRIPTION - :Source: - `src/Builder/PhpDomainBuilder.php#51 `_ - .. php:const:: SECTION_AFTER_DESCRIPTION = self::class \. ::SECTION\_AFTER\_DESCRIPTION - :Source: - `src/Builder/PhpDomainBuilder.php#52 `_ - .. php:const:: SECTION_AFTER_TITLE = self::class \. ::SECTION\_AFTER\_TITLE - :Source: - `src/Builder/PhpDomainBuilder.php#53 `_ - .. php:const:: SECTION_AFTER_INTRODUCTION = self::class \. ::SECTION\_AFTER\_INTRODUCTION - :Source: - `src/Builder/PhpDomainBuilder.php#54 `_ - Methods @@ -95,131 +51,129 @@ Methods .. php:method:: public __construct( $extensions) - :Source: - `src/Builder/PhpDomainBuilder.php#60 `_ - -.. rst-class:: public static +.. rst-class:: protected - .. php:method:: public static getNamespace(phpDocumentor\\Reflection\\Element $element) + .. php:method:: protected addPageHeader( $element) .. rst-class:: phpdoc-description - | Strip element name from Fqsen to return the namespace only + | Add namespace - :Source: - `src/Builder/PhpDomainBuilder.php#72 `_ - :Parameters: * **$element** (:any:`phpDocumentor\\Reflection\\Element `) - :Returns: mixed -.. rst-class:: protected +.. rst-class:: public static - .. php:method:: protected addPageHeader(phpDocumentor\\Reflection\\Element $element) + .. php:method:: public static getNamespace( $element) .. rst-class:: phpdoc-description - | Add namespace + | Strip element name from Fqsen to return the namespace only - :Source: - `src/Builder/PhpDomainBuilder.php#81 `_ - :Parameters: * **$element** (:any:`phpDocumentor\\Reflection\\Element `) + :Returns: mixed -.. rst-class:: protected +.. rst-class:: public - .. php:method:: protected addAfterIntroduction( $element) + .. php:method:: public beginPhpDomain( $type, $name, $indent=true) - :Source: - `src/Builder/PhpDomainBuilder.php#118 `_ + :Parameters: + * **$type** string + * **$name** string + * **$indent** bool Should indent after the section started + -.. rst-class:: protected +.. rst-class:: private - .. php:method:: protected addConstants( $constants) + .. php:method:: private getTypeForClass( $element) - :Source: - `src/Builder/PhpDomainBuilder.php#123 `_ + + + +.. rst-class:: protected + + .. php:method:: protected addAfterIntroduction( $element) + .. rst-class:: protected - .. php:method:: protected addProperties( $properties) + .. php:method:: protected addConstants( $constants) - :Source: - `src/Builder/PhpDomainBuilder.php#152 `_ + + + +.. rst-class:: public + + .. php:method:: public shouldRenderElement( $element) + :Parameters: - * **$properties** (:any:`phpDocumentor\\Reflection\\Php\\Property\[\] `) + * **$element** (:any:`phpDocumentor\\Reflection\\Element `) + :Returns: bool -.. rst-class:: protected +.. rst-class:: private - .. php:method:: protected addParent( $element) + .. php:method:: private addConstant( $constant) - :Source: - `src/Builder/PhpDomainBuilder.php#182 `_ - :Parameters: - * **$element** (:any:`phpDocumentor\\Reflection\\Php\\Interface\_ ` | :any:`\\phpDocumentor\\Reflection\\Php\\Class\_ `) + * **$constant** (:any:`phpDocumentor\\Reflection\\Php\\Constant `) -.. rst-class:: protected +.. rst-class:: public - .. php:method:: protected addUsedTraits( $element) + .. php:method:: public addDocBlockDescription( $element) - :Source: - `src/Builder/PhpDomainBuilder.php#200 `_ - :Parameters: - * **$element** (:any:`phpDocumentor\\Reflection\\Php\\Class\_ ` | :any:`\\phpDocumentor\\Reflection\\Php\\Trait\_ `) + * **$element** (:any:`phpDocumentor\\Reflection\\Php\\Class\_ ` | :any:`\\phpDocumentor\\Reflection\\Php\\Interface\_ ` | :any:`\\phpDocumentor\\Reflection\\Php\\Trait\_ ` | :any:`\\phpDocumentor\\Reflection\\Php\\Property ` | :any:`\\phpDocumentor\\Reflection\\Php\\Method ` | :any:`\\phpDocumentor\\Reflection\\Php\\Constant `) + :Returns: $this .. rst-class:: protected - .. php:method:: protected addMethods( $methods) + .. php:method:: protected addDocblockTag( $tagName, $docBlock) - :Source: - `src/Builder/PhpDomainBuilder.php#213 `_ - :Parameters: - * **$methods** + * **$tagName** (string) Name of the tag to parse + * **$docBlock** (:any:`phpDocumentor\\Reflection\\DocBlock `) @@ -227,115 +181,150 @@ Methods .. rst-class:: public static - .. php:method:: public static getLink( $type, $fqsen, $description="") + .. php:method:: public static typesToRst( $typesString) - :Source: - `src/Builder/PhpDomainBuilder.php#309 `_ - :Parameters: - * **$type** string - * **$fqsen** string + * **$typesString** (string) - :Returns: string + :Returns: bool | string .. rst-class:: public - .. php:method:: public beginPhpDomain( $type, $name, $indent=true) + .. php:method:: public endPhpDomain( $type="") - :Source: - `src/Builder/PhpDomainBuilder.php#321 `_ - :Parameters: - * **$type** string - * **$name** string - * **$indent** bool Should indent after the section started + * **$type** (string) + :Returns: $this -.. rst-class:: public +.. rst-class:: protected - .. php:method:: public endPhpDomain( $type="") + .. php:method:: protected addProperties( $properties) - :Source: - `src/Builder/PhpDomainBuilder.php#333 `_ + :Parameters: + * **$properties** (:any:`phpDocumentor\\Reflection\\Php\\Property\[\] `) + + + + + +.. rst-class:: private + + .. php:method:: private addProperty( $property) + :Parameters: - * **$type** (string) + * **$property** (:any:`phpDocumentor\\Reflection\\Php\\Property `) - :Returns: $this -.. rst-class:: public +.. rst-class:: protected - .. php:method:: public addDocBlockDescription( $element) + .. php:method:: protected addParent( $element) - :Source: - `src/Builder/PhpDomainBuilder.php#342 `_ + :Parameters: + * **$element** (:any:`phpDocumentor\\Reflection\\Php\\Interface\_ ` | :any:`\\phpDocumentor\\Reflection\\Php\\Class\_ `) + + + + + +.. rst-class:: public static + + .. php:method:: public static getLink( $type, $fqsen, $description="") + :Parameters: - * **$element** (:any:`phpDocumentor\\Reflection\\Php\\Class\_ ` | :any:`\\phpDocumentor\\Reflection\\Php\\Interface\_ ` | :any:`\\phpDocumentor\\Reflection\\Php\\Trait\_ ` | :any:`\\phpDocumentor\\Reflection\\Php\\Property ` | :any:`\\phpDocumentor\\Reflection\\Php\\Method ` | :any:`\\phpDocumentor\\Reflection\\Php\\Constant `) + * **$type** string + * **$fqsen** string - :Returns: $this + :Returns: string .. rst-class:: protected - .. php:method:: protected addDocblockTag( $tagName, phpDocumentor\\Reflection\\DocBlock $docBlock) + .. php:method:: protected addUsedTraits( $element) - :Source: - `src/Builder/PhpDomainBuilder.php#365 `_ + :Parameters: + * **$element** (:any:`phpDocumentor\\Reflection\\Php\\Class\_ ` | :any:`\\phpDocumentor\\Reflection\\Php\\Trait\_ `) + + + + + +.. rst-class:: protected + + .. php:method:: protected addMethods( $methods) + :Parameters: - * **$tagName** (string) Name of the tag to parse - * **$docBlock** (:any:`phpDocumentor\\Reflection\\DocBlock `) + * **$methods** -.. rst-class:: public static +.. rst-class:: private - .. php:method:: public static typesToRst( $typesString) + .. php:method:: private addMethod( $method) - :Source: - `src/Builder/PhpDomainBuilder.php#425 `_ + + + +.. rst-class:: private + + .. php:method:: private processMethodArgumentDocs( $method, $params) + :Parameters: - * **$typesString** (string) + * **$method** (:any:`phpDocumentor\\Reflection\\Php\\Method `) + * **$params** (array) - :Returns: bool | string + :Returns: string -.. rst-class:: public +.. rst-class:: private - .. php:method:: public shouldRenderElement(phpDocumentor\\Reflection\\Element $element) + .. php:method:: private processMethodArgumentTypes( $method) - :Source: - `src/Builder/PhpDomainBuilder.php#451 `_ + :Parameters: + * **$method** (:any:`phpDocumentor\\Reflection\\Php\\Method `) + + + :Returns: string + + + +.. rst-class:: private + + .. php:method:: private processMethodArgumentType( $argument, $args) + :Parameters: - * **$element** (:any:`phpDocumentor\\Reflection\\Element `) + * **$argument** (:any:`phpDocumentor\\Reflection\\Php\\Argument `) + * **$args** (string) - :Returns: bool + :Returns: string diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Builder/RstBuilder.rst b/docs/api/JuliusHaertl/PHPDocToRst/Builder/RstBuilder.rst old mode 100644 new mode 100755 index eeb2984..fb4ac60 --- a/docs/api/JuliusHaertl/PHPDocToRst/Builder/RstBuilder.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Builder/RstBuilder.rst @@ -18,42 +18,19 @@ RstBuilder | Helper class to build reStructuredText files - :Source: - `src/Builder/RstBuilder.php#34 `_ - - - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`public getContent\(\)` -* :php:meth:`public static escape\($text\)` -* :php:meth:`public indent\(\)` -* :php:meth:`public unindent\(\)` -* :php:meth:`public addFieldList\($key, $value\)` -* :php:meth:`public addH1\($text\)` -* :php:meth:`public addH2\($text\)` -* :php:meth:`public addH3\($text\)` -* :php:meth:`public addLine\($text\)` -* :php:meth:`public addMultiline\($text, $blockIndent\)` -* :php:meth:`public addMultilineWithoutRendering\($text\)` -* :php:meth:`public add\($text\)` - Properties ---------- .. php:attr:: protected static content - :Source: - `src/Builder/RstBuilder.php#38 `_ - :Type: string +.. php:attr:: private static indentLevel + + + Methods ------- @@ -61,135 +38,99 @@ Methods .. php:method:: public getContent() - :Source: - `src/Builder/RstBuilder.php#40 `_ - -.. rst-class:: public static +.. rst-class:: public - .. php:method:: public static escape( $text) + .. php:method:: public addFieldList( $key, $value) - :Source: - `src/Builder/RstBuilder.php#44 `_ - .. rst-class:: public - .. php:method:: public indent() + .. php:method:: public addLine( $text="") - :Source: - `src/Builder/RstBuilder.php#50 `_ - .. rst-class:: public - .. php:method:: public unindent() + .. php:method:: public add( $text) - :Source: - `src/Builder/RstBuilder.php#55 `_ - -.. rst-class:: public +.. rst-class:: public static - .. php:method:: public addFieldList( $key, $value) + .. php:method:: public static escape( $text) - :Source: - `src/Builder/RstBuilder.php#61 `_ - .. rst-class:: public - .. php:method:: public addH1(string $text) + .. php:method:: public unindent() - :Source: - `src/Builder/RstBuilder.php#71 `_ - - :Parameters: - * **$text** (string) - - - :Returns: $this .. rst-class:: public - .. php:method:: public addH2( $text) + .. php:method:: public addMultiline( $text="", $blockIndent=false) - :Source: - `src/Builder/RstBuilder.php#77 `_ - .. rst-class:: public - .. php:method:: public addH3( $text) + .. php:method:: public indent() - :Source: - `src/Builder/RstBuilder.php#83 `_ - .. rst-class:: public - .. php:method:: public addLine( $text="") + .. php:method:: public addH1( $text) - :Source: - `src/Builder/RstBuilder.php#89 `_ + :Parameters: + * **$text** (string) + + :Returns: $this .. rst-class:: public - .. php:method:: public addMultiline( $text="", $blockIndent=false) + .. php:method:: public addH2( $text) - :Source: - `src/Builder/RstBuilder.php#94 `_ - .. rst-class:: public - .. php:method:: public addMultilineWithoutRendering( $text) + .. php:method:: public addH3( $text) - :Source: - `src/Builder/RstBuilder.php#109 `_ - .. rst-class:: public - .. php:method:: public add( $text) + .. php:method:: public addMultilineWithoutRendering( $text) - :Source: - `src/Builder/RstBuilder.php#118 `_ - diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Builder/TraitFileBuilder.rst b/docs/api/JuliusHaertl/PHPDocToRst/Builder/TraitFileBuilder.rst old mode 100644 new mode 100755 index 9c43263..f1e5928 --- a/docs/api/JuliusHaertl/PHPDocToRst/Builder/TraitFileBuilder.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Builder/TraitFileBuilder.rst @@ -13,23 +13,10 @@ TraitFileBuilder .. php:class:: TraitFileBuilder - :Source: - `src/Builder/TraitFileBuilder.php#31 `_ - :Parent: :php:class:`JuliusHaertl\\PHPDocToRst\\Builder\\FileBuilder` - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`protected render\(\)` - - Methods ------- @@ -37,9 +24,6 @@ Methods .. php:method:: protected render() - :Source: - `src/Builder/TraitFileBuilder.php#33 `_ - diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Builder/index.rst b/docs/api/JuliusHaertl/PHPDocToRst/Builder/index.rst old mode 100644 new mode 100755 index e0c3806..bdedc9f --- a/docs/api/JuliusHaertl/PHPDocToRst/Builder/index.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Builder/index.rst @@ -18,14 +18,14 @@ Classes .. toctree:: :maxdepth: 1 + InterfaceFileBuilder + NamespaceIndexBuilder + TraitFileBuilder + ClassFileBuilder MainIndexBuilder PhpDomainBuilder RstBuilder FileBuilder - ClassFileBuilder - InterfaceFileBuilder - TraitFileBuilder - NamespaceIndexBuilder Traits diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Extension/AddFullElementNameExtension.rst b/docs/api/JuliusHaertl/PHPDocToRst/Extension/AddFullElementNameExtension.rst old mode 100644 new mode 100755 index 90856fd..7843b97 --- a/docs/api/JuliusHaertl/PHPDocToRst/Extension/AddFullElementNameExtension.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Extension/AddFullElementNameExtension.rst @@ -18,23 +18,10 @@ AddFullElementNameExtension | Add the fully qualified element name including the namespace to each page - :Source: - `src/Extension/AddFullElementNameExtension.php#39 `_ - :Parent: :php:class:`JuliusHaertl\\PHPDocToRst\\Extension\\Extension` - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`public render\($type, $builder, $element\)` - - Methods ------- @@ -42,9 +29,6 @@ Methods .. php:method:: public render( $type, &$builder, $element) - :Source: - `src/Extension/AddFullElementNameExtension.php#45 `_ - :Parameters: * **$type** (string) diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Extension/Extension.rst b/docs/api/JuliusHaertl/PHPDocToRst/Extension/Extension.rst old mode 100644 new mode 100755 index 9490160..749933c --- a/docs/api/JuliusHaertl/PHPDocToRst/Extension/Extension.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Extension/Extension.rst @@ -15,40 +15,17 @@ Extension .. php:class:: Extension - :Source: - `src/Extension/Extension.php#32 `_ - - - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`public \_\_construct\($project, $arguments\)` -* :php:meth:`public prepare\(\)` -* :php:meth:`public render\($type, $builder, $element\)` -* :php:meth:`public shouldRenderElement\($element\)` -* :php:meth:`public shouldRenderIndex\($type, $element\)` - Properties ---------- .. php:attr:: protected static project - :Source: - `src/Extension/Extension.php#35 `_ - :Type: :any:`\\phpDocumentor\\Reflection\\Php\\Project ` .. php:attr:: protected static arguments - :Source: - `src/Extension/Extension.php#38 `_ - :Type: array @@ -57,11 +34,8 @@ Methods .. rst-class:: public - .. php:method:: public __construct(phpDocumentor\\Reflection\\Php\\Project $project, $arguments=\[\]) + .. php:method:: public __construct( $project, $arguments=\[\]) - :Source: - `src/Extension/Extension.php#40 `_ - @@ -77,9 +51,6 @@ Methods | to be used in the output documentation - :Source: - `src/Extension/Extension.php#50 `_ - @@ -100,9 +71,6 @@ Methods | \- PhpDomainBuilder::SECTION\_AFTER\_DESCRIPTION - :Source: - `src/Extension/Extension.php#67 `_ - :Parameters: * **$type** (string) @@ -115,7 +83,7 @@ Methods .. rst-class:: public - .. php:method:: public shouldRenderElement(phpDocumentor\\Reflection\\Element $element) + .. php:method:: public shouldRenderElement( $element) .. rst-class:: phpdoc-description @@ -125,9 +93,6 @@ Methods | An example extension that makes use of it is PublicOnlyExtension - :Source: - `src/Extension/Extension.php#80 `_ - :Parameters: * **$element** (:any:`phpDocumentor\\Reflection\\Element `) @@ -141,9 +106,6 @@ Methods .. php:method:: public shouldRenderIndex( $type, $element) - :Source: - `src/Extension/Extension.php#84 `_ - diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Extension/GithubLocationExtension.rst b/docs/api/JuliusHaertl/PHPDocToRst/Extension/GithubLocationExtension.rst old mode 100644 new mode 100755 index 8575323..7a87cac --- a/docs/api/JuliusHaertl/PHPDocToRst/Extension/GithubLocationExtension.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Extension/GithubLocationExtension.rst @@ -23,47 +23,23 @@ GithubLocationExtension | 2 =\> Branch to link to \(default=master\) - :Source: - `src/Extension/GithubLocationExtension.php#40 `_ - :Parent: :php:class:`JuliusHaertl\\PHPDocToRst\\Extension\\Extension` - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`public prepare\(\)` -* :php:meth:`public render\($type, $builder, $element\)` -* :php:meth:`private getGithubLink\($file, $line, $branch\)` - - Properties ---------- .. php:attr:: protected static basePath - :Source: - `src/Extension/GithubLocationExtension.php#42 `_ - .. php:attr:: protected static githubRepo - :Source: - `src/Extension/GithubLocationExtension.php#43 `_ - .. php:attr:: protected static branch - :Source: - `src/Extension/GithubLocationExtension.php#44 `_ - Methods @@ -73,9 +49,6 @@ Methods .. php:method:: public prepare() - :Source: - `src/Extension/GithubLocationExtension.php#46 `_ - @@ -84,9 +57,6 @@ Methods .. php:method:: public render( $type, &$builder, $element) - :Source: - `src/Extension/GithubLocationExtension.php#62 `_ - :Parameters: * **$type** (string) @@ -97,3 +67,11 @@ Methods +.. rst-class:: private + + .. php:method:: private getGithubLink( $file, $line=1, $branch=master) + + + + + diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Extension/HideChildNamespaces.rst b/docs/api/JuliusHaertl/PHPDocToRst/Extension/HideChildNamespaces.rst old mode 100644 new mode 100755 index db6d42a..c1041be --- a/docs/api/JuliusHaertl/PHPDocToRst/Extension/HideChildNamespaces.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Extension/HideChildNamespaces.rst @@ -18,23 +18,10 @@ HideChildNamespaces | Example for hiding a section in the namespace index page - :Source: - `src/Extension/HideChildNamespaces.php#32 `_ - :Parent: :php:class:`JuliusHaertl\\PHPDocToRst\\Extension\\Extension` - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`public shouldRenderIndex\($type, $element\)` - - Methods ------- @@ -42,9 +29,6 @@ Methods .. php:method:: public shouldRenderIndex( $type, $element) - :Source: - `src/Extension/HideChildNamespaces.php#34 `_ - diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Extension/InterfaceImplementors.rst b/docs/api/JuliusHaertl/PHPDocToRst/Extension/InterfaceImplementors.rst old mode 100644 new mode 100755 index 027b2e4..48f5de3 --- a/docs/api/JuliusHaertl/PHPDocToRst/Extension/InterfaceImplementors.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Extension/InterfaceImplementors.rst @@ -18,26 +18,16 @@ InterfaceImplementors | Class InterfaceImplementors - :Source: - `src/Extension/InterfaceImplementors.php#41 `_ - :Parent: :php:class:`JuliusHaertl\\PHPDocToRst\\Extension\\Extension` +Properties +---------- -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`public prepare\(\)` -* :php:meth:`public render\($type, $builder, $element\)` +.. php:attr:: private static implementors -Properties ----------- Methods ------- @@ -46,9 +36,6 @@ Methods .. php:method:: public prepare() - :Source: - `src/Extension/InterfaceImplementors.php#45 `_ - @@ -57,9 +44,6 @@ Methods .. php:method:: public render( $type, &$builder, $element) - :Source: - `src/Extension/InterfaceImplementors.php#63 `_ - :Parameters: * **$type** (string) diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Extension/NoPrivateExtension.rst b/docs/api/JuliusHaertl/PHPDocToRst/Extension/NoPrivateExtension.rst old mode 100644 new mode 100755 index 97b9075..094df97 --- a/docs/api/JuliusHaertl/PHPDocToRst/Extension/NoPrivateExtension.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Extension/NoPrivateExtension.rst @@ -19,33 +19,17 @@ NoPrivateExtension | Do only render public methods/properties - :Source: - `src/Extension/NoPrivateExtension.php#38 `_ - :Parent: :php:class:`JuliusHaertl\\PHPDocToRst\\Extension\\Extension` - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`public shouldRenderElement\($element\)` - - Methods ------- .. rst-class:: public - .. php:method:: public shouldRenderElement(phpDocumentor\\Reflection\\Element $element) + .. php:method:: public shouldRenderElement( $element) - :Source: - `src/Extension/NoPrivateExtension.php#40 `_ - diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Extension/PublicOnlyExtension.rst b/docs/api/JuliusHaertl/PHPDocToRst/Extension/PublicOnlyExtension.rst old mode 100644 new mode 100755 index 1c2dff0..6b898b7 --- a/docs/api/JuliusHaertl/PHPDocToRst/Extension/PublicOnlyExtension.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Extension/PublicOnlyExtension.rst @@ -19,33 +19,17 @@ PublicOnlyExtension | Do only render public methods/properties - :Source: - `src/Extension/PublicOnlyExtension.php#38 `_ - :Parent: :php:class:`JuliusHaertl\\PHPDocToRst\\Extension\\Extension` - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`public shouldRenderElement\($element\)` - - Methods ------- .. rst-class:: public - .. php:method:: public shouldRenderElement(phpDocumentor\\Reflection\\Element $element) + .. php:method:: public shouldRenderElement( $element) - :Source: - `src/Extension/PublicOnlyExtension.php#40 `_ - diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Extension/TocExtension.rst b/docs/api/JuliusHaertl/PHPDocToRst/Extension/TocExtension.rst old mode 100644 new mode 100755 index 979e30a..358b105 --- a/docs/api/JuliusHaertl/PHPDocToRst/Extension/TocExtension.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Extension/TocExtension.rst @@ -19,23 +19,10 @@ TocExtension | at the beginning of classes, interfaces and traits - :Source: - `src/Extension/TocExtension.php#40 `_ - :Parent: :php:class:`JuliusHaertl\\PHPDocToRst\\Extension\\Extension` - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`public render\($type, $builder, $element\)` - - Methods ------- @@ -43,9 +30,6 @@ Methods .. php:method:: public render( $type, &$builder, $element) - :Source: - `src/Extension/TocExtension.php#46 `_ - :Parameters: * **$type** (string) diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Extension/index.rst b/docs/api/JuliusHaertl/PHPDocToRst/Extension/index.rst old mode 100644 new mode 100755 index 755d27a..f2d5b33 --- a/docs/api/JuliusHaertl/PHPDocToRst/Extension/index.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Extension/index.rst @@ -18,13 +18,13 @@ Classes .. toctree:: :maxdepth: 1 - GithubLocationExtension - AddFullElementNameExtension + Extension TocExtension - NoPrivateExtension - InterfaceImplementors + AddFullElementNameExtension HideChildNamespaces + InterfaceImplementors + NoPrivateExtension + GithubLocationExtension PublicOnlyExtension - Extension diff --git a/docs/api/JuliusHaertl/PHPDocToRst/GenerateDocumentationCommand.rst b/docs/api/JuliusHaertl/PHPDocToRst/GenerateDocumentationCommand.rst old mode 100644 new mode 100755 index d532ee1..f7b8724 --- a/docs/api/JuliusHaertl/PHPDocToRst/GenerateDocumentationCommand.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/GenerateDocumentationCommand.rst @@ -18,24 +18,10 @@ GenerateDocumentationCommand | Class GenerateDocumentationCommand - :Source: - `src/GenerateDocumentationCommand.php#42 `_ - :Parent: :php:class:`Symfony\\Component\\Console\\Command\\Command` - -Summary -------- - -Methods -~~~~~~~ - -* :php:meth:`protected configure\(\)` -* :php:meth:`protected execute\($input, $output\)` - - Methods ------- @@ -43,20 +29,14 @@ Methods .. php:method:: protected configure() - :Source: - `src/GenerateDocumentationCommand.php#44 `_ - .. rst-class:: protected - .. php:method:: protected execute(Symfony\\Component\\Console\\Input\\InputInterface $input, Symfony\\Component\\Console\\Output\\OutputInterface $output) + .. php:method:: protected execute( $input, $output) - :Source: - `src/GenerateDocumentationCommand.php#62 `_ - diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Middleware/ErrorHandlingMiddleware.rst b/docs/api/JuliusHaertl/PHPDocToRst/Middleware/ErrorHandlingMiddleware.rst old mode 100644 new mode 100755 index f8e30b9..5eb1fd9 --- a/docs/api/JuliusHaertl/PHPDocToRst/Middleware/ErrorHandlingMiddleware.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/Middleware/ErrorHandlingMiddleware.rst @@ -4,3 +4,60 @@ :language: php +ErrorHandlingMiddleware +======================= + + +.. php:namespace:: JuliusHaertl\PHPDocToRst\Middleware + +.. rst-class:: final + +.. php:class:: ErrorHandlingMiddleware + + + .. rst-class:: phpdoc-description + + | Class ErrorHandlingMiddleware + + + :Implements: + :php:interface:`phpDocumentor\\Reflection\\Middleware\\Middleware` + + +Properties +---------- + +.. php:attr:: private static apiDocBuilder + + + +Methods +------- + +.. rst-class:: public + + .. php:method:: public __construct( $apiDocBuilder) + + + + + +.. rst-class:: public + + .. php:method:: public execute( $command, $next) + + .. rst-class:: phpdoc-description + + | Executes this middleware class\. + + + + :Parameters: + * **$command** (:any:`phpDocumentor\\Reflection\\Php\\Factory\\File\\CreateCommand `) + * **$next** (callable) + + + :Returns: object + + + diff --git a/docs/api/JuliusHaertl/PHPDocToRst/Middleware/index.rst b/docs/api/JuliusHaertl/PHPDocToRst/Middleware/index.rst old mode 100644 new mode 100755 diff --git a/docs/api/JuliusHaertl/PHPDocToRst/WriteException.rst b/docs/api/JuliusHaertl/PHPDocToRst/WriteException.rst old mode 100644 new mode 100755 index f477dbf..6fa480b --- a/docs/api/JuliusHaertl/PHPDocToRst/WriteException.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/WriteException.rst @@ -18,14 +18,7 @@ WriteException | An exception for writing failure of files/directories in the build process - :Source: - `src/WriteException.php#29 `_ - :Parent: :php:class:`Exception` - -Summary -------- - diff --git a/docs/api/JuliusHaertl/PHPDocToRst/index.rst b/docs/api/JuliusHaertl/PHPDocToRst/index.rst old mode 100644 new mode 100755 index 0fc9a96..316d00d --- a/docs/api/JuliusHaertl/PHPDocToRst/index.rst +++ b/docs/api/JuliusHaertl/PHPDocToRst/index.rst @@ -29,7 +29,8 @@ Classes .. toctree:: :maxdepth: 1 - WriteException GenerateDocumentationCommand + WriteException + ApiDocBuilder diff --git a/docs/api/index-namespaces-all.rst b/docs/api/index-namespaces-all.rst old mode 100644 new mode 100755 diff --git a/docs/api/index.rst b/docs/api/index.rst old mode 100644 new mode 100755 diff --git a/docs/cli.rst b/docs/cli.rst old mode 100644 new mode 100755 diff --git a/docs/conf.py b/docs/conf.py old mode 100644 new mode 100755 diff --git a/docs/extensions.rst b/docs/extensions.rst old mode 100644 new mode 100755 diff --git a/docs/index.rst b/docs/index.rst old mode 100644 new mode 100755 index f00f867..0b22e68 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,7 +1,7 @@ .. phpdoc-to-rst documentation master file, created by - sphinx-quickstart on Sat Oct 7 13:51:26 2017. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. +sphinx-quickstart on Sat Oct 7 13:51:26 2017. +You can adapt this file completely to your liking, but it should at least +contain the root `toctree` directive. Welcome to phpdoc-to-rst's documentation! ========================================= @@ -22,7 +22,7 @@ is used to annotate the PHP objects in the documentation. - + diff --git a/docs/make.bat b/docs/make.bat old mode 100644 new mode 100755 index a6aadd7..2eae0e6 --- a/docs/make.bat +++ b/docs/make.bat @@ -1,36 +1,36 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=python -msphinx -) -set SOURCEDIR=. -set BUILDDIR=_build -set SPHINXPROJ=phpdoc-to-rst - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The Sphinx module was not found. Make sure you have Sphinx installed, - echo.then set the SPHINXBUILD environment variable to point to the full - echo.path of the 'sphinx-build' executable. Alternatively you may add the - echo.Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% - -:end -popd +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=python -msphinx +) +set SOURCEDIR=. +set BUILDDIR=_build +set SPHINXPROJ=phpdoc-to-rst + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The Sphinx module was not found. Make sure you have Sphinx installed, + echo.then set the SPHINXBUILD environment variable to point to the full + echo.path of the 'sphinx-build' executable. Alternatively you may add the + echo.Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/docs/requirements.txt b/docs/requirements.txt old mode 100644 new mode 100755 diff --git a/docs/usage.rst b/docs/usage.rst old mode 100644 new mode 100755 diff --git a/example/test-example.php b/example/test-example.php index 0516683..1fdb7ba 100755 --- a/example/test-example.php +++ b/example/test-example.php @@ -1,9 +1,7 @@ - * * @author Julius Härtl - * * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -18,19 +16,16 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ - -include __DIR__ . '/../vendor/autoload.php'; +include __DIR__.'/../vendor/autoload.php'; use JuliusHaertl\PHPDocToRst\ApiDocBuilder; -$src = [__DIR__ . '/../tests/test-project']; -$dst = __DIR__ . '/../tests/test-project-doc'; +$src = [__DIR__.'/../src']; +$dst = __DIR__.'/../tests/test-project-doc'; $apiDocBuilder = new ApiDocBuilder($src, $dst); $apiDocBuilder->setVerboseOutput(true); $apiDocBuilder->setDebugOutput(true); $apiDocBuilder->addExtension(\JuliusHaertl\PHPDocToRst\Extension\InterfaceImplementors::class); $apiDocBuilder->build(); - diff --git a/phpunit.xml b/phpunit.xml new file mode 100755 index 0000000..d1902bc --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,20 @@ + + + + ./src + + ./demos + ./tests + ./vendor + + + + + + ./tests + + + + + + diff --git a/src/ApiDocBuilder.php b/src/ApiDocBuilder.php old mode 100644 new mode 100755 index 70e123e..86b5eec --- a/src/ApiDocBuilder.php +++ b/src/ApiDocBuilder.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,38 +16,38 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst; +use Exception; +use JuliusHaertl\PHPDocToRst\Builder\ClassFileBuilder; +use JuliusHaertl\PHPDocToRst\Builder\InterfaceFileBuilder; +use JuliusHaertl\PHPDocToRst\Builder\MainIndexBuilder; +use JuliusHaertl\PHPDocToRst\Builder\NamespaceIndexBuilder; use JuliusHaertl\PHPDocToRst\Builder\PhpDomainBuilder; use JuliusHaertl\PHPDocToRst\Builder\TraitFileBuilder; +use JuliusHaertl\PHPDocToRst\Extension\Extension; use JuliusHaertl\PHPDocToRst\Middleware\ErrorHandlingMiddleware; use phpDocumentor\Reflection\DocBlockFactory; use phpDocumentor\Reflection\File\LocalFile; +use phpDocumentor\Reflection\Php\Factory; use phpDocumentor\Reflection\Php\Namespace_; use phpDocumentor\Reflection\Php\NodesFactory; use phpDocumentor\Reflection\Php\Project; use phpDocumentor\Reflection\Php\ProjectFactory; -use phpDocumentor\Reflection\Php\Factory; -use JuliusHaertl\PHPDocToRst\Builder\MainIndexBuilder; -use JuliusHaertl\PHPDocToRst\Builder\NamespaceIndexBuilder; -use JuliusHaertl\PHPDocToRst\Extension\Extension; -use JuliusHaertl\PHPDocToRst\Builder\ClassFileBuilder; -use JuliusHaertl\PHPDocToRst\Builder\InterfaceFileBuilder; use phpDocumentor\Reflection\PrettyPrinter; +use RecursiveDirectoryIterator; +use RecursiveIteratorIterator; /** * This class is used to parse a project tree and generate rst files - * for all of the containing PHP structures + * for all of the containing PHP structures. * * Example usage is documented in examples/example.php - * - * @package JuliusHaertl\PHPDocToRst */ -final class ApiDocBuilder { - +final class ApiDocBuilder +{ /** @var Project */ private $project; @@ -68,7 +66,7 @@ final class ApiDocBuilder { /** @var string[] */ private $extensionNames = []; - /** @var [][] */ + /** @var array[] */ private $extensionArguments = []; /** @var string[] */ @@ -87,17 +85,19 @@ final class ApiDocBuilder { * ApiDocBuilder constructor. * * @param string[] $srcDir array of paths that should be analysed - * @param string $dstDir path where the output documentation should be stored + * @param string $dstDir path where the output documentation should be stored */ - public function __construct($srcDir, $dstDir) { + public function __construct($srcDir, $dstDir) + { $this->dstDir = $dstDir; - $this->srcDir = (array)$srcDir; + $this->srcDir = (array) $srcDir; } /** - * Run this to build the documentation + * Run this to build the documentation. */ - public function build() { + public function build() + { $this->setupReflection(); $this->createDirectoryStructure(); $this->parseFiles(); @@ -107,64 +107,25 @@ public function build() { /* hacky logging for cli */ /** - * Enable verbose logging output - * - * @param bool $v Set to true to enable - */ - public function setVerboseOutput($v) { - $this->verboseOutput = $v; - } - - /** - * Enable debug logging output - * - * @param bool $v Set to true to enable - */ - public function setDebugOutput($v) { - $this->debugOutput = $v; - } - - /** - * Log a message - * - * @param string $message Message to be logged - */ - public function log($message) { - if ($this->verboseOutput) { - echo $message . PHP_EOL; - } - } - - /** - * Log a debug message - * - * @param string $message Message to be logged + * @throws Exception */ - public function debug($message) { - if ($this->debugOutput) { - echo $message . PHP_EOL; - } - } - - /** - * @throws \Exception - */ - private function setupReflection() { - + private function setupReflection() + { $interfaceList = []; $this->log('Start parsing files.'); foreach ($this->srcDir as $srcDir) { - $dir = new \RecursiveDirectoryIterator($srcDir); - $files = new \RecursiveIteratorIterator($dir); + $dir = new RecursiveDirectoryIterator($srcDir); + $files = new RecursiveIteratorIterator($dir); foreach ($files as $file) { if ($file->isDir()) { continue; } + try { $interfaceList[] = new LocalFile($file->getPathname()); - } catch (\Exception $e) { - $this->log('Failed to load ' . $file->getPathname() . PHP_EOL); + } catch (Exception $e) { + $this->log('Failed to load '.$file->getPathname().PHP_EOL); } } } @@ -174,9 +135,8 @@ private function setupReflection() { new Factory\Class_(), new Factory\Constant(new PrettyPrinter()), new Factory\DocBlock(DocBlockFactory::createInstance()), - new Factory\File(NodesFactory::createInstance(), - [ - new ErrorHandlingMiddleware($this) + new Factory\File(NodesFactory::createInstance(), [ + new ErrorHandlingMiddleware($this), ]), new Factory\Function_(), new Factory\Interface_(), @@ -191,89 +151,94 @@ private function setupReflection() { foreach ($this->extensionNames as $extensionName) { $extension = new $extensionName($this->project, $this->extensionArguments[$extensionName]); if (!is_subclass_of($extension, Extension::class)) { - $this->log('Failed to load extension ' . $extensionName . '.'); + $this->log('Failed to load extension '.$extensionName.'.'); } $this->extensions[] = $extension; - $this->log('Extension ' . $extensionName . ' loaded.'); + $this->log('Extension '.$extensionName.' loaded.'); } } /** - * @param string $class name of the extension class - * @throws \Exception + * Log a message. + * + * @param string $message Message to be logged */ - public function addExtension($class, $arguments=[]) { - $this->extensionNames[] = $class; - $this->extensionArguments[$class] = $arguments; - + public function log($message) + { + if ($this->verboseOutput) { + echo $message.PHP_EOL; + } } /** - * Create directory structure for the rst output + * Create directory structure for the rst output. + * * @throws WriteException */ - private function createDirectoryStructure() { + private function createDirectoryStructure() + { foreach ($this->project->getNamespaces() as $namespace) { - $namespaceDir = $this->dstDir . str_replace('\\', '/', $namespace->getFqsen()); + $namespaceDir = $this->dstDir.str_replace('\\', '/', $namespace->getFqsen()); if (is_dir($namespaceDir)) { continue; } if (!mkdir($namespaceDir, 0755, true)) { - throw new WriteException('Could not create directory ' . $namespaceDir); + throw new WriteException('Could not create directory '.$namespaceDir); } } } - private function parseFiles() { + private function parseFiles() + { /** @var Extension $extension */ foreach ($this->extensions as $extension) { $extension->prepare(); } $this->log('Start building files'); foreach ($this->project->getFiles() as $file) { - /** + /* * Go though interfaces/classes/functions of files and build documentation */ foreach ($file->getInterfaces() as $interface) { $fqsen = $interface->getFqsen(); $builder = new InterfaceFileBuilder($file, $interface, $this->extensions); - $filename = $this->dstDir . str_replace('\\', '/', $fqsen) . '.rst'; + $filename = $this->dstDir.str_replace('\\', '/', $fqsen).'.rst'; file_put_contents($filename, $builder->getContent()); - $this->docFiles[(string)$interface->getFqsen()] = str_replace('\\', '/', $fqsen); + $this->docFiles[(string) $interface->getFqsen()] = str_replace('\\', '/', $fqsen); // also build root namespace in indexes - if (strpos((string)substr($fqsen, 1), '\\') === false) { + if (strpos((string) substr($fqsen, 1), '\\') === false) { $this->project->getRootNamespace()->addInterface($fqsen); } - $this->debug('Written interface documentation to ' . $filename); + $this->debug('Written interface documentation to '.$filename); } foreach ($file->getClasses() as $class) { $fqsen = $class->getFqsen(); $builder = new ClassFileBuilder($file, $class, $this->extensions); - $filename = $this->dstDir . str_replace('\\', '/', $fqsen) . '.rst'; + $filename = $this->dstDir.str_replace('\\', '/', $fqsen).'.rst'; file_put_contents($filename, $builder->getContent()); - $this->docFiles[(string)$class->getFqsen()] = str_replace('\\', '/', $fqsen); + $this->docFiles[(string) $class->getFqsen()] = str_replace('\\', '/', $fqsen); // also build root namespace in indexes - if (strpos((string)substr($class->getFqsen(), 1), '\\') === false) { + if (strpos((string) substr($class->getFqsen(), 1), '\\') === false) { $this->project->getRootNamespace()->addClass($fqsen); } - $this->debug('Written class documentation to ' . $filename); + $this->debug('Written class documentation to '.$filename); } foreach ($file->getTraits() as $trait) { $fqsen = $trait->getFqsen(); $builder = new TraitFileBuilder($file, $trait, $this->extensions); - $filename = $this->dstDir . str_replace('\\', '/', $fqsen) . '.rst'; + $filename = $this->dstDir.str_replace('\\', '/', $fqsen).'.rst'; file_put_contents($filename, $builder->getContent()); - $this->docFiles[(string)$trait->getFqsen()] = str_replace('\\', '/', $fqsen); + $this->docFiles[(string) $trait->getFqsen()] = str_replace('\\', '/', $fqsen); // also build root namespace in indexes - if (strpos((string)substr($fqsen, 1), '\\') === false) { + if (strpos((string) substr($fqsen, 1), '\\') === false) { $this->project->getRootNamespace()->addTrait($fqsen); } - $this->debug('Written trait documentation to ' . $filename); + $this->debug('Written trait documentation to '.$filename); } // build array of functions per namespace @@ -294,11 +259,23 @@ private function parseFiles() { } $this->constants[$namespace][] = $constant; } + } + } + /** + * Log a debug message. + * + * @param string $message Message to be logged + */ + public function debug($message) + { + if ($this->debugOutput) { + echo $message.PHP_EOL; } } - private function buildIndexes() { + private function buildIndexes() + { $this->log('Build indexes.'); $namespaces = $this->project->getNamespaces(); $namespaces['\\'] = $this->project->getRootNamespace(); @@ -307,8 +284,8 @@ private function buildIndexes() { }); /** @var Namespace_ $namespace */ foreach ($namespaces as $namespace) { - $fqsen = (string)$namespace->getFqsen(); - $this->debug('Build namespace index for ' . $fqsen); + $fqsen = (string) $namespace->getFqsen(); + $this->debug('Build namespace index for '.$fqsen); $functions = []; $constants = []; if (array_key_exists($fqsen, $this->functions)) { @@ -319,14 +296,45 @@ private function buildIndexes() { } $builder = new NamespaceIndexBuilder($this->extensions, $namespaces, $namespace, $functions, $constants); $builder->render(); - $path = $this->dstDir . str_replace('\\', '/', $fqsen) . '/index.rst'; + $path = $this->dstDir.str_replace('\\', '/', $fqsen).'/index.rst'; file_put_contents($path, $builder->getContent()); } $this->log('Build main index files.'); $builder = new MainIndexBuilder($namespaces); $builder->render(); - $path = $this->dstDir . '/index-namespaces-all.rst'; + $path = $this->dstDir.'/index-namespaces-all.rst'; file_put_contents($path, $builder->getContent()); } + + /** + * Enable verbose logging output. + * + * @param bool $v Set to true to enable + */ + public function setVerboseOutput($v) + { + $this->verboseOutput = $v; + } + + /** + * Enable debug logging output. + * + * @param bool $v Set to true to enable + */ + public function setDebugOutput($v) + { + $this->debugOutput = $v; + } + + /** + * @param string $class name of the extension class + * + * @throws Exception + */ + public function addExtension($class, $arguments = []) + { + $this->extensionNames[] = $class; + $this->extensionArguments[$class] = $arguments; + } } diff --git a/src/Builder/ClassFileBuilder.php b/src/Builder/ClassFileBuilder.php old mode 100644 new mode 100755 index bafaf91..3b3790c --- a/src/Builder/ClassFileBuilder.php +++ b/src/Builder/ClassFileBuilder.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,18 +16,17 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Builder; use phpDocumentor\Reflection\DocBlock\Tags\Param; -use phpDocumentor\Reflection\Php\Argument; use phpDocumentor\Reflection\Php\Class_; -class ClassFileBuilder extends FileBuilder { - - protected function render() { +class ClassFileBuilder extends FileBuilder +{ + protected function render() + { /** @var Class_ $class */ $class = $this->element; @@ -57,14 +54,14 @@ protected function render() { /** * @param Class_ $element */ - protected function addImplementedInterfaces($element) { + protected function addImplementedInterfaces($element) + { $implementedInterfaces = ''; foreach ($element->getInterfaces() as $int) { - $implementedInterfaces .= $this->getLink('interface', $int) . ' '; + $implementedInterfaces .= $this->getLink('interface', $int).' '; } if ($implementedInterfaces !== '') { $this->addFieldList('Implements', $implementedInterfaces); } } - -} \ No newline at end of file +} diff --git a/src/Builder/ExtensionBuilder.php b/src/Builder/ExtensionBuilder.php old mode 100644 new mode 100755 index 75c8baf..9efd9cd --- a/src/Builder/ExtensionBuilder.php +++ b/src/Builder/ExtensionBuilder.php @@ -3,25 +3,27 @@ * Created by PhpStorm. * User: jus * Date: 11.10.17 - * Time: 23:02 + * Time: 23:02. */ namespace JuliusHaertl\PHPDocToRst\Builder; use JuliusHaertl\PHPDocToRst\Extension\Extension; -trait ExtensionBuilder { - +trait ExtensionBuilder +{ /** @var Extension[] */ protected $extensions; - public function __construct($extensions) { + public function __construct($extensions) + { $this->extensions = $extensions; } - protected function callExtensions($type, $element) { + protected function callExtensions($type, $element) + { foreach ($this->extensions as $extension) { $extension->render($type, $this, $element); } } -} \ No newline at end of file +} diff --git a/src/Builder/FileBuilder.php b/src/Builder/FileBuilder.php old mode 100644 new mode 100755 index e2f8455..ae45e3b --- a/src/Builder/FileBuilder.php +++ b/src/Builder/FileBuilder.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,7 +16,6 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Builder; @@ -28,12 +25,10 @@ use phpDocumentor\Reflection\Php\File; /** - * Abstract building class to build sphinxcontrib-phpdomain from a php file - * - * @package JuliusHaertl\PHPDocToRst\Builder + * Abstract building class to build sphinxcontrib-phpdomain from a php file. */ -abstract class FileBuilder extends PhpDomainBuilder { - +abstract class FileBuilder extends PhpDomainBuilder +{ /** @var File */ protected $file; @@ -43,27 +38,29 @@ abstract class FileBuilder extends PhpDomainBuilder { /** @var Extension[] */ protected $extensions = []; - protected abstract function render(); - - public function __construct($file, $element, $extensions) { + public function __construct($file, $element, $extensions) + { parent::__construct($extensions); $this->file = $file; $this->element = $element; $this->render(); } + abstract protected function render(); + /** * @return Element that is used to build the rst file */ - public function getElement() { + public function getElement() + { return $this->element; } /** * @return File */ - public function getFile() { + public function getFile() + { return $this->file; } - -} \ No newline at end of file +} diff --git a/src/Builder/InterfaceFileBuilder.php b/src/Builder/InterfaceFileBuilder.php old mode 100644 new mode 100755 index ebe03a8..3481e95 --- a/src/Builder/InterfaceFileBuilder.php +++ b/src/Builder/InterfaceFileBuilder.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,18 +16,16 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Builder; -use phpDocumentor\Reflection\DocBlock\Tags\Param; use phpDocumentor\Reflection\Php\Interface_; - -class InterfaceFileBuilder extends FileBuilder { - - protected function render() { +class InterfaceFileBuilder extends FileBuilder +{ + protected function render() + { /** @var Interface_ $interface */ $interface = $this->element; @@ -48,5 +44,4 @@ protected function render() { $this->addConstants($interface->getConstants()); $this->addMethods($interface->getMethods()); } - -} \ No newline at end of file +} diff --git a/src/Builder/MainIndexBuilder.php b/src/Builder/MainIndexBuilder.php old mode 100644 new mode 100755 index 71aca38..5385f64 --- a/src/Builder/MainIndexBuilder.php +++ b/src/Builder/MainIndexBuilder.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,30 +16,27 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Builder; - -use phpDocumentor\Reflection\Php\Class_; use phpDocumentor\Reflection\Php\Namespace_; /** * This class builds a list of all available namespaces in the project. - * - * @package JuliusHaertl\PHPDocToRst\Builder */ -class MainIndexBuilder extends RstBuilder { - +class MainIndexBuilder extends RstBuilder +{ /** @var Namespace_[] */ private $namespaces; - public function __construct($namespaces) { + public function __construct($namespaces) + { $this->namespaces = $namespaces; } - public function render() { + public function render() + { $this->addLine('.. _namespaces:')->addLine(); $this->addH1(RstBuilder::escape('Namespaces')); @@ -49,16 +44,15 @@ public function render() { $this->indent(); $this->addLine(':maxdepth: 1')->addLine(); foreach ($this->namespaces as $namespace) { - $namespaceString = (string)$namespace->getFqsen(); + $namespaceString = (string) $namespace->getFqsen(); $subPath = $namespaceString; - $path = substr(str_replace("\\", "/", $subPath), 1) . '/index'; + $path = substr(str_replace('\\', '/', $subPath), 1).'/index'; if ($namespaceString === '\\') { $path = 'index'; } - $this->addLine($namespace->getFqsen() . ' <' . $path . '>'); + $this->addLine($namespace->getFqsen().' <'.$path.'>'); } $this->addLine(); $this->addLine(); - } -} \ No newline at end of file +} diff --git a/src/Builder/NamespaceIndexBuilder.php b/src/Builder/NamespaceIndexBuilder.php old mode 100644 new mode 100755 index b209fc5..4ac33d8 --- a/src/Builder/NamespaceIndexBuilder.php +++ b/src/Builder/NamespaceIndexBuilder.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,27 +16,23 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Builder; - use phpDocumentor\Reflection\DocBlock\Tags\Param; use phpDocumentor\Reflection\Fqsen; -use phpDocumentor\Reflection\Php\Constant; use phpDocumentor\Reflection\Php\Argument; +use phpDocumentor\Reflection\Php\Constant; use phpDocumentor\Reflection\Php\Function_; use phpDocumentor\Reflection\Php\Namespace_; /** * This class will build an index for each namespace. - * It contains a toc for child namespaces, classes, traits, interfaces and functions - * - * @package JuliusHaertl\PHPDocToRst\Builder + * It contains a toc for child namespaces, classes, traits, interfaces and functions. */ -class NamespaceIndexBuilder extends PhpDomainBuilder { - +class NamespaceIndexBuilder extends PhpDomainBuilder +{ const RENDER_INDEX_NAMESPACE = 0; const RENDER_INDEX_CLASSES = 1; const RENDER_INDEX_TRAITS = 2; @@ -61,7 +55,8 @@ class NamespaceIndexBuilder extends PhpDomainBuilder { /** @var Constant[] */ private $constants; - public function __construct($extensions, $namespaces, Namespace_ $current, $functions, $constants) { + public function __construct($extensions, $namespaces, Namespace_ $current, $functions, $constants) + { parent::__construct($extensions); $this->namespaces = $namespaces; $this->currentNamespace = $current; @@ -71,19 +66,23 @@ public function __construct($extensions, $namespaces, Namespace_ $current, $func } /** - * Find child namespaces for current namespace + * Find child namespaces for current namespace. */ - private function findChildNamespaces() { - $currentNamespaceFqsen = (string)$this->currentNamespace->getFqsen(); + private function findChildNamespaces() + { + $currentNamespaceFqsen = (string) $this->currentNamespace->getFqsen(); /** @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; } @@ -91,16 +90,17 @@ private function findChildNamespaces() { } } - public function render() { - $currentNamespaceFqsen = (string)$this->currentNamespace->getFqsen(); + public function render() + { + $currentNamespaceFqsen = (string) $this->currentNamespace->getFqsen(); if ($currentNamespaceFqsen !== '\\') { $label = str_replace('\\', '-', $currentNamespaceFqsen); - $this->addLine('.. _namespace' . $label . ':')->addLine(); + $this->addLine('.. _namespace'.$label.':')->addLine(); $this->addH1(RstBuilder::escape($this->currentNamespace->getName())); $this->addLine(self::escape($currentNamespaceFqsen))->addLine(); } else { $label = 'root-namespace'; - $this->addLine('.. _namespace-' . $label . ':')->addLine(); + $this->addLine('.. _namespace-'.$label.':')->addLine(); $this->addH1(RstBuilder::escape('\\')); } $this->addLine(); @@ -116,7 +116,8 @@ public function render() { $this->addFunctions(); } - protected function addIndex($type) { + protected function addIndex($type) + { if ($this->shouldRenderIndex($type)) { $this->addH2($this->getHeaderForType($type)); $this->addLine('.. toctree::'); @@ -128,7 +129,7 @@ protected function addIndex($type) { continue; } if ($type === self::RENDER_INDEX_NAMESPACE) { - $this->addLine($entry->getName() . ' <' . $entry->getName() . '/index>'); + $this->addLine($entry->getName().' <'.$entry->getName().'/index>'); } else { $this->addElementTocEntry($entry); } @@ -138,80 +139,27 @@ protected function addIndex($type) { } } - private function addFunctions() { - if (!$this->shouldRenderIndex(self::RENDER_INDEX_FUNCTIONS)) { - return; - } - $this->addH2('Functions'); - /** @var Function_ $function */ - foreach ($this->functions as $function) { - if (!$this->shouldRenderIndex(self::RENDER_INDEX_FUNCTIONS, $function)) { - continue; - } - $docBlock = $function->getDocBlock(); - $params = []; - if ($docBlock !== null) { - /** @var Param $param */ - foreach ($docBlock->getTagsByName('param') as $param) { - $params[$param->getVariableName()] = $param; - } - } - $args = ''; - /** @var Argument $argument */ - foreach ($function->getArguments() as $argument) { - // TODO: defaults, types - $args .= '$' . $argument->getName() . ', '; - } - $args = substr($args, 0, -2); - $this->beginPhpDomain('function', $function->getName() . '(' . $args . ')'); - $this->addDocBlockDescription($function); - if (!empty($params)) { - foreach ($function->getArguments() as $argument) { - if (array_key_exists($argument->getName(), $params)) { - /** @var Param $param */ - $param = $params[$argument->getName()]; - if ($param !== null) { - $this->addMultiline(':param ' . self::escape($param->getType()) . ' $' . $argument->getName() . ': ' . $param->getDescription(), true); - } - } - } - } - $this->endPhpDomain('function'); - } - } - - private function addElementTocEntry(Fqsen $entry) { - $currentNamespaceFqsen = (string)$this->currentNamespace->getFqsen(); - $subPath = $entry; - if ($currentNamespaceFqsen !== '\\' && substr($entry, 0, strlen($currentNamespaceFqsen)) === $currentNamespaceFqsen) { - $subPath = substr($entry, strlen($currentNamespaceFqsen)); - } - $path = substr(str_replace('\\', '/', $subPath), 1); - $this->addLine($entry->getName() . ' <' . $path . '>'); - } - - private function shouldRenderIndex($type, $element = null) { + private function shouldRenderIndex($type, $element = null) + { foreach ($this->extensions as $extension) { if (!$extension->shouldRenderIndex($type, $element)) { return false; } } if ($element === null) { - return (count($this->getElementList($type)) > 0); + return count($this->getElementList($type)) > 0; } - return true; - } - 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']; - return $headers[$type]; + return true; } /** * @param int $type + * * @return array */ - private function getElementList($type) { + private function getElementList($type) + { $elements = []; switch ($type) { case self::RENDER_INDEX_NAMESPACE: @@ -233,7 +181,76 @@ private function getElementList($type) { $elements = $this->constants; break; } + return $elements; } -} \ No newline at end of file + 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', + ]; + + return $headers[$type]; + } + + private function addElementTocEntry(Fqsen $entry) + { + $currentNamespaceFqsen = (string) $this->currentNamespace->getFqsen(); + $subPath = $entry; + if ($currentNamespaceFqsen !== '\\' && substr($entry, 0, + strlen($currentNamespaceFqsen)) === $currentNamespaceFqsen) { + $subPath = substr($entry, strlen($currentNamespaceFqsen)); + } + $path = substr(str_replace('\\', '/', $subPath), 1); + $this->addLine($entry->getName().' <'.$path.'>'); + } + + private function addFunctions() + { + if (!$this->shouldRenderIndex(self::RENDER_INDEX_FUNCTIONS)) { + return; + } + $this->addH2('Functions'); + /** @var Function_ $function */ + foreach ($this->functions as $function) { + if (!$this->shouldRenderIndex(self::RENDER_INDEX_FUNCTIONS, $function)) { + continue; + } + $docBlock = $function->getDocBlock(); + $params = []; + if ($docBlock !== null) { + /** @var Param $param */ + foreach ($docBlock->getTagsByName('param') as $param) { + $params[$param->getVariableName()] = $param; + } + } + $args = ''; + /** @var Argument $argument */ + foreach ($function->getArguments() as $argument) { + // TODO: defaults, types + $args .= '$'.$argument->getName().', '; + } + $args = substr($args, 0, -2); + $this->beginPhpDomain('function', $function->getName().'('.$args.')'); + $this->addDocBlockDescription($function); + if (!empty($params)) { + foreach ($function->getArguments() as $argument) { + if (array_key_exists($argument->getName(), $params)) { + /** @var Param $param */ + $param = $params[$argument->getName()]; + if ($param !== null) { + $this->addMultiline(':param '.self::escape($param->getType()).' $'.$argument->getName().': '.$param->getDescription(), + true); + } + } + } + } + $this->endPhpDomain('function'); + } + } +} diff --git a/src/Builder/PhpDomainBuilder.php b/src/Builder/PhpDomainBuilder.php old mode 100644 new mode 100755 index f091dad..ff550a4 --- a/src/Builder/PhpDomainBuilder.php +++ b/src/Builder/PhpDomainBuilder.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,13 +16,13 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Builder; use JuliusHaertl\PHPDocToRst\Extension\Extension; use phpDocumentor\Reflection\DocBlock; +use phpDocumentor\Reflection\DocBlock\Tags\Deprecated; use phpDocumentor\Reflection\DocBlock\Tags\Param; use phpDocumentor\Reflection\DocBlock\Tags\Return_; use phpDocumentor\Reflection\DocBlock\Tags\See; @@ -38,47 +36,36 @@ use phpDocumentor\Reflection\Php\Interface_; use phpDocumentor\Reflection\Php\Method; use phpDocumentor\Reflection\Php\Property; -use phpDocumentor\Reflection\DocBlock\Tags\Deprecated; use phpDocumentor\Reflection\Php\Trait_; /** - * Class to build reStructuredText file with sphinxcontrib-phpdomain syntax - * - * @package JuliusHaertl\PHPDocToRst\Builder + * Class to build reStructuredText file with sphinxcontrib-phpdomain syntax. */ -class PhpDomainBuilder extends RstBuilder { - - const SECTION_BEFORE_DESCRIPTION = self::class . '::SECTION_BEFORE_DESCRIPTION'; - const SECTION_AFTER_DESCRIPTION = self::class . '::SECTION_AFTER_DESCRIPTION'; - const SECTION_AFTER_TITLE = self::class . '::SECTION_AFTER_TITLE'; - const SECTION_AFTER_INTRODUCTION = self::class . '::SECTION_AFTER_INTRODUCTION'; +class PhpDomainBuilder extends RstBuilder +{ + const SECTION_BEFORE_DESCRIPTION = self::class.'::SECTION_BEFORE_DESCRIPTION'; + const SECTION_AFTER_DESCRIPTION = self::class.'::SECTION_AFTER_DESCRIPTION'; + const SECTION_AFTER_TITLE = self::class.'::SECTION_AFTER_TITLE'; + const SECTION_AFTER_INTRODUCTION = self::class.'::SECTION_AFTER_INTRODUCTION'; use ExtensionBuilder { ExtensionBuilder::__construct as private __extensionConstructor; } - public function __construct($extensions) { + public function __construct($extensions) + { $this->__extensionConstructor($extensions); - $this->addMultiline('.. role:: php(code)' . PHP_EOL . ':language: php', true); + $this->addMultiline('.. role:: php(code)'.PHP_EOL.':language: php', true); $this->addLine(); } /** - * Strip element name from Fqsen to return the namespace only + * Add namespace. * * @param Element $element - * @return mixed - */ - public static function getNamespace(Element $element) { - return substr($element->getFqsen(), 0, strlen($element->getFqsen())-strlen('\\'. $element->getName())); - //return str_replace('\\' . $element->getName(), '', $element->getFqsen()); - } - - /** - * Add namespace - * @param Element $element */ - protected function addPageHeader(Element $element) { + protected function addPageHeader(Element $element) + { $this->addH1(self::escape($element->getName()))->addLine(); if (self::getNamespace($element) !== '') { $this->beginPhpDomain('namespace', substr(self::getNamespace($element), 1), false); @@ -87,18 +74,45 @@ protected function addPageHeader(Element $element) { $modifiers = $element->isAbstract() ? ' abstract' : ''; $modifiers = $element->isFinal() ? ' final' : $modifiers; if ($modifiers !== '') { - $this->addLine('.. rst-class:: ' . $modifiers)->addLine(); + $this->addLine('.. rst-class:: '.$modifiers)->addLine(); } } $this->callExtensions(self::SECTION_AFTER_TITLE, $element); - $this->beginPhpDomain($this->getTypeForClass($element), $element->getName(), false); $this->addLine(); } - private function getTypeForClass($element) { + /** + * Strip element name from Fqsen to return the namespace only. + * + * @param Element $element + * + * @return mixed + */ + public static function getNamespace(Element $element) + { + return substr($element->getFqsen(), 0, strlen($element->getFqsen()) - strlen('\\'.$element->getName())); + //return str_replace('\\' . $element->getName(), '', $element->getFqsen()); + } + + /** + * @param $type string + * @param $name string + * @param $indent bool Should indent after the section started + */ + public function beginPhpDomain($type, $name, $indent = true) + { + // FIXME: Add checks if it is properly ended + $this->addLine('.. php:'.$type.':: '.$name)->addLine(); + if ($indent === true) { + $this->indent(); + } + } + + private function getTypeForClass($element) + { switch (get_class($element)) { case Class_::class: return 'class'; @@ -115,12 +129,13 @@ private function getTypeForClass($element) { } } - protected function addAfterIntroduction($element) { + protected function addAfterIntroduction($element) + { $this->callExtensions(self::SECTION_AFTER_INTRODUCTION, $element); } - - protected function addConstants($constants) { + protected function addConstants($constants) + { if (count($constants) > 0) { $this->addH2('Constants'); foreach ($constants as $constant) { @@ -131,11 +146,29 @@ protected function addConstants($constants) { } } + /** + * @param Element $element + * + * @return bool + */ + public function shouldRenderElement(Element $element) + { + /** @var Extension $extension */ + foreach ($this->extensions as $extension) { + if ($extension->shouldRenderElement($element) === false) { + return false; + } + } + + return true; + } + /** * @param Constant $constant */ - private function addConstant(Constant $constant) { - $this->beginPhpDomain('const', $constant->getName() . ' = ' . self::escape($constant->getValue())); + private function addConstant(Constant $constant) + { + $this->beginPhpDomain('const', $constant->getName().' = '.self::escape($constant->getValue())); $docBlock = $constant->getDocBlock(); $this->addDocBlockDescription($constant); if ($docBlock) { @@ -146,10 +179,166 @@ private function addConstant(Constant $constant) { $this->endPhpDomain(); } + /** + * @param Class_|Interface_|Trait_|Property|Method|Constant $element + * + * @return $this + */ + public function addDocBlockDescription($element) + { + if ($element === null) { + return $this; + } + $docBlock = $element->getDocBlock(); + $this->callExtensions(self::SECTION_BEFORE_DESCRIPTION, $element); + if ($docBlock !== null && $docBlock->getSummary() !== '') { + $this->addLine('.. rst-class:: phpdoc-description')->addLine(); + $this->indent(); + $this->addMultilineWithoutRendering(RstBuilder::escape($docBlock->getSummary()))->addLine(); + if ((string) $docBlock->getDescription() !== '') { + $this->addMultilineWithoutRendering(RstBuilder::escape($docBlock->getDescription()))->addLine(); + } + $this->unindent(); + } + $this->callExtensions(self::SECTION_AFTER_DESCRIPTION, $element); + + return $this; + } + + /** + * @param string $tagName Name of the tag to parse + * @param DocBlock $docBlock + */ + protected function addDocblockTag($tagName, DocBlock $docBlock) + { + $inclusion_tag_name = [ + 'return', + 'var', + 'throws', + 'since', + 'deprecated', + 'see', + 'license', + ]; + + $tags = $docBlock->getTagsByName($tagName); + + if (!in_array($tagName, $inclusion_tag_name)) { + return ''; + } + + if (in_array($tagName, $inclusion_tag_name) && count($tags) === 0) { + return ''; + } + + switch ($tagName) { + case 'return': + /** @var Return_ $return */ + $return = $tags[0]; + $this->addMultiline(':Returns: '.self::typesToRst($return->getType()).' '.RstBuilder::escape($return->getDescription()), + true); + break; + case 'var': + /** @var DocBlock\Tags\Var_ $return */ + $return = $tags[0]; + $this->addMultiline(':Type: '.self::typesToRst($return->getType()).' '.RstBuilder::escape($return->getDescription()), + true); + break; + case 'throws': + /** @var Throws $tag */ + foreach ($tags as $tag) { + $this->addMultiline(':Throws: '.self::typesToRst($tag->getType()).' '.RstBuilder::escape($tag->getDescription()), + true); + } + break; + case 'since': + /** @var Since $return */ + $return = $tags[0]; + $this->addMultiline(':Since: '.$return->getVersion().' '.RstBuilder::escape($return->getDescription()), + true); + break; + case 'deprecated': + /** @var Deprecated $return */ + $return = $tags[0]; + $this->addMultiline(':Deprecated: '.$return->getVersion().' '.RstBuilder::escape($return->getDescription()), + true); + break; + case 'see': + /** @var See $return */ + $return = $tags[0]; + $this->addMultiline(':See: '.self::typesToRst($return->getReference()).' '.RstBuilder::escape($return->getDescription()), + true); + break; + case 'license': + /** @var DocBlock\Tags\BaseTag $return */ + $return = $tags[0]; + $this->addMultiline(':License: '.RstBuilder::escape($return->getDescription()), true); + break; + } + } + + /** + * @param string $typesString + * + * @return bool|string + */ + public static function typesToRst($typesString) + { + // http://docs.phpdoc.org/guides/types.html + $whitelist = [ + 'string', + 'int', + 'integer', + 'float', + 'bool', + 'boolean', + 'array', + 'resource', + 'null', + 'callable', + 'mixed', + 'void', + 'object', + 'false', + 'true', + 'self', + 'static', + '$this', + ]; + $types = explode('|', $typesString); + $result = ''; + /* @var string $type */ + foreach ($types as $typeFull) { + $type = str_replace('[]', '', $typeFull); + if (in_array($type, $whitelist, true)) { + $result .= $typeFull.' | '; + continue; + } + if (0 === strpos($type, '\\')) { + $type = substr($type, 1); + } + $result .= ':any:`'.RstBuilder::escape($typeFull).' <'.RstBuilder::escape($type).'>` | '; + } + + return substr($result, 0, -3); + } + + /** + * @param string $type + * + * @return $this + */ + public function endPhpDomain($type = '') + { + $this->unindent(); + $this->addLine(); + } + /** * @param Property[] $properties */ - protected function addProperties($properties) { + protected function addProperties($properties) + { if (count($properties) > 0) { $this->addH2('Properties'); foreach ($properties as $property) { @@ -163,9 +352,10 @@ protected function addProperties($properties) { /** * @param Property $property */ - private function addProperty(Property $property) { - $modifiers = $property->isStatic() ? '' : ' static' ; - $this->beginPhpDomain('attr', $property->getVisibility() . $modifiers . ' ' . $property->getName()); + private function addProperty(Property $property) + { + $modifiers = $property->isStatic() ? '' : ' static'; + $this->beginPhpDomain('attr', $property->getVisibility().$modifiers.' '.$property->getName()); $docBlock = $property->getDocBlock(); $this->addDocBlockDescription($property); if ($docBlock) { @@ -179,7 +369,8 @@ private function addProperty(Property $property) { /** * @param Interface_|Class_ $element */ - protected function addParent($element) { + protected function addParent($element) + { if ($element instanceof Class_) { $parent = $element->getParent(); if ($parent !== null) { @@ -194,13 +385,30 @@ protected function addParent($element) { } } + /** + * @param $type string + * @param $fqsen string + * + * @return string + */ + public static function getLink($type, $fqsen, $description = '') + { + if ($description !== '') { + return ':php:'.$type.':`'.RstBuilder::escape($description).'<'.RstBuilder::escape(substr($fqsen, + 1)).'>`'; + } + + return ':php:'.$type.':`'.RstBuilder::escape(substr($fqsen, 1)).'`'; + } + /** * @param Class_|Trait_ $element */ - protected function addUsedTraits($element) { + protected function addUsedTraits($element) + { $usedTraits = ''; foreach ($element->getUsedTraits() as $trait) { - $usedTraits .= $this->getLink('trait', $trait) . ' '; + $usedTraits .= $this->getLink('trait', $trait).' '; } if ($usedTraits !== '') { $this->addFieldList('Used traits', $usedTraits); @@ -210,7 +418,8 @@ protected function addUsedTraits($element) { /** * @param $methods */ - protected function addMethods($methods) { + protected function addMethods($methods) + { if (count($methods) > 0) { $this->addH2('Methods'); foreach ($methods as $method) { @@ -219,7 +428,8 @@ protected function addMethods($methods) { } } - private function addMethod(Method $method) { + private function addMethod(Method $method) + { if (!$this->shouldRenderElement($method)) { return; } @@ -233,63 +443,21 @@ private function addMethod(Method $method) { } $deprecated = $docBlock->getTagsByName('deprecated'); } - $args = ''; - /** @var Argument $argument */ - foreach ($method->getArguments() as $argument) { - // This will work after https://github.com/phpDocumentor/Reflection/pull/109 is merged - foreach ($argument->getTypes() as $type) { - $args .= self::escape($type) . '|'; - } - $args = substr($args, 0, -1) . ' '; - if($argument->isVariadic()) { - $args .= '...'; - } - if($argument->isByReference()) { - $args .= '&'; - } - $args .= '$' . $argument->getName(); - $default = $argument->getDefault(); - if ($default !== null) { - $default = $default === '' ? '""' : $default; - $args .= '=' . self::escape($default); - } - $args .= ', '; - } - $args = substr($args, 0, -2); $modifiers = $method->getVisibility(); $modifiers .= $method->isAbstract() ? ' abstract' : ''; $modifiers .= $method->isFinal() ? ' final' : ''; $modifiers .= $method->isStatic() ? ' static' : ''; $deprecated = count($deprecated) > 0 ? ' deprecated' : ''; - $this->addLine('.. rst-class:: ' . $modifiers . $deprecated)->addLine(); + $this->addLine('.. rst-class:: '.$modifiers.$deprecated)->addLine(); $this->indent(); - $this->beginPhpDomain('method', $modifiers . ' ' . $method->getName() . '(' . $args . ')'); + + $args = $this->processMethodArgumentTypes($method); + $this->beginPhpDomain('method', $modifiers.' '.$method->getName().'('.$args.')'); $this->addDocBlockDescription($method); $this->addLine(); if (!empty($params)) { - $parameterDetails = ''; - foreach ($method->getArguments() as $argument) { - if (!array_key_exists($argument->getName(), $params)) { - continue; - } - /** @var Param $param */ - $param = $params[$argument->getName()]; - if ($param !== null) { - $typString = $param->getType(); - // Remove first \ to allow references - if (0 === strpos($typString, '\\')) { - $typString = substr($typString, 1); - } - $paramItem = '* '; - $paramItem .= '**$' . $argument->getName() . '** '; - if ($typString !== null) { - $paramItem .= '(' . self::typesToRst($typString) . ') '; - } - $paramItem .= ' ' . $param->getDescription(); - $parameterDetails .= $paramItem . PHP_EOL; - } - } + $parameterDetails = $this->processMethodArgumentDocs($method, $params); $this->addFieldList('Parameters', $parameterDetails); } if ($docBlock !== null) { @@ -302,161 +470,86 @@ private function addMethod(Method $method) { } /** - * @param $type string - * @param $fqsen string + * @param Method $method + * @param array $params + * * @return string */ - public static function getLink($type, $fqsen, $description='') { - if($description !== '') { - return ':php:' . $type . ':`' . RstBuilder::escape($description) . '<' . RstBuilder::escape(substr($fqsen, 1)) . '>`'; + private function processMethodArgumentDocs(Method $method, array $params): string + { + $parameterDetails = ''; + foreach ($method->getArguments() as $argument) { + if (!array_key_exists($argument->getName(), $params)) { + continue; + } + /** @var Param $param */ + $param = $params[$argument->getName()]; + if ($param !== null) { + $typString = $param->getType(); + // Remove first \ to allow references + if (0 === strpos($typString, '\\')) { + $typString = substr($typString, 1); + } + $paramItem = '* '; + $paramItem .= '**'; + if ($argument->isVariadic()) { + $paramItem .= '...'; + } + $paramItem .= '$'.$argument->getName().'** '; + if ($typString !== null) { + $paramItem .= '('.self::typesToRst($typString).') '; + } + $paramItem .= ' '.$param->getDescription(); + $parameterDetails .= $paramItem.PHP_EOL; + } } - return ':php:' . $type . ':`' . RstBuilder::escape(substr($fqsen, 1)) . '`'; + + return $parameterDetails; } /** - * @param $type string - * @param $name string - * @param $indent bool Should indent after the section started + * @param Method $method + * + * @return string */ - public function beginPhpDomain($type, $name, $indent = true) { - // FIXME: Add checks if it is properly ended - $this->addLine('.. php:' . $type . ':: ' . $name)->addLine(); - if ($indent === true) { - $this->indent(); + private function processMethodArgumentTypes(Method $method): string + { + $args = ''; + /** @var Argument $argument */ + foreach ($method->getArguments() as $argument) { + $args = $this->processMethodArgumentType($argument, $args); } - } + $args = substr($args, 0, -2); - /** - * @param string $type - * @return $this - */ - public function endPhpDomain($type = '') { - $this->unindent(); - $this->addLine(); + return $args; } /** - * @param Class_|Interface_|Trait_|Property|Method|Constant $element - * @return $this + * @param Argument $argument + * @param string $args + * + * @return string */ - public function addDocBlockDescription($element) { - if ($element === null) { - return $this; + private function processMethodArgumentType(Argument $argument, string $args): string + { + foreach ($argument->getType() as $type) { + $args .= self::escape($type).'|'; } - $docBlock = $element->getDocBlock(); - $this->callExtensions(self::SECTION_BEFORE_DESCRIPTION, $element); - if ($docBlock !== null && $docBlock->getSummary() !== '') { - $this->addLine('.. rst-class:: phpdoc-description')->addLine(); - $this->indent(); - $this->addMultilineWithoutRendering(RstBuilder::escape($docBlock->getSummary()))->addLine(); - if ((string)$docBlock->getDescription() !== '') { - $this->addMultilineWithoutRendering(RstBuilder::escape($docBlock->getDescription()))->addLine(); - } - $this->unindent(); + $args = substr($args, 0, -1).' '; + if ($argument->isVariadic()) { + $args .= '...'; } - $this->callExtensions(self::SECTION_AFTER_DESCRIPTION, $element); - return $this; - } - - /** - * @param string $tagName Name of the tag to parse - * @param DocBlock $docBlock - */ - protected function addDocblockTag($tagName, DocBlock $docBlock) { - $tags = $docBlock->getTagsByName($tagName); - switch ($tagName) { - case 'return': - if (count($tags) === 0) continue; - /** @var Return_ $return */ - $return = $tags[0]; - $this->addMultiline(':Returns: ' . self::typesToRst($return->getType()) . ' ' . RstBuilder::escape($return->getDescription()), true); - break; - case 'var': - if (count($tags) === 0) continue; - /** @var DocBlock\Tags\Var_ $return */ - $return = $tags[0]; - $this->addMultiline(':Type: ' . self::typesToRst($return->getType()) . ' ' . RstBuilder::escape($return->getDescription()), true); - break; - case 'throws': - if (count($tags) === 0) continue; - /** @var Throws $tag */ - foreach ($tags as $tag) { - $this->addMultiline(':Throws: ' . self::typesToRst($tag->getType()) . ' ' . RstBuilder::escape($tag->getDescription()), true); - } - break; - case 'since': - if (count($tags) === 0) continue; - /** @var Since $return */ - $return = $tags[0]; - $this->addMultiline(':Since: ' . $return->getVersion() . ' ' . RstBuilder::escape($return->getDescription()), true); - break; - case 'deprecated': - if (count($tags) === 0) continue; - /** @var Deprecated $return */ - $return = $tags[0]; - $this->addMultiline(':Deprecated: ' . $return->getVersion() . ' ' . RstBuilder::escape($return->getDescription()), true); - break; - case 'see': - if (count($tags) === 0) continue; - /** @var See $return */ - $return = $tags[0]; - $this->addMultiline(':See: ' . self::typesToRst($return->getReference()) . ' ' . RstBuilder::escape($return->getDescription()), true); - break; - case 'license': - if (count($tags) === 0) continue; - /** @var DocBlock\Tags\BaseTag $return */ - $return = $tags[0]; - $this->addMultiline(':License: ' . RstBuilder::escape($return->getDescription()), true); - break; - case 'param': - // param handling is done by subclasses since it is more that docbook parsing - break; - default: - //echo 'Tag handling not defined for: ' . $tag . PHP_EOL; - break; + if ($argument->isByReference()) { + $args .= '&'; } - - } - - /** - * @param string $typesString - * @return bool|string - */ - public static function typesToRst($typesString) { - // http://docs.phpdoc.org/guides/types.html - $whitelist = [ - 'string', 'int', 'integer', 'float', 'bool', 'boolean', 'array', 'resource', 'null', 'callable', - 'mixed', 'void', 'object', 'false', 'true', 'self', 'static', '$this' - ]; - $types = explode('|', $typesString); - $result = ''; - /** @var string $type */ - foreach ($types as $typeFull) { - $type = str_replace('[]', '', $typeFull); - if (in_array($type, $whitelist, true)) { - $result .= $typeFull . ' | '; - continue; - } - if (0 === strpos($type, '\\')) - $type = substr($type, 1); - $result .= ':any:`' . RstBuilder::escape($typeFull) . ' <' . RstBuilder::escape($type) . '>` | '; + $args .= '$'.$argument->getName(); + $default = $argument->getDefault(); + if ($default !== null) { + $default = $default === '' ? '""' : $default; + $args .= '='.self::escape($default); } - return substr($result, 0, -3); - } + $args .= ', '; - /** - * @param Element $element - * @return bool - */ - public function shouldRenderElement(Element $element) { - /** @var Extension $extension */ - foreach ($this->extensions as $extension) { - if ($extension->shouldRenderElement($element) === false) { - return false; - } - } - return true; + return $args; } - - -} \ No newline at end of file +} diff --git a/src/Builder/RstBuilder.php b/src/Builder/RstBuilder.php old mode 100644 new mode 100755 index a039be7..4973a14 --- a/src/Builder/RstBuilder.php +++ b/src/Builder/RstBuilder.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,80 +16,64 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Builder; - -use phpDocumentor\Reflection\Fqsen; - /** - * Helper class to build reStructuredText files - * - * @package JuliusHaertl\PHPDocToRst\Builder + * Helper class to build reStructuredText files. */ -class RstBuilder { - - private $indentLevel = 0; +class RstBuilder +{ /** @var string */ - protected $content = '.. rst-class:: phpdoctorst' . PHP_EOL . PHP_EOL ; + protected $content = '.. rst-class:: phpdoctorst'.PHP_EOL.PHP_EOL; + private $indentLevel = 0; - public function getContent() { + public function getContent() + { return $this->content; } - public static function escape($text) { - // escape all common reStructuredText control chars - $text = preg_replace("/[\'\`\*\_\{\}\[\]\(\)\|\>\#\+\-\.\\\!]/", '\\\\$0', $text); - return $text; - } + public function addFieldList($key, $value) + { + $this->addLine(':'.self::escape($key).':'); + $this->indent()->addMultiline($value, false)->unindent(); - public function indent() { - $this->indentLevel++; return $this; } - public function unindent() { - $this->indentLevel--; - $this->addLine(); - return $this; - } + public function addLine($text = '') + { + $this->add(str_repeat("\t", $this->indentLevel).$text.PHP_EOL); - public function addFieldList($key, $value) { - $this->addLine(':'.self::escape($key).':'); - $this->indent()->addMultiline($value, false)->unindent(); return $this; } - /** - * @param string $text - * @return $this - */ - public function addH1(string $text) { - $this->addLine($text); - $this->addLine(str_repeat('=', strlen((string)$text)))->addLine(); - return $this; - } + public function add($text) + { + $this->content .= $text; - public function addH2($text) { - $this->addLine($text); - $this->addLine(str_repeat('-', strlen((string)$text)))->addLine(); return $this; } - public function addH3($text) { - $this->addLine($text); - $this->addLine(str_repeat('~', strlen((string)$text)))->addLine(); - return $this; + public static function escape($text) + { + // escape all common reStructuredText control chars + $text = preg_replace("/[\'\`\*\_\{\}\[\]\(\)\|\>\#\+\-\.\\\!]/", '\\\\$0', $text); + + return $text; } - public function addLine($text = '') { - $this->add(str_repeat("\t", $this->indentLevel) . $text . PHP_EOL); + public function unindent() + { + $this->indentLevel--; + $this->addLine(); + return $this; } - public function addMultiline($text = '', $blockIndent = false) { + public function addMultiline($text = '', $blockIndent = false) + { $lines = preg_split('/$\R?^/m', $text); $i = 0; foreach ($lines as $line) { @@ -103,22 +85,53 @@ public function addMultiline($text = '', $blockIndent = false) { if ($blockIndent && count($lines) > 1) { $this->unindent(); } + return $this; } - public function addMultilineWithoutRendering($text) { - $lines = preg_split('/$\R?^/m', $text); - foreach ($lines as $line) { - $this->addLine('| ' . $line); - } + public function indent() + { + $this->indentLevel++; return $this; } - public function add($text) { - $this->content .= $text; + /** + * @param string $text + * + * @return $this + */ + public function addH1(string $text) + { + $this->addLine($text); + $this->addLine(str_repeat('=', strlen((string) $text)))->addLine(); + + return $this; + } + + public function addH2($text) + { + $this->addLine($text); + $this->addLine(str_repeat('-', strlen((string) $text)))->addLine(); + + return $this; + } + + public function addH3($text) + { + $this->addLine($text); + $this->addLine(str_repeat('~', strlen((string) $text)))->addLine(); + return $this; } + public function addMultilineWithoutRendering($text) + { + $lines = preg_split('/$\R?^/m', $text); + foreach ($lines as $line) { + $this->addLine('| '.$line); + } -} \ No newline at end of file + return $this; + } +} diff --git a/src/Builder/TraitFileBuilder.php b/src/Builder/TraitFileBuilder.php old mode 100644 new mode 100755 index 8c8d097..d661f1b --- a/src/Builder/TraitFileBuilder.php +++ b/src/Builder/TraitFileBuilder.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,19 +16,16 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Builder; -use phpDocumentor\Reflection\DocBlock\Tags\Param; -use phpDocumentor\Reflection\Php\Argument; -use phpDocumentor\Reflection\Php\Class_; use phpDocumentor\Reflection\Php\Trait_; -class TraitFileBuilder extends FileBuilder { - - protected function render() { +class TraitFileBuilder extends FileBuilder +{ + protected function render() + { /** @var Trait_ $trait */ $trait = $this->element; @@ -50,5 +45,4 @@ protected function render() { $this->addMethods($trait->getMethods()); } - -} \ No newline at end of file +} diff --git a/src/Extension/AddFullElementNameExtension.php b/src/Extension/AddFullElementNameExtension.php old mode 100644 new mode 100755 index 6c74cd1..e05c9cb --- a/src/Extension/AddFullElementNameExtension.php +++ b/src/Extension/AddFullElementNameExtension.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,42 +16,36 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Extension; -use JuliusHaertl\PHPDocToRst\Builder\ExtensionBuilder; use JuliusHaertl\PHPDocToRst\Builder\FileBuilder; -use JuliusHaertl\PHPDocToRst\Builder\InterfaceFileBuilder; use JuliusHaertl\PHPDocToRst\Builder\PhpDomainBuilder; use JuliusHaertl\PHPDocToRst\Builder\RstBuilder; use phpDocumentor\Reflection\Php\Class_; -use phpDocumentor\Reflection\Php\Interface_; -use phpDocumentor\Reflection\Php\Trait_; /** - * Add the fully qualified element name including the namespace to each page + * Add the fully qualified element name including the namespace to each page. */ - -class AddFullElementNameExtension extends Extension { - +class AddFullElementNameExtension extends Extension +{ /** - * @param string $type + * @param string $type * @param FileBuilder $builder */ - public function render($type, &$builder, $element) { + public function render($type, &$builder, $element) + { if (!$builder instanceof FileBuilder) { return; } if ($type === PhpDomainBuilder::SECTION_BEFORE_DESCRIPTION) { - if($element instanceof Class_) { + if ($element instanceof Class_) { $modifiers = $element->isAbstract() ? 'abstract' : ''; $modifiers = $element->isFinal() ? ' final' : $modifiers; - $builder->addLine(':php:`' . $modifiers . ' class ' . RstBuilder::escape($builder->getElement()->getName()) . ' {}`'); + $builder->addLine(':php:`'.$modifiers.' class '.RstBuilder::escape($builder->getElement()->getName()).' {}`'); $builder->addLine(); } } } - -} \ No newline at end of file +} diff --git a/src/Extension/Extension.php b/src/Extension/Extension.php old mode 100644 new mode 100755 index 6c37f05..7b7f25d --- a/src/Extension/Extension.php +++ b/src/Extension/Extension.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,26 +16,24 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Extension; - use JuliusHaertl\PHPDocToRst\Builder\ExtensionBuilder; -use JuliusHaertl\PHPDocToRst\Builder\FileBuilder; use phpDocumentor\Reflection\Element; use phpDocumentor\Reflection\Php\Project; -abstract class Extension { - +abstract class Extension +{ /** @var Project */ protected $project; /** @var array */ protected $arguments; - public function __construct(Project $project, $arguments=[]) { + public function __construct(Project $project, $arguments = []) + { $this->project = $project; $this->arguments = $arguments; } @@ -45,10 +41,10 @@ public function __construct(Project $project, $arguments=[]) { /** * Method that will be ran before generating any documentation files * This is useful for preparing own data structures - * to be used in the output documentation + * to be used in the output documentation. */ - public function prepare() { - + public function prepare() + { } /** @@ -60,12 +56,12 @@ public function prepare() { * - PhpDomainBuilder::SECTION_BEFORE_DESCRIPTION * - PhpDomainBuilder::SECTION_AFTER_DESCRIPTION * - * @param string $type + * @param string $type * @param ExtensionBuilder $builder - * @param Element $element context for the render type + * @param Element $element context for the render type */ - public function render($type, &$builder, $element) { - + public function render($type, &$builder, $element) + { } /** @@ -75,14 +71,16 @@ public function render($type, &$builder, $element) { * An example extension that makes use of it is PublicOnlyExtension * * @param Element $element + * * @return bool */ - public function shouldRenderElement(Element $element) { + public function shouldRenderElement(Element $element) + { return true; } - public function shouldRenderIndex($type, $element) { + public function shouldRenderIndex($type, $element) + { return true; } - -} \ No newline at end of file +} diff --git a/src/Extension/GithubLocationExtension.php b/src/Extension/GithubLocationExtension.php old mode 100644 new mode 100755 index 536e5ce..60cb099 --- a/src/Extension/GithubLocationExtension.php +++ b/src/Extension/GithubLocationExtension.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,34 +16,34 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Extension; +use Exception; use JuliusHaertl\PHPDocToRst\Builder\FileBuilder; use JuliusHaertl\PHPDocToRst\Builder\PhpDomainBuilder; use phpDocumentor\Reflection\Element; use phpDocumentor\Reflection\Php\File; /** - * This extension adds a link to the source at github to all elements + * 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) */ - -class GithubLocationExtension extends Extension { - +class GithubLocationExtension extends Extension +{ protected $basePath; protected $githubRepo; protected $branch = 'master'; - public function prepare() { + public function prepare() + { if (count($this->arguments) < 2) { - throw new \Exception('GithubLocationExtension requires the following arguments githubUrl, basePath.'); + throw new Exception('GithubLocationExtension requires the following arguments githubUrl, basePath.'); } $this->basePath = $this->arguments[0]; $this->githubRepo = $this->arguments[1]; @@ -55,11 +53,12 @@ public function prepare() { } /** - * @param string $type + * @param string $type * @param FileBuilder $builder - * @param Element $element + * @param Element $element */ - public function render($type, &$builder, $element) { + public function render($type, &$builder, $element) + { if (!$builder instanceof FileBuilder) { return; } @@ -68,15 +67,15 @@ public function render($type, &$builder, $element) { return; } $filePath = $builder->getFile()->getPath(); - $filePath = preg_replace('/^' . preg_quote($this->basePath, '/') . '/', '', $filePath); + $filePath = preg_replace('/^'.preg_quote($this->basePath, '/').'/', '', $filePath); $lineNumber = $element->getLocation()->getLineNumber(); $url = $this->getGithubLink($filePath, $lineNumber, $this->branch); - $builder->addFieldList('Source', '`' . $filePath. '#' . $lineNumber . ' <'.$url.'>`_'); + $builder->addFieldList('Source', '`'.$filePath.'#'.$lineNumber.' <'.$url.'>`_'); } } - private function getGithubLink($file, $line=1, $branch='master') { - return $this->githubRepo . '/blob/'.$branch.'/'.$file.'#L' . $line; + private function getGithubLink($file, $line = 1, $branch = 'master') + { + return $this->githubRepo.'/blob/'.$branch.'/'.$file.'#L'.$line; } - -} \ No newline at end of file +} diff --git a/src/Extension/HideChildNamespaces.php b/src/Extension/HideChildNamespaces.php old mode 100644 new mode 100755 index cc6b148..d1631a9 --- a/src/Extension/HideChildNamespaces.php +++ b/src/Extension/HideChildNamespaces.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,7 +16,6 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Extension; @@ -26,16 +23,16 @@ use JuliusHaertl\PHPDocToRst\Builder\NamespaceIndexBuilder; /** - * Example for hiding a section in the namespace index page + * Example for hiding a section in the namespace index page. */ - -class HideChildNamespaces extends Extension { - - public function shouldRenderIndex($type, $element) { +class HideChildNamespaces extends Extension +{ + public function shouldRenderIndex($type, $element) + { if ($type === NamespaceIndexBuilder::RENDER_INDEX_NAMESPACE) { return false; } + return true; } - -} \ No newline at end of file +} diff --git a/src/Extension/InterfaceImplementors.php b/src/Extension/InterfaceImplementors.php old mode 100644 new mode 100755 index 0ab6ada..bc54867 --- a/src/Extension/InterfaceImplementors.php +++ b/src/Extension/InterfaceImplementors.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,7 +16,6 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Extension; @@ -30,37 +27,33 @@ use phpDocumentor\Reflection\Php\Interface_; /** - * Class InterfaceImplementors - * @package JuliusHaertl\PHPDocToRst\Extension - * - * This extension parses all classes and interface relations. - * A link to all classes implementing a specific interface - * is added to the interface documentation. + * Class InterfaceImplementors. */ - -class InterfaceImplementors extends Extension { - +class InterfaceImplementors extends Extension +{ private $implementors = []; - public function prepare() { + public function prepare() + { foreach ($this->project->getFiles() as $file) { foreach ($file->getClasses() as $class) { foreach ($class->getInterfaces() as $interface) { - if (!array_key_exists((string)$interface, $this->implementors)) { - $this->implementors[(string)$interface] = []; + if (!array_key_exists((string) $interface, $this->implementors)) { + $this->implementors[(string) $interface] = []; } - $this->implementors[(string)$interface][] = $class->getFqsen(); + $this->implementors[(string) $interface][] = $class->getFqsen(); } } } } /** - * @param string $type + * @param string $type * @param FileBuilder $builder - * @param Element $element + * @param Element $element */ - public function render($type, &$builder, $element) { + public function render($type, &$builder, $element) + { if (!$builder instanceof FileBuilder || !$element instanceof Interface_) { return; } @@ -68,19 +61,18 @@ public function render($type, &$builder, $element) { /** @var Interface_ $interface */ $interface = $builder->getElement(); $content = ''; - if (!array_key_exists((string)$interface->getFqsen(), $this->implementors)) { + if (!array_key_exists((string) $interface->getFqsen(), $this->implementors)) { return; } - $implementors = $this->implementors[(string)$interface->getFqsen()]; + $implementors = $this->implementors[(string) $interface->getFqsen()]; if (count($implementors) === 0) { return; } foreach ($implementors as $implementor) { - $content .= ':php:class:`' . RstBuilder::escape(substr($implementor, 1)) . '` '; + $content .= ':php:class:`'.RstBuilder::escape(substr($implementor, 1)).'` '; } $builder->addFieldList('Implemented by', $content); $builder->addLine(); } } - -} \ No newline at end of file +} diff --git a/src/Extension/NoPrivateExtension.php b/src/Extension/NoPrivateExtension.php old mode 100644 new mode 100755 index 77c0715..fbe532c --- a/src/Extension/NoPrivateExtension.php +++ b/src/Extension/NoPrivateExtension.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,26 +16,23 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Extension; -use JuliusHaertl\PHPDocToRst\Builder\FileBuilder; use phpDocumentor\Reflection\Element; use phpDocumentor\Reflection\Php\Class_; -use phpDocumentor\Reflection\Php\Constant; use phpDocumentor\Reflection\Php\Method; use phpDocumentor\Reflection\Php\Property; /** * Do not render classes marked with phpDoc internal tag - * Do only render public methods/properties + * Do only render public methods/properties. */ - -class NoPrivateExtension extends Extension { - - public function shouldRenderElement(Element $element) { +class NoPrivateExtension extends Extension +{ + public function shouldRenderElement(Element $element) + { if ($element instanceof Class_) { /** @var Class_ $class */ $class = $element; @@ -48,11 +43,11 @@ public function shouldRenderElement(Element $element) { if ($element instanceof Method || $element instanceof Property) { /** @var Method|Property $class */ $class = $element; - if ((string)$class->getVisibility() === 'private') { + if ((string) $class->getVisibility() === 'private') { return false; } } + return true; } - -} \ No newline at end of file +} diff --git a/src/Extension/PublicOnlyExtension.php b/src/Extension/PublicOnlyExtension.php old mode 100644 new mode 100755 index 1927bfd..eb6de4e --- a/src/Extension/PublicOnlyExtension.php +++ b/src/Extension/PublicOnlyExtension.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,26 +16,23 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Extension; -use JuliusHaertl\PHPDocToRst\Builder\FileBuilder; use phpDocumentor\Reflection\Element; use phpDocumentor\Reflection\Php\Class_; -use phpDocumentor\Reflection\Php\Constant; use phpDocumentor\Reflection\Php\Method; use phpDocumentor\Reflection\Php\Property; /** * Do not render classes marked with phpDoc internal tag - * Do only render public methods/properties + * Do only render public methods/properties. */ - -class PublicOnlyExtension extends Extension { - - public function shouldRenderElement(Element $element) { +class PublicOnlyExtension extends Extension +{ + public function shouldRenderElement(Element $element) + { if ($element instanceof Class_) { /** @var Class_ $class */ $class = $element; @@ -48,11 +43,11 @@ public function shouldRenderElement(Element $element) { if ($element instanceof Method || $element instanceof Property) { /** @var Method|Property $class */ $class = $element; - if ((string)$class->getVisibility() !== 'public') { + if ((string) $class->getVisibility() !== 'public') { return false; } } + return true; } - -} \ No newline at end of file +} diff --git a/src/Extension/TocExtension.php b/src/Extension/TocExtension.php old mode 100644 new mode 100755 index 6f1b308..551ba64 --- a/src/Extension/TocExtension.php +++ b/src/Extension/TocExtension.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,15 +16,12 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst\Extension; use JuliusHaertl\PHPDocToRst\Builder\FileBuilder; -use JuliusHaertl\PHPDocToRst\Builder\InterfaceFileBuilder; use JuliusHaertl\PHPDocToRst\Builder\PhpDomainBuilder; -use JuliusHaertl\PHPDocToRst\Builder\RstBuilder; use phpDocumentor\Reflection\Php\Argument; use phpDocumentor\Reflection\Php\Class_; use phpDocumentor\Reflection\Php\Interface_; @@ -34,16 +29,16 @@ /** * This extension will render a list of methods for easy access - * at the beginning of classes, interfaces and traits + * at the beginning of classes, interfaces and traits. */ - -class TocExtension extends Extension { - +class TocExtension extends Extension +{ /** - * @param string $type + * @param string $type * @param FileBuilder $builder */ - public function render($type, &$builder, $element) { + public function render($type, &$builder, $element) + { if ($type === PhpDomainBuilder::SECTION_AFTER_INTRODUCTION) { if ($element instanceof Class_ || $element instanceof Interface_ || $element instanceof Trait_) { $builder->addLine(); @@ -52,29 +47,27 @@ public function render($type, &$builder, $element) { /** @var Interface_ $interface */ $interface = $builder->getElement(); - if(count($interface->getMethods()) > 0) { + if (count($interface->getMethods()) > 0) { $builder->addH3('Methods'); foreach ($interface->getMethods() as $method) { $args = ''; /** @var Argument $argument */ foreach ($method->getArguments() as $argument) { // TODO: defaults, types - $args .= '$' . $argument->getName() . ', '; + $args .= '$'.$argument->getName().', '; } $args = substr($args, 0, -2); $modifiers = $method->getVisibility(); $modifiers .= $method->isAbstract() ? ' abstract' : ''; $modifiers .= $method->isFinal() ? ' final' : ''; $modifiers .= $method->isStatic() ? ' static' : ''; - $signature = $modifiers . ' ' . $method->getName() . '(' . $args . ')'; - - $builder->addLine('* ' . PhpDomainBuilder::getLink('meth', $method->getFqsen(), $signature)); + $signature = $modifiers.' '.$method->getName().'('.$args.')'; + $builder->addLine('* '.PhpDomainBuilder::getLink('meth', $method->getFqsen(), $signature)); } $builder->addLine()->addLine(); } } } - } -} \ No newline at end of file +} diff --git a/src/GenerateDocumentationCommand.php b/src/GenerateDocumentationCommand.php old mode 100644 new mode 100755 index a64c402..988a57a --- a/src/GenerateDocumentationCommand.php +++ b/src/GenerateDocumentationCommand.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,48 +16,42 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst; -use JuliusHaertl\PHPDocToRst\Extension\AddFullElementNameExtension; use JuliusHaertl\PHPDocToRst\Extension\GithubLocationExtension; use JuliusHaertl\PHPDocToRst\Extension\NoPrivateExtension; use JuliusHaertl\PHPDocToRst\Extension\PublicOnlyExtension; use JuliusHaertl\PHPDocToRst\Extension\TocExtension; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputArgument; /** - * Class GenerateDocumentationCommand - * @package JuliusHaertl\PHPDocToRst + * Class GenerateDocumentationCommand. + * * @internal Only for use of the phpdoc-to-rst cli tool */ -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); - +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); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output) + { $src = $input->getArgument('src'); $dst = $input->getArgument('target'); @@ -71,22 +63,22 @@ protected function execute(InputInterface $input, OutputInterface $output) { $apiDocBuilder->setVerboseOutput(true); $apiDocBuilder->setDebugOutput(true); } - if($input->getOption('public-only')) { + if ($input->getOption('public-only')) { $apiDocBuilder->addExtension(PublicOnlyExtension::class); } - if(!$input->getOption('show-private')) { + if (!$input->getOption('show-private')) { $apiDocBuilder->addExtension(NoPrivateExtension::class); } - if($input->getOption('element-toc')) { + if ($input->getOption('element-toc')) { $apiDocBuilder->addExtension(TocExtension::class); } - if($input->getOption('repo-github') && $input->getOption('repo-base')) { + if ($input->getOption('repo-github') && $input->getOption('repo-base')) { $apiDocBuilder->addExtension(GithubLocationExtension::class, [ $input->getOption('repo-base'), - $input->getOption('repo-github') + $input->getOption('repo-github'), ]); } $apiDocBuilder->build(); } -} \ No newline at end of file +} diff --git a/src/Middleware/ErrorHandlingMiddleware.php b/src/Middleware/ErrorHandlingMiddleware.php old mode 100644 new mode 100755 index 5a58f20..a8d7563 --- a/src/Middleware/ErrorHandlingMiddleware.php +++ b/src/Middleware/ErrorHandlingMiddleware.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,24 +16,26 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ + namespace JuliusHaertl\PHPDocToRst\Middleware; +use Exception; use JuliusHaertl\PHPDocToRst\ApiDocBuilder; use phpDocumentor\Reflection\Middleware\Middleware; use phpDocumentor\Reflection\Php\Factory\File\CreateCommand; /** - * Class ErrorHandlingMiddleware + * Class ErrorHandlingMiddleware. + * * @ignore */ final class ErrorHandlingMiddleware implements Middleware { - private $apiDocBuilder; - public function __construct(ApiDocBuilder $apiDocBuilder) { + public function __construct(ApiDocBuilder $apiDocBuilder) + { $this->apiDocBuilder = $apiDocBuilder; } @@ -43,18 +43,19 @@ public function __construct(ApiDocBuilder $apiDocBuilder) { * Executes this middleware class. * * @param CreateCommand $command - * @param callable $next + * @param callable $next + * * @return object */ public function execute($command, callable $next) { $filename = $command->getFile()->path(); - $this->apiDocBuilder->debug('Starting to parse file: ' . $filename); + $this->apiDocBuilder->debug('Starting to parse file: '.$filename); + try { return $next($command); - } catch (\Exception $e) { - $this->apiDocBuilder->log('Unable to parse file "' . $filename . '", ' . $e->getMessage()); + } catch (Exception $e) { + $this->apiDocBuilder->log('Unable to parse file "'.$filename.'", '.$e->getMessage()); } - return null; } -} \ No newline at end of file +} diff --git a/src/WriteException.php b/src/WriteException.php old mode 100644 new mode 100755 index 3874f14..24865ba --- a/src/WriteException.php +++ b/src/WriteException.php @@ -1,10 +1,8 @@ - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version + * @author Julius Härtl + * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -18,14 +16,15 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * */ namespace JuliusHaertl\PHPDocToRst; +use Exception; + /** - * An exception for writing failure of files/directories in the build process + * An exception for writing failure of files/directories in the build process. */ -class WriteException extends \Exception { - -} \ No newline at end of file +class WriteException extends Exception +{ +} diff --git a/tests/DocGenerationTest.php b/tests/DocGenerationTest.php new file mode 100755 index 0000000..ee1be2c --- /dev/null +++ b/tests/DocGenerationTest.php @@ -0,0 +1,82 @@ +setVerboseOutput(true); + $apiDocBuilder->setDebugOutput(true); + $apiDocBuilder->addExtension(InterfaceImplementors::class); + $apiDocBuilder->build(); + } + + public function testDocumentingSelf() + { + $src = [__DIR__.'/../src']; + $dst = __DIR__.'/../tests/self-doc'; + + $apiDocBuilder = new ApiDocBuilder($src, $dst); + $apiDocBuilder->setVerboseOutput(true); + $apiDocBuilder->setDebugOutput(true); + $apiDocBuilder->addExtension(InterfaceImplementors::class); + $apiDocBuilder->build(); + } + + public function testDocumentingPSR() + { + $src = [__DIR__.'/../vendor/psr']; + $dst = __DIR__.'/../tests/psr-doc'; + + $apiDocBuilder = new ApiDocBuilder($src, $dst); + $apiDocBuilder->setVerboseOutput(true); + $apiDocBuilder->setDebugOutput(true); + $apiDocBuilder->addExtension(InterfaceImplementors::class); + $apiDocBuilder->build(); + } + + public function testDocumentingDocumentor() + { + $src = [__DIR__.'/../vendor/phpdocumentor']; + $dst = __DIR__.'/../tests/documentor-doc'; + + $apiDocBuilder = new ApiDocBuilder($src, $dst); + $apiDocBuilder->setVerboseOutput(true); + $apiDocBuilder->setDebugOutput(true); + $apiDocBuilder->addExtension(InterfaceImplementors::class); + $apiDocBuilder->build(); + } + + public function testDocumentingWithExtension() + { + $src = [__DIR__.'/../src']; + $dst = __DIR__.'/../tests/self-doc'; + + $apiDocBuilder = new ApiDocBuilder($src, $dst); + $apiDocBuilder->setVerboseOutput(true); + $apiDocBuilder->setDebugOutput(true); + $apiDocBuilder->addExtension(PublicOnlyExtension::class); + $apiDocBuilder->addExtension(NoPrivateExtension::class); + $apiDocBuilder->addExtension(TocExtension::class); + $apiDocBuilder->addExtension(InterfaceImplementors::class); + $apiDocBuilder->addExtension(GithubLocationExtension::class, [ + 'http://github.com/abbadon1334', + 'phpdoc-to-rst', + 'master', + ]); + $apiDocBuilder->build(); + } +} diff --git a/tests/InterfaceBuilderTest.php b/tests/InterfaceBuilderTest.php deleted file mode 100644 index c9adc6c..0000000 --- a/tests/InterfaceBuilderTest.php +++ /dev/null @@ -1,22 +0,0 @@ -getMockBuilder(File::class); - $element = $this->getMockBuilder(Element::class); - } -} \ No newline at end of file diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index e91cc12..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,3 +0,0 @@ - - - - ./ - - - - ../src - - - -