From b17c827067fa07e2bd787afb7b769a2322e88798 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 5 Jan 2014 04:38:30 +0100 Subject: [PATCH] renamed phpdoc extension to apidoc --- extensions/yii/apidoc/.gitignore | 2 + extensions/yii/apidoc/CHANGELOG.md | 7 + extensions/yii/apidoc/LICENSE.md | 32 ++++ extensions/yii/apidoc/README.md | 28 ++++ extensions/yii/apidoc/assets/css/api.css | 105 ++++++++++++ extensions/yii/apidoc/assets/css/style.css | 32 ++++ .../yii/apidoc/commands/PhpdocController.php | 88 ++++++++++ extensions/yii/apidoc/components/BaseRenderer.php | 37 +++++ .../yii/apidoc/components/OfflineRenderer.php | 182 +++++++++++++++++++++ extensions/yii/apidoc/composer.json | 29 ++++ extensions/yii/apidoc/models/BaseDoc.php | 45 +++++ extensions/yii/apidoc/models/ClassDoc.php | 80 +++++++++ extensions/yii/apidoc/models/Context.php | 93 +++++++++++ extensions/yii/apidoc/models/EventDoc.php | 15 ++ extensions/yii/apidoc/models/File.php | 53 ++++++ extensions/yii/apidoc/models/FunctionDoc.php | 15 ++ extensions/yii/apidoc/models/InterfaceDoc.php | 45 +++++ extensions/yii/apidoc/models/MethodDoc.php | 18 ++ extensions/yii/apidoc/models/ParamDoc.php | 18 ++ extensions/yii/apidoc/models/PropertyDoc.php | 23 +++ extensions/yii/apidoc/models/TraitDoc.php | 49 ++++++ extensions/yii/apidoc/views/class.php | 49 ++++++ extensions/yii/apidoc/views/classSummary.php | 60 +++++++ extensions/yii/apidoc/views/index.php | 30 ++++ extensions/yii/apidoc/views/layouts/offline.php | 64 ++++++++ extensions/yii/phpdoc/.gitignore | 2 - extensions/yii/phpdoc/CHANGELOG.md | 7 - extensions/yii/phpdoc/LICENSE.md | 32 ---- extensions/yii/phpdoc/README.md | 28 ---- extensions/yii/phpdoc/assets/css/api.css | 105 ------------ extensions/yii/phpdoc/assets/css/style.css | 32 ---- .../yii/phpdoc/commands/PhpdocController.php | 89 ---------- extensions/yii/phpdoc/components/BaseRenderer.php | 38 ----- .../yii/phpdoc/components/OfflineRenderer.php | 182 --------------------- extensions/yii/phpdoc/composer.json | 29 ---- extensions/yii/phpdoc/models/BaseDoc.php | 40 ----- extensions/yii/phpdoc/models/ClassDoc.php | 75 --------- extensions/yii/phpdoc/models/Context.php | 93 ----------- extensions/yii/phpdoc/models/EventDoc.php | 10 -- extensions/yii/phpdoc/models/File.php | 48 ------ extensions/yii/phpdoc/models/FunctionDoc.php | 10 -- extensions/yii/phpdoc/models/InterfaceDoc.php | 45 ----- extensions/yii/phpdoc/models/MethodDoc.php | 13 -- extensions/yii/phpdoc/models/ParamDoc.php | 18 -- extensions/yii/phpdoc/models/PropertyDoc.php | 23 --- extensions/yii/phpdoc/models/TraitDoc.php | 49 ------ extensions/yii/phpdoc/views/class.php | 49 ------ extensions/yii/phpdoc/views/classSummary.php | 60 ------- extensions/yii/phpdoc/views/index.php | 30 ---- extensions/yii/phpdoc/views/layouts/offline.php | 64 -------- 50 files changed, 1199 insertions(+), 1171 deletions(-) create mode 100644 extensions/yii/apidoc/.gitignore create mode 100644 extensions/yii/apidoc/CHANGELOG.md create mode 100644 extensions/yii/apidoc/LICENSE.md create mode 100644 extensions/yii/apidoc/README.md create mode 100644 extensions/yii/apidoc/assets/css/api.css create mode 100644 extensions/yii/apidoc/assets/css/style.css create mode 100644 extensions/yii/apidoc/commands/PhpdocController.php create mode 100644 extensions/yii/apidoc/components/BaseRenderer.php create mode 100644 extensions/yii/apidoc/components/OfflineRenderer.php create mode 100644 extensions/yii/apidoc/composer.json create mode 100644 extensions/yii/apidoc/models/BaseDoc.php create mode 100644 extensions/yii/apidoc/models/ClassDoc.php create mode 100644 extensions/yii/apidoc/models/Context.php create mode 100644 extensions/yii/apidoc/models/EventDoc.php create mode 100644 extensions/yii/apidoc/models/File.php create mode 100644 extensions/yii/apidoc/models/FunctionDoc.php create mode 100644 extensions/yii/apidoc/models/InterfaceDoc.php create mode 100644 extensions/yii/apidoc/models/MethodDoc.php create mode 100644 extensions/yii/apidoc/models/ParamDoc.php create mode 100644 extensions/yii/apidoc/models/PropertyDoc.php create mode 100644 extensions/yii/apidoc/models/TraitDoc.php create mode 100644 extensions/yii/apidoc/views/class.php create mode 100644 extensions/yii/apidoc/views/classSummary.php create mode 100644 extensions/yii/apidoc/views/index.php create mode 100644 extensions/yii/apidoc/views/layouts/offline.php delete mode 100644 extensions/yii/phpdoc/.gitignore delete mode 100644 extensions/yii/phpdoc/CHANGELOG.md delete mode 100644 extensions/yii/phpdoc/LICENSE.md delete mode 100644 extensions/yii/phpdoc/README.md delete mode 100644 extensions/yii/phpdoc/assets/css/api.css delete mode 100644 extensions/yii/phpdoc/assets/css/style.css delete mode 100644 extensions/yii/phpdoc/commands/PhpdocController.php delete mode 100644 extensions/yii/phpdoc/components/BaseRenderer.php delete mode 100644 extensions/yii/phpdoc/components/OfflineRenderer.php delete mode 100644 extensions/yii/phpdoc/composer.json delete mode 100644 extensions/yii/phpdoc/models/BaseDoc.php delete mode 100644 extensions/yii/phpdoc/models/ClassDoc.php delete mode 100644 extensions/yii/phpdoc/models/Context.php delete mode 100644 extensions/yii/phpdoc/models/EventDoc.php delete mode 100644 extensions/yii/phpdoc/models/File.php delete mode 100644 extensions/yii/phpdoc/models/FunctionDoc.php delete mode 100644 extensions/yii/phpdoc/models/InterfaceDoc.php delete mode 100644 extensions/yii/phpdoc/models/MethodDoc.php delete mode 100644 extensions/yii/phpdoc/models/ParamDoc.php delete mode 100644 extensions/yii/phpdoc/models/PropertyDoc.php delete mode 100644 extensions/yii/phpdoc/models/TraitDoc.php delete mode 100644 extensions/yii/phpdoc/views/class.php delete mode 100644 extensions/yii/phpdoc/views/classSummary.php delete mode 100644 extensions/yii/phpdoc/views/index.php delete mode 100644 extensions/yii/phpdoc/views/layouts/offline.php diff --git a/extensions/yii/apidoc/.gitignore b/extensions/yii/apidoc/.gitignore new file mode 100644 index 0000000..8b7ef35 --- /dev/null +++ b/extensions/yii/apidoc/.gitignore @@ -0,0 +1,2 @@ +/vendor +composer.lock diff --git a/extensions/yii/apidoc/CHANGELOG.md b/extensions/yii/apidoc/CHANGELOG.md new file mode 100644 index 0000000..16875d2 --- /dev/null +++ b/extensions/yii/apidoc/CHANGELOG.md @@ -0,0 +1,7 @@ +Yii Framework 2 apidoc extension Change Log +=========================================== + +2.0.0 beta under development +---------------------------- + +- Initial release. diff --git a/extensions/yii/apidoc/LICENSE.md b/extensions/yii/apidoc/LICENSE.md new file mode 100644 index 0000000..e98f03d --- /dev/null +++ b/extensions/yii/apidoc/LICENSE.md @@ -0,0 +1,32 @@ +The Yii framework is free software. It is released under the terms of +the following BSD License. + +Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Yii Software LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/extensions/yii/apidoc/README.md b/extensions/yii/apidoc/README.md new file mode 100644 index 0000000..b733d7d --- /dev/null +++ b/extensions/yii/apidoc/README.md @@ -0,0 +1,28 @@ +API documentation generator for Yii 2 +===================================== + +This extension provides an API documentation generator for the Yii framework 2.0. + +Installation +------------ + +The preferred way to install this extension is through [composer](http://getcomposer.org/download/). + +Either run + +``` +php composer.phar require yiisoft/yii2-apidoc "*" +``` + +or add + +```json +"yiisoft/yii2-apidoc": "*" +``` + +to the require section of your composer.json. + +Usage +----- + +TDB \ No newline at end of file diff --git a/extensions/yii/apidoc/assets/css/api.css b/extensions/yii/apidoc/assets/css/api.css new file mode 100644 index 0000000..482c04f --- /dev/null +++ b/extensions/yii/apidoc/assets/css/api.css @@ -0,0 +1,105 @@ +pre { + color: #000000; + background-color: #FFF5E6; + font-family: "courier new", "times new roman", monospace; + line-height: 1.3em; + /* Put a nice border around it. */ + padding: 1px; + width: 90%; + /* Don't wrap its contents, and show scrollbars. */ + /* white-space: nowrap;*/ + overflow: auto; + /* Stop after about 24 lines, and just show a scrollbar. */ + /* max-height: 24em; */ + margin: 5px; + padding-left: 20px; + border: 1px solid #FFE6BF; + border-left: 6px solid #FFE6BF; +} + +div.code { + display: none; + color: #000000; + background-color: #FFF5E6; + font-family: "courier new", "times new roman", monospace; + line-height: 1.3em; + /* Put a nice border around it. */ + padding: 1px; + width: 90%; + /* Don't wrap its contents, and show scrollbars. */ + /* white-space: nowrap;*/ + overflow: auto; + /* Stop after about 24 lines, and just show a scrollbar. */ + /* max-height: 24em; */ + margin: 5px; + padding-left: 20px; + border-left: 6px solid #FFE6BF; +} + +table.summaryTable { + background: #E6ECFF; + border-collapse: collapse; + width: 100%; +} + +table.summaryTable th, table.summaryTable td { + border: 1px #BFCFFF solid; + padding: 0.2em; +} + +table.summaryTable th { + background: #CCD9FF; + text-align: left; +} + +#nav { + padding: 3px; + margin: 0 0 10px 0; + border-top: 1px #BFCFFF solid; +} + +#classDescription { + padding: 5px; + margin: 10px 0 20px 0; + border-bottom: 1px solid #BFCFFF; +} + +.detailHeader { + font-weight: bold; + font-size: 12pt; + margin: 30px 0 5px 0; + border-bottom: 1px solid #BFCFFF; +} + +.detailHeaderTag { + font-weight: normal; + font-size: 10pt; +} + +.signature, .signature2 { + padding: 3px; + color: #000000; + font-family: "courier new", "times new roman", monospace; + line-height: 1.3em; +} + +.signature { + margin: 10px 0 10px 0; + background: #E6ECFF; + border: 1px #BFCFFF solid; +} + +.paramNameCol { + width: 12%; + font-weight: bold; +} + +.paramTypeCol { + width: 12%; +} + +.sourceCode { + margin: 5px 0; + padding:5px; + background:#FFF5E6; +} \ No newline at end of file diff --git a/extensions/yii/apidoc/assets/css/style.css b/extensions/yii/apidoc/assets/css/style.css new file mode 100644 index 0000000..009c218 --- /dev/null +++ b/extensions/yii/apidoc/assets/css/style.css @@ -0,0 +1,32 @@ +body +{ +} + +body, div, span, p, input +{ + font-family: Verdana, Arial, sans-serif; + font-size: 10pt; + color: #333333; +} + +#apiPage { +} + +#apiHeader { + padding: 3px; + color: white; + background: #6078BF; + margin-bottom: 5px; + font-weight: bold; +} + +#apiHeader a { + color: white; +} + +#apiFooter { + margin-top: 5px; + padding: 3px; + border-top: 1px solid #BFCFFF; + text-align: center; +} diff --git a/extensions/yii/apidoc/commands/PhpdocController.php b/extensions/yii/apidoc/commands/PhpdocController.php new file mode 100644 index 0000000..9236580 --- /dev/null +++ b/extensions/yii/apidoc/commands/PhpdocController.php @@ -0,0 +1,88 @@ + + * @since 2.0 + */ +class PhpdocController extends Controller +{ + public function actionIndex($targetDir) + { + echo "hi\n"; + + $targetDir = Yii::getAlias($targetDir); + if (is_dir($targetDir) && !$this->confirm('TargetDirectory already exists. Overwrite?')) { + return 2; + } + + // TODO determine files to analyze + $this->stdout('Searching files to process... '); + $files = $this->findFiles(YII_PATH); +// $files = array_slice($files, 0, 42); // TODO remove this line + $this->stdout('done.' . PHP_EOL, Console::FG_GREEN); + + $fileCount = count($files); + Console::startProgress(0, $fileCount, 'Processing files... ', false); + $context = new Context(); + $done = 0; + foreach($files as $file) { + $context->addFile($file); + Console::updateProgress(++$done, $fileCount); + } + Console::endProgress(true); + $this->stdout('done.' . PHP_EOL, Console::FG_GREEN); + + $this->stdout('Updating cross references and backlinks... '); + $context->updateReferences(); + $this->stdout('done.' . PHP_EOL, Console::FG_GREEN); + + + // TODO LATER analyze for dead links and similar stuff + + // TODO render models + $renderer = new OfflineRenderer(); + $renderer->targetDir = $targetDir; + $renderer->render($context, $this); + } + + + protected function findFiles($path, $except = []) + { + $path = FileHelper::normalizePath($path); + $options = [ + 'filter' => function ($path) { + if (is_file($path)) { + $file = basename($path); + if ($file[0] < 'A' || $file[0] > 'Z') { + return false; + } + } + return null; + }, + 'only' => ['.php'], + 'except' => array_merge($except, [ + '/views/', + '/requirements/', + '/gii/generators/', + ]), + ]; + return FileHelper::findFiles($path, $options); + } + +} \ No newline at end of file diff --git a/extensions/yii/apidoc/components/BaseRenderer.php b/extensions/yii/apidoc/components/BaseRenderer.php new file mode 100644 index 0000000..5b8fb69 --- /dev/null +++ b/extensions/yii/apidoc/components/BaseRenderer.php @@ -0,0 +1,37 @@ +_view === null) { + $this->_view = new View(); + } + return $this->_view; + } + + /** + * @param Context $context + * @param Controller $controller + * @return mixed + */ + public abstract function render($context, $controller); + +} \ No newline at end of file diff --git a/extensions/yii/apidoc/components/OfflineRenderer.php b/extensions/yii/apidoc/components/OfflineRenderer.php new file mode 100644 index 0000000..0c3d2dd --- /dev/null +++ b/extensions/yii/apidoc/components/OfflineRenderer.php @@ -0,0 +1,182 @@ +context = $context; + $dir = Yii::getAlias($this->targetDir); + if (!is_dir($dir)) { + mkdir($dir); + } + + $items = array_merge($context->classes, $context->interfaces, $context->traits); + $itemCount = count($items) + 1; + Console::startProgress(0, $itemCount, 'Rendering files: ', false); + $done = 0; + foreach($items as $item) { + $fileContent = $this->renderWithLayout($this->itemView, [ + 'item' => $item, + 'docContext' => $context, + ]); + file_put_contents($dir . '/' . $this->generateFileName($item->name), $fileContent); + Console::updateProgress(++$done, $itemCount); + } + $indexFileContent = $this->renderWithLayout($this->indexView, [ + 'docContext' => $context, + 'items' => $items, + ]); + file_put_contents($dir . '/index.html', $indexFileContent); + Console::updateProgress(++$done, $itemCount); + Console::endProgress(true); + $controller->stdout('done.' . PHP_EOL, Console::FG_GREEN); + + $controller->stdout('Copying asset files... '); + FileHelper::copyDirectory(__DIR__ . '/../assets/css', $dir . '/css'); + $controller->stdout('done.' . PHP_EOL, Console::FG_GREEN); + + } + + protected function renderWithLayout($viewFile, $params) + { + $output = $this->getView()->render($viewFile, $params, $this); + if ($this->layout !== false) { + $params['content'] = $output; + return $this->getView()->renderFile($this->layout, $params, $this); + } else { + return $output; + } + } + + /** + * creates a link to an item + * @param ClassDoc|InterfaceDoc|TraitDoc $item + * @param string $title + * @return string + */ + public function link($item, $title = null) + { + if ($title === null) { + $title = $item->name; + } + return Html::a($title, null, ['href' => $this->generateFileName($item->name)]); + } + + /** + * @param ClassDoc $class + * @return string + */ + public function renderInheritance($class) + { + $parents[] = $this->link($class); + while ($class->parentClass !== null) { + if(isset($this->context->classes[$class->parentClass])) { + $class = $this->context->classes[$class->parentClass]; + $parents[] = $this->link($class); + } else { + $parents[] = $class->parentClass; // TODO link to php.net + break; + } + } + return implode(" »\n",$parents); + } + + /** + * @param ClassDoc $class + * @return string + */ + public function renderImplements($class) + { + $interfaces = []; + foreach($class->interfaces as $interface) { + if(isset($this->context->interfaces[$interface])) { + $interfaces[] = $this->link($this->context->interfaces[$interface]); + } else { + $interfaces[] = $interface; // TODO link to php.net + } + } + return implode(', ',$interfaces); + } + + /** + * @param ClassDoc|TraitDoc $class + * @return string + */ + public function renderTraitUses($class) + { + $traits = []; + foreach($class->traits as $trait) { + if(isset($this->context->traits[$trait])) { + $traits[] = $this->link($this->context->traits[$trait]); + } else { + $traits[] = $trait; // TODO link to php.net + } + } + return implode(', ',$traits); + } + + public function renderSubclasses($class) + { + $subclasses = []; + foreach($class->subclasses as $subclass) { + if(isset($this->context->classes[$subclass])) { + $subclasses[] = $this->link($this->context->classes[$subclass]); + } else { + $subclasses[] = $subclass; // TODO link to php.net + } + } + return implode(', ',$subclasses); + } + + + public function generateFileName($itemName) + { + return strtolower(str_replace('\\', '_', $itemName)) . '.html'; + } + + /** + * Finds the view file corresponding to the specified relative view name. + * @param string $view a relative view name. The name does NOT start with a slash. + * @return string the view file path. Note that the file may not exist. + */ + public function findViewFile($view) + { + return Yii::getAlias('@yii/phpdoc/views/' . $view); + } +} \ No newline at end of file diff --git a/extensions/yii/apidoc/composer.json b/extensions/yii/apidoc/composer.json new file mode 100644 index 0000000..30608a1 --- /dev/null +++ b/extensions/yii/apidoc/composer.json @@ -0,0 +1,29 @@ +{ + "name": "yiisoft/yii2-apidoc", + "description": "API Documentation generator for the Yii framework 2.0", + "keywords": ["yii", "phpdoc", "apidoc", "api", "documentation"], + "type": "yii2-extension", + "license": "BSD-3-Clause", + "support": { + "issues": "https://github.com/yiisoft/yii2/issues?labels=ext%3Aapidoc", + "forum": "http://www.yiiframework.com/forum/", + "wiki": "http://www.yiiframework.com/wiki/", + "irc": "irc://irc.freenode.net/yii", + "source": "https://github.com/yiisoft/yii2" + }, + "authors": [ + { + "name": "Carsten Brandt", + "email": "mail@cebe.cc" + } + ], + "minimum-stability": "dev", + "require": { + "yiisoft/yii2": "*", + "phpdocumentor/reflection": "1.0.2" + }, + "autoload": { + "psr-0": { "yii\\apidoc\\": "" } + }, + "target-dir": "yii/apidoc" +} diff --git a/extensions/yii/apidoc/models/BaseDoc.php b/extensions/yii/apidoc/models/BaseDoc.php new file mode 100644 index 0000000..888d1ac --- /dev/null +++ b/extensions/yii/apidoc/models/BaseDoc.php @@ -0,0 +1,45 @@ +sourcePath=str_replace('\\','/',str_replace(YII_PATH,'',$reflection->getFileName())); + $this->startLine=$reflection->getStartLine(); + $this->endLine=$reflection->getEndLine(); + } + + public function getSourceUrl($baseUrl,$line=null) + { + if($line===null) + return $baseUrl.$this->sourcePath; + else + return $baseUrl.$this->sourcePath.'#'.$line; + } + + public function getSourceCode() + { + $lines=file(YII_PATH.$this->sourcePath); + return implode("",array_slice($lines,$this->startLine-1,$this->endLine-$this->startLine+1)); + } +} \ No newline at end of file diff --git a/extensions/yii/apidoc/models/ClassDoc.php b/extensions/yii/apidoc/models/ClassDoc.php new file mode 100644 index 0000000..3fe7f3d --- /dev/null +++ b/extensions/yii/apidoc/models/ClassDoc.php @@ -0,0 +1,80 @@ +name = ltrim($reflector->getName(), '\\'); + $this->startLine = $reflector->getNode()->getAttribute('startLine'); + $this->endLine = $reflector->getNode()->getAttribute('endLine'); + + $this->parentClass = ltrim($reflector->getParentClass(), '\\'); + if (empty($this->parentClass)) { + $this->parentClass = null; + } + $this->isAbstract = $reflector->isAbstract(); + $this->isFinal = $reflector->isFinal(); + + foreach($reflector->getInterfaces() as $interface) { + $this->interfaces[] = ltrim($interface, '\\'); + } + foreach($reflector->getTraits() as $trait) { + $this->traits[] = ltrim($trait, '\\'); + } + + // TODO methods + + // TODO properties + + // TODO docblock + + if ($context !== null) { + $context->addClass($this); + } + + parent::__construct($config); + } +} \ No newline at end of file diff --git a/extensions/yii/apidoc/models/Context.php b/extensions/yii/apidoc/models/Context.php new file mode 100644 index 0000000..11ece3e --- /dev/null +++ b/extensions/yii/apidoc/models/Context.php @@ -0,0 +1,93 @@ +files[$fileName] = $file; + } + + public function addClass($class) + { + if (isset($this->classes[$class->name])) { + throw new Exception('Duplicate class definition: ' . $class->name . ' in file ' . $class->fileName); + } + $this->classes[$class->name] = $class; + } + + public function addInterface($interface) + { + if (isset($this->interfaces[$interface->name])) { + throw new Exception('Duplicate interface definition: ' . $interface->name . ' in file ' . $interface->fileName); + } + $this->interfaces[$interface->name] = $interface; + } + + public function addTrait($trait) + { + if (isset($this->traits[$trait->name])) { + throw new Exception('Duplicate trait definition: ' . $trait->name . ' in file ' . $trait->fileName); + } + $this->traits[$trait->name] = $trait; + } + + public function updateReferences() + { + // update all subclass references + foreach($this->classes as $class) { + $className = $class->name; + while (isset($this->classes[$class->parentClass])) { + $class = $this->classes[$class->parentClass]; + $class->subclasses[] = $className; + } + } + // update interfaces of subclasses + foreach($this->classes as $class) { + $this->updateSubclassInferfacesTraits($class); + } + // TODO update interface and trait usages + } + + /** + * Add implemented interfaces and used traits to subclasses + * @param ClassDoc $class + */ + protected function updateSubclassInferfacesTraits($class) + { + foreach($class->subclasses as $subclass) { + $subclass = $this->classes[$subclass]; + $subclass->interfaces = array_unique(array_merge($subclass->interfaces, $class->interfaces)); + $subclass->traits = array_unique(array_merge($subclass->traits, $class->traits)); + $this->updateSubclassInferfacesTraits($subclass); + } + } +} \ No newline at end of file diff --git a/extensions/yii/apidoc/models/EventDoc.php b/extensions/yii/apidoc/models/EventDoc.php new file mode 100644 index 0000000..22fedc9 --- /dev/null +++ b/extensions/yii/apidoc/models/EventDoc.php @@ -0,0 +1,15 @@ +name = $fileName; + $this->_reflection = new FileReflector($fileName, true); + $this->_reflection->process(); + + foreach($this->_reflection->getClasses() as $class) { + $class = new ClassDoc($class, $context); + $class->sourceFile = $fileName; + $this->classes[] = $class; + } + foreach($this->_reflection->getInterfaces() as $interface) { + $this->interfaces[] = new InterfaceDoc($interface, $context); + } + foreach($this->_reflection->getTraits() as $trait) { + $this->traits[] = new TraitDoc($trait, $context); + } + + parent::__construct($config); + } +} \ No newline at end of file diff --git a/extensions/yii/apidoc/models/FunctionDoc.php b/extensions/yii/apidoc/models/FunctionDoc.php new file mode 100644 index 0000000..b9cee3b --- /dev/null +++ b/extensions/yii/apidoc/models/FunctionDoc.php @@ -0,0 +1,15 @@ +name = ltrim($reflector->getName(), '\\'); + $this->startLine = $reflector->getNode()->getAttribute('startLine'); + $this->endLine = $reflector->getNode()->getAttribute('endLine'); + + foreach($reflector->getParentInterfaces() as $interface) { + $this->parentInterfaces[] = ltrim($interface, '\\'); + } + + // TODO methods + + // TODO docblock + + if ($context !== null) { + $context->addInterface($this); + } + + parent::__construct($config); + } + +} \ No newline at end of file diff --git a/extensions/yii/apidoc/models/MethodDoc.php b/extensions/yii/apidoc/models/MethodDoc.php new file mode 100644 index 0000000..cd32c86 --- /dev/null +++ b/extensions/yii/apidoc/models/MethodDoc.php @@ -0,0 +1,18 @@ +name = ltrim($reflector->getName(), '\\'); + $this->startLine = $reflector->getNode()->getAttribute('startLine'); + $this->endLine = $reflector->getNode()->getAttribute('endLine'); + + foreach($reflector->getTraits() as $trait) { + $this->traits[] = ltrim($trait, '\\'); + } + + // TODO methods + + // TODO properties + + // TODO docblock + + if ($context !== null) { + $context->addTrait($this); + } + + parent::__construct($config); + } +} \ No newline at end of file diff --git a/extensions/yii/apidoc/views/class.php b/extensions/yii/apidoc/views/class.php new file mode 100644 index 0000000..ffe6063 --- /dev/null +++ b/extensions/yii/apidoc/views/class.php @@ -0,0 +1,49 @@ + +

name; +?>

+ + +render('classSummary', ['item' => $item]); ?> + + +renderPartial('propertySummary',array('class'=>$item,'protected'=>false)); ?> +renderPartial('propertySummary',array('class'=>$item,'protected'=>true)); ?> + + +renderPartial('methodSummary',array('class'=>$item,'protected'=>false)); ?> +renderPartial('methodSummary',array('class'=>$item,'protected'=>true)); ?> + + +renderPartial('eventSummary',array('class'=>$item)); ?> + +renderPartial('propertyDetails',array('class'=>$item)); ?> +renderPartial('methodDetails',array('class'=>$item)); ?> diff --git a/extensions/yii/apidoc/views/classSummary.php b/extensions/yii/apidoc/views/classSummary.php new file mode 100644 index 0000000..1f6ad9a --- /dev/null +++ b/extensions/yii/apidoc/views/classSummary.php @@ -0,0 +1,60 @@ + ++ + + + + + + + + +interfaces)): ?> + + + + + +traits)): ?> + + + + + +subclasses)): ?> + + + + + +since)): ?> + + + + + +version)): ?> + + + + + + + +renderSourceLink($item->sourcePath); ?> + +
Inheritancecontext->renderInheritance($item); ?>
Implementscontext->renderImplements($item); ?>
Uses Traitscontext->renderTraitUses($item); ?>
Subclassescontext->renderSubclasses($item); ?>
Sincesince; ?>
Versionversion; ?>
Source Code
+ +
+description; ?> +
\ No newline at end of file diff --git a/extensions/yii/apidoc/views/index.php b/extensions/yii/apidoc/views/index.php new file mode 100644 index 0000000..c329707 --- /dev/null +++ b/extensions/yii/apidoc/views/index.php @@ -0,0 +1,30 @@ +

Class Reference

+ + ++ + + + + + + +$class): ?> + + + + + +
ClassDescription
context->link($class, $class->name); ?>shortDescription; ?>
diff --git a/extensions/yii/apidoc/views/layouts/offline.php b/extensions/yii/apidoc/views/layouts/offline.php new file mode 100644 index 0000000..809de75 --- /dev/null +++ b/extensions/yii/apidoc/views/layouts/offline.php @@ -0,0 +1,64 @@ +beginPage(); +?> + + + + + + + + +head(); ?> +<?php echo $this->context->pageTitle; ?> + + + +beginBody(); ?> +
+ +
+Yii Framework v Class Reference +
+ +
+ +
+ +
+© 2008-2013 by Yii Software LLC
+All Rights Reserved.
+
+ + + +
+endBody(); ?> + + +endPage(); ?> \ No newline at end of file diff --git a/extensions/yii/phpdoc/.gitignore b/extensions/yii/phpdoc/.gitignore deleted file mode 100644 index 8b7ef35..0000000 --- a/extensions/yii/phpdoc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/vendor -composer.lock diff --git a/extensions/yii/phpdoc/CHANGELOG.md b/extensions/yii/phpdoc/CHANGELOG.md deleted file mode 100644 index b029621..0000000 --- a/extensions/yii/phpdoc/CHANGELOG.md +++ /dev/null @@ -1,7 +0,0 @@ -Yii Framework 2 phpdoc extension Change Log -=========================================== - -2.0.0 beta under development ----------------------------- - -- Initial release. diff --git a/extensions/yii/phpdoc/LICENSE.md b/extensions/yii/phpdoc/LICENSE.md deleted file mode 100644 index e98f03d..0000000 --- a/extensions/yii/phpdoc/LICENSE.md +++ /dev/null @@ -1,32 +0,0 @@ -The Yii framework is free software. It is released under the terms of -the following BSD License. - -Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * Neither the name of Yii Software LLC nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/extensions/yii/phpdoc/README.md b/extensions/yii/phpdoc/README.md deleted file mode 100644 index f0c8087..0000000 --- a/extensions/yii/phpdoc/README.md +++ /dev/null @@ -1,28 +0,0 @@ -API documentation generator for Yii 2 -===================================== - -This extension provides an API documentation generator for the Yii framework 2.0. - -Installation ------------- - -The preferred way to install this extension is through [composer](http://getcomposer.org/download/). - -Either run - -``` -php composer.phar require yiisoft/yii2-phpdoc "*" -``` - -or add - -```json -"yiisoft/yii2-phpdoc": "*" -``` - -to the require section of your composer.json. - -Usage ------ - -TDB \ No newline at end of file diff --git a/extensions/yii/phpdoc/assets/css/api.css b/extensions/yii/phpdoc/assets/css/api.css deleted file mode 100644 index 482c04f..0000000 --- a/extensions/yii/phpdoc/assets/css/api.css +++ /dev/null @@ -1,105 +0,0 @@ -pre { - color: #000000; - background-color: #FFF5E6; - font-family: "courier new", "times new roman", monospace; - line-height: 1.3em; - /* Put a nice border around it. */ - padding: 1px; - width: 90%; - /* Don't wrap its contents, and show scrollbars. */ - /* white-space: nowrap;*/ - overflow: auto; - /* Stop after about 24 lines, and just show a scrollbar. */ - /* max-height: 24em; */ - margin: 5px; - padding-left: 20px; - border: 1px solid #FFE6BF; - border-left: 6px solid #FFE6BF; -} - -div.code { - display: none; - color: #000000; - background-color: #FFF5E6; - font-family: "courier new", "times new roman", monospace; - line-height: 1.3em; - /* Put a nice border around it. */ - padding: 1px; - width: 90%; - /* Don't wrap its contents, and show scrollbars. */ - /* white-space: nowrap;*/ - overflow: auto; - /* Stop after about 24 lines, and just show a scrollbar. */ - /* max-height: 24em; */ - margin: 5px; - padding-left: 20px; - border-left: 6px solid #FFE6BF; -} - -table.summaryTable { - background: #E6ECFF; - border-collapse: collapse; - width: 100%; -} - -table.summaryTable th, table.summaryTable td { - border: 1px #BFCFFF solid; - padding: 0.2em; -} - -table.summaryTable th { - background: #CCD9FF; - text-align: left; -} - -#nav { - padding: 3px; - margin: 0 0 10px 0; - border-top: 1px #BFCFFF solid; -} - -#classDescription { - padding: 5px; - margin: 10px 0 20px 0; - border-bottom: 1px solid #BFCFFF; -} - -.detailHeader { - font-weight: bold; - font-size: 12pt; - margin: 30px 0 5px 0; - border-bottom: 1px solid #BFCFFF; -} - -.detailHeaderTag { - font-weight: normal; - font-size: 10pt; -} - -.signature, .signature2 { - padding: 3px; - color: #000000; - font-family: "courier new", "times new roman", monospace; - line-height: 1.3em; -} - -.signature { - margin: 10px 0 10px 0; - background: #E6ECFF; - border: 1px #BFCFFF solid; -} - -.paramNameCol { - width: 12%; - font-weight: bold; -} - -.paramTypeCol { - width: 12%; -} - -.sourceCode { - margin: 5px 0; - padding:5px; - background:#FFF5E6; -} \ No newline at end of file diff --git a/extensions/yii/phpdoc/assets/css/style.css b/extensions/yii/phpdoc/assets/css/style.css deleted file mode 100644 index 1ead51c..0000000 --- a/extensions/yii/phpdoc/assets/css/style.css +++ /dev/null @@ -1,32 +0,0 @@ -body -{ -} - -body, div, span, p, input -{ - font-family: Verdana, sans-serif, Arial; - font-size: 10pt; - color: #333333; -} - -#apiPage { -} - -#apiHeader { - padding: 3px; - color: white; - background: #6078BF; - margin-bottom: 5px; - font-weight: bold; -} - -#apiHeader a { - color: white; -} - -#apiFooter { - margin-top: 5px; - padding: 3px; - border-top: 1px solid #BFCFFF; - text-align: center; -} diff --git a/extensions/yii/phpdoc/commands/PhpdocController.php b/extensions/yii/phpdoc/commands/PhpdocController.php deleted file mode 100644 index 1bb3e32..0000000 --- a/extensions/yii/phpdoc/commands/PhpdocController.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @author Qiang Xue - * @since 2.0 - */ -class PhpdocController extends Controller -{ - public function actionIndex($targetDir) - { - echo "hi\n"; - - $targetDir = Yii::getAlias($targetDir); - if (is_dir($targetDir) && !$this->confirm('TargetDirectory already exists. Overwrite?')) { - return 2; - } - - // TODO determine files to analyze - $this->stdout('Searching files to process... '); - $files = $this->findFiles(YII_PATH); -// $files = array_slice($files, 0, 42); // TODO remove this line - $this->stdout('done.' . PHP_EOL, Console::FG_GREEN); - - $fileCount = count($files); - Console::startProgress(0, $fileCount, 'Processing files... ', false); - $context = new Context(); - $done = 0; - foreach($files as $file) { - $context->addFile($file); - Console::updateProgress(++$done, $fileCount); - } - Console::endProgress(true); - $this->stdout('done.' . PHP_EOL, Console::FG_GREEN); - - $this->stdout('Updating cross references and backlinks... '); - $context->updateReferences(); - $this->stdout('done.' . PHP_EOL, Console::FG_GREEN); - - - // TODO LATER analyze for dead links and similar stuff - - // TODO render models - $renderer = new OfflineRenderer(); - $renderer->targetDir = $targetDir; - $renderer->render($context, $this); - } - - - protected function findFiles($path, $except = []) - { - $path = FileHelper::normalizePath($path); - $options = [ - 'filter' => function ($path) { - if (is_file($path)) { - $file = basename($path); - if ($file[0] < 'A' || $file[0] > 'Z') { - return false; - } - } - return null; - }, - 'only' => ['.php'], - 'except' => array_merge($except, [ - '/views/', - '/requirements/', - '/gii/generators/', - ]), - ]; - return FileHelper::findFiles($path, $options); - } - -} \ No newline at end of file diff --git a/extensions/yii/phpdoc/components/BaseRenderer.php b/extensions/yii/phpdoc/components/BaseRenderer.php deleted file mode 100644 index 86e93b2..0000000 --- a/extensions/yii/phpdoc/components/BaseRenderer.php +++ /dev/null @@ -1,38 +0,0 @@ - - */ - -namespace yii\phpdoc\components; - - -use Yii; -use yii\base\Component; -use yii\console\Controller; -use yii\phpdoc\models\Context; -use yii\web\View; - -abstract class BaseRenderer extends Component -{ - - private $_view; - - - public function getView() - { - if ($this->_view === null) { - $this->_view = new View(); - } - return $this->_view; - } - - /** - * @param Context $context - * @param Controller $controller - * @return mixed - */ - public abstract function render($context, $controller); - -} \ No newline at end of file diff --git a/extensions/yii/phpdoc/components/OfflineRenderer.php b/extensions/yii/phpdoc/components/OfflineRenderer.php deleted file mode 100644 index 1d02de0..0000000 --- a/extensions/yii/phpdoc/components/OfflineRenderer.php +++ /dev/null @@ -1,182 +0,0 @@ - - */ - -namespace yii\phpdoc\components; - - -use yii\base\ViewContextInterface; -use yii\console\Controller; -use yii\helpers\Console; -use yii\helpers\FileHelper; -use yii\helpers\Html; -use yii\phpdoc\models\ClassDoc; -use yii\phpdoc\models\Context; -use Yii; -use yii\phpdoc\models\InterfaceDoc; -use yii\phpdoc\models\TraitDoc; - -class OfflineRenderer extends BaseRenderer implements ViewContextInterface -{ - public $targetDir; - - public $layout = '@yii/phpdoc/views/layouts/offline.php'; - public $itemView = '@yii/phpdoc/views/class.php'; - public $indexView = '@yii/phpdoc/views/index.php'; - - public $pageTitle = 'Yii Framework 2.0 API Documentation'; - - /** - * @var Context - */ - protected $context; - - /** - * @param Context $context - * @param Controller $controller - */ - public function render($context, $controller) - { - $this->context = $context; - $dir = Yii::getAlias($this->targetDir); - if (!is_dir($dir)) { - mkdir($dir); - } - - $items = array_merge($context->classes, $context->interfaces, $context->traits); - $itemCount = count($items) + 1; - Console::startProgress(0, $itemCount, 'Rendering files: ', false); - $done = 0; - foreach($items as $item) { - $fileContent = $this->renderWithLayout($this->itemView, [ - 'item' => $item, - 'docContext' => $context, - ]); - file_put_contents($dir . '/' . $this->generateFileName($item->name), $fileContent); - Console::updateProgress(++$done, $itemCount); - } - $indexFileContent = $this->renderWithLayout($this->indexView, [ - 'docContext' => $context, - 'items' => $items, - ]); - file_put_contents($dir . '/index.html', $indexFileContent); - Console::updateProgress(++$done, $itemCount); - Console::endProgress(true); - $controller->stdout('done.' . PHP_EOL, Console::FG_GREEN); - - $controller->stdout('Copying asset files... '); - FileHelper::copyDirectory(__DIR__ . '/../assets/css', $dir . '/css'); - $controller->stdout('done.' . PHP_EOL, Console::FG_GREEN); - - } - - protected function renderWithLayout($viewFile, $params) - { - $output = $this->getView()->render($viewFile, $params, $this); - if ($this->layout !== false) { - $params['content'] = $output; - return $this->getView()->renderFile($this->layout, $params, $this); - } else { - return $output; - } - } - - /** - * creates a link to an item - * @param ClassDoc|InterfaceDoc|TraitDoc $item - * @param string $title - * @return string - */ - public function link($item, $title = null) - { - if ($title === null) { - $title = $item->name; - } - return Html::a($title, null, ['href' => $this->generateFileName($item->name)]); - } - - /** - * @param ClassDoc $class - * @return string - */ - public function renderInheritance($class) - { - $parents[] = $this->link($class); - while ($class->parentClass !== null) { - if(isset($this->context->classes[$class->parentClass])) { - $class = $this->context->classes[$class->parentClass]; - $parents[] = $this->link($class); - } else { - $parents[] = $class->parentClass; // TODO link to php.net - break; - } - } - return implode(" »\n",$parents); - } - - /** - * @param ClassDoc $class - * @return string - */ - public function renderImplements($class) - { - $interfaces = []; - foreach($class->interfaces as $interface) { - if(isset($this->context->interfaces[$interface])) { - $interfaces[] = $this->link($this->context->interfaces[$interface]); - } else { - $interfaces[] = $interface; // TODO link to php.net - } - } - return implode(', ',$interfaces); - } - - /** - * @param ClassDoc|TraitDoc $class - * @return string - */ - public function renderTraitUses($class) - { - $traits = []; - foreach($class->traits as $trait) { - if(isset($this->context->traits[$trait])) { - $traits[] = $this->link($this->context->traits[$trait]); - } else { - $traits[] = $trait; // TODO link to php.net - } - } - return implode(', ',$traits); - } - - public function renderSubclasses($class) - { - $subclasses = []; - foreach($class->subclasses as $subclass) { - if(isset($this->context->classes[$subclass])) { - $subclasses[] = $this->link($this->context->classes[$subclass]); - } else { - $subclasses[] = $subclass; // TODO link to php.net - } - } - return implode(', ',$subclasses); - } - - - public function generateFileName($itemName) - { - return strtolower(str_replace('\\', '_', $itemName)) . '.html'; - } - - /** - * Finds the view file corresponding to the specified relative view name. - * @param string $view a relative view name. The name does NOT start with a slash. - * @return string the view file path. Note that the file may not exist. - */ - public function findViewFile($view) - { - return Yii::getAlias('@yii/phpdoc/views/' . $view); - } -} \ No newline at end of file diff --git a/extensions/yii/phpdoc/composer.json b/extensions/yii/phpdoc/composer.json deleted file mode 100644 index 7fa2dde..0000000 --- a/extensions/yii/phpdoc/composer.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "yiisoft/yii2-phpdoc", - "description": "PHP Documentation generator for the Yii framework 2.0", - "keywords": ["yii", "phpdoc", "api", "documentation"], - "type": "yii2-extension", - "license": "BSD-3-Clause", - "support": { - "issues": "https://github.com/yiisoft/yii2/issues?labels=ext%3Aredis", - "forum": "http://www.yiiframework.com/forum/", - "wiki": "http://www.yiiframework.com/wiki/", - "irc": "irc://irc.freenode.net/yii", - "source": "https://github.com/yiisoft/yii2" - }, - "authors": [ - { - "name": "Carsten Brandt", - "email": "mail@cebe.cc" - } - ], - "minimum-stability": "dev", - "require": { - "yiisoft/yii2": "*", - "phpdocumentor/reflection": "1.0.2" - }, - "autoload": { - "psr-0": { "yii\\redis\\": "" } - }, - "target-dir": "yii/redis" -} diff --git a/extensions/yii/phpdoc/models/BaseDoc.php b/extensions/yii/phpdoc/models/BaseDoc.php deleted file mode 100644 index cbdf270..0000000 --- a/extensions/yii/phpdoc/models/BaseDoc.php +++ /dev/null @@ -1,40 +0,0 @@ -sourcePath=str_replace('\\','/',str_replace(YII_PATH,'',$reflection->getFileName())); - $this->startLine=$reflection->getStartLine(); - $this->endLine=$reflection->getEndLine(); - } - - public function getSourceUrl($baseUrl,$line=null) - { - if($line===null) - return $baseUrl.$this->sourcePath; - else - return $baseUrl.$this->sourcePath.'#'.$line; - } - - public function getSourceCode() - { - $lines=file(YII_PATH.$this->sourcePath); - return implode("",array_slice($lines,$this->startLine-1,$this->endLine-$this->startLine+1)); - } -} \ No newline at end of file diff --git a/extensions/yii/phpdoc/models/ClassDoc.php b/extensions/yii/phpdoc/models/ClassDoc.php deleted file mode 100644 index dd51bb5..0000000 --- a/extensions/yii/phpdoc/models/ClassDoc.php +++ /dev/null @@ -1,75 +0,0 @@ -name = ltrim($reflector->getName(), '\\'); - $this->startLine = $reflector->getNode()->getAttribute('startLine'); - $this->endLine = $reflector->getNode()->getAttribute('endLine'); - - $this->parentClass = ltrim($reflector->getParentClass(), '\\'); - if (empty($this->parentClass)) { - $this->parentClass = null; - } - $this->isAbstract = $reflector->isAbstract(); - $this->isFinal = $reflector->isFinal(); - - foreach($reflector->getInterfaces() as $interface) { - $this->interfaces[] = ltrim($interface, '\\'); - } - foreach($reflector->getTraits() as $trait) { - $this->traits[] = ltrim($trait, '\\'); - } - - // TODO methods - - // TODO properties - - // TODO docblock - - if ($context !== null) { - $context->addClass($this); - } - - parent::__construct($config); - } -} \ No newline at end of file diff --git a/extensions/yii/phpdoc/models/Context.php b/extensions/yii/phpdoc/models/Context.php deleted file mode 100644 index 78d455d..0000000 --- a/extensions/yii/phpdoc/models/Context.php +++ /dev/null @@ -1,93 +0,0 @@ - - */ - -namespace yii\phpdoc\models; - - -use yii\base\Component; -use yii\base\Exception; - -class Context extends Component -{ - public $basePath; - - public $files = []; - - /** - * @var ClassDoc[] - */ - public $classes = []; - /** - * @var InterfaceDoc[] - */ - public $interfaces = []; - /** - * @var TraitDoc[] - */ - public $traits = []; - - public function addFile($fileName) - { - $file = new File($fileName, $this); - $this->files[$fileName] = $file; - } - - public function addClass($class) - { - if (isset($this->classes[$class->name])) { - throw new Exception('Duplicate class definition: ' . $class->name . ' in file ' . $class->fileName); - } - $this->classes[$class->name] = $class; - } - - public function addInterface($interface) - { - if (isset($this->interfaces[$interface->name])) { - throw new Exception('Duplicate interface definition: ' . $interface->name . ' in file ' . $interface->fileName); - } - $this->interfaces[$interface->name] = $interface; - } - - public function addTrait($trait) - { - if (isset($this->traits[$trait->name])) { - throw new Exception('Duplicate trait definition: ' . $trait->name . ' in file ' . $trait->fileName); - } - $this->traits[$trait->name] = $trait; - } - - public function updateReferences() - { - // update all subclass references - foreach($this->classes as $class) { - $className = $class->name; - while (isset($this->classes[$class->parentClass])) { - $class = $this->classes[$class->parentClass]; - $class->subclasses[] = $className; - } - } - // update interfaces of subclasses - foreach($this->classes as $class) { - $this->updateSubclassInferfacesTraits($class); - } - // TODO update interface and trait usages - } - - /** - * Add implemented interfaces and used traits to subclasses - * @param ClassDoc $class - */ - protected function updateSubclassInferfacesTraits($class) - { - foreach($class->subclasses as $subclass) { - $subclass = $this->classes[$subclass]; - $subclass->interfaces = array_unique(array_merge($subclass->interfaces, $class->interfaces)); - $subclass->traits = array_unique(array_merge($subclass->traits, $class->traits)); - $this->updateSubclassInferfacesTraits($subclass); - } - } -} \ No newline at end of file diff --git a/extensions/yii/phpdoc/models/EventDoc.php b/extensions/yii/phpdoc/models/EventDoc.php deleted file mode 100644 index 2ce7ad1..0000000 --- a/extensions/yii/phpdoc/models/EventDoc.php +++ /dev/null @@ -1,10 +0,0 @@ -name = $fileName; - $this->_reflection = new FileReflector($fileName, true); - $this->_reflection->process(); - - foreach($this->_reflection->getClasses() as $class) { - $class = new ClassDoc($class, $context); - $class->sourceFile = $fileName; - $this->classes[] = $class; - } - foreach($this->_reflection->getInterfaces() as $interface) { - $this->interfaces[] = new InterfaceDoc($interface, $context); - } - foreach($this->_reflection->getTraits() as $trait) { - $this->traits[] = new TraitDoc($trait, $context); - } - - parent::__construct($config); - } -} \ No newline at end of file diff --git a/extensions/yii/phpdoc/models/FunctionDoc.php b/extensions/yii/phpdoc/models/FunctionDoc.php deleted file mode 100644 index add2a00..0000000 --- a/extensions/yii/phpdoc/models/FunctionDoc.php +++ /dev/null @@ -1,10 +0,0 @@ - - */ - -namespace yii\phpdoc\models; - -class InterfaceDoc extends BaseDoc -{ - public $parentInterfaces = []; - - public $implementedBy = []; - - public $methods = []; - - /** - * @param \phpDocumentor\Reflection\InterfaceReflector $reflector - * @param Context $context - * @param array $config - */ - public function __construct($reflector, $context = null, $config = []) - { - // base properties - $this->name = ltrim($reflector->getName(), '\\'); - $this->startLine = $reflector->getNode()->getAttribute('startLine'); - $this->endLine = $reflector->getNode()->getAttribute('endLine'); - - foreach($reflector->getParentInterfaces() as $interface) { - $this->parentInterfaces[] = ltrim($interface, '\\'); - } - - // TODO methods - - // TODO docblock - - if ($context !== null) { - $context->addInterface($this); - } - - parent::__construct($config); - } - -} \ No newline at end of file diff --git a/extensions/yii/phpdoc/models/MethodDoc.php b/extensions/yii/phpdoc/models/MethodDoc.php deleted file mode 100644 index be29aea..0000000 --- a/extensions/yii/phpdoc/models/MethodDoc.php +++ /dev/null @@ -1,13 +0,0 @@ - - */ - -namespace yii\phpdoc\models; - -class ParamDoc -{ - public $name; - public $description; - public $type; - public $isOptional; - public $defaultValue; - public $isPassedByReference; -} \ No newline at end of file diff --git a/extensions/yii/phpdoc/models/PropertyDoc.php b/extensions/yii/phpdoc/models/PropertyDoc.php deleted file mode 100644 index 8ac0287..0000000 --- a/extensions/yii/phpdoc/models/PropertyDoc.php +++ /dev/null @@ -1,23 +0,0 @@ - - */ - -namespace yii\phpdoc\models; - -class PropertyDoc extends BaseDoc -{ - public $isProtected; - public $isStatic; - public $readOnly; - public $isInherited; - public $definedBy; - - public $type; - public $signature; - - public $getter; - public $setter; -} \ No newline at end of file diff --git a/extensions/yii/phpdoc/models/TraitDoc.php b/extensions/yii/phpdoc/models/TraitDoc.php deleted file mode 100644 index 7fc6e5a..0000000 --- a/extensions/yii/phpdoc/models/TraitDoc.php +++ /dev/null @@ -1,49 +0,0 @@ - - */ - -namespace yii\phpdoc\models; - -class TraitDoc extends BaseDoc -{ - // classes using the trait - public $usedByClasses = []; - - public $traits = []; - - public $properties = []; - public $methods = []; - - - /** - * @param \phpDocumentor\Reflection\TraitReflector $reflector - * @param Context $context - * @param array $config - */ - public function __construct($reflector, $context = null, $config = []) - { - // base properties - $this->name = ltrim($reflector->getName(), '\\'); - $this->startLine = $reflector->getNode()->getAttribute('startLine'); - $this->endLine = $reflector->getNode()->getAttribute('endLine'); - - foreach($reflector->getTraits() as $trait) { - $this->traits[] = ltrim($trait, '\\'); - } - - // TODO methods - - // TODO properties - - // TODO docblock - - if ($context !== null) { - $context->addTrait($this); - } - - parent::__construct($config); - } -} \ No newline at end of file diff --git a/extensions/yii/phpdoc/views/class.php b/extensions/yii/phpdoc/views/class.php deleted file mode 100644 index 0af8987..0000000 --- a/extensions/yii/phpdoc/views/class.php +++ /dev/null @@ -1,49 +0,0 @@ - -

name; -?>

- - -render('classSummary', ['item' => $item]); ?> - - -renderPartial('propertySummary',array('class'=>$item,'protected'=>false)); ?> -renderPartial('propertySummary',array('class'=>$item,'protected'=>true)); ?> - - -renderPartial('methodSummary',array('class'=>$item,'protected'=>false)); ?> -renderPartial('methodSummary',array('class'=>$item,'protected'=>true)); ?> - - -renderPartial('eventSummary',array('class'=>$item)); ?> - -renderPartial('propertyDetails',array('class'=>$item)); ?> -renderPartial('methodDetails',array('class'=>$item)); ?> diff --git a/extensions/yii/phpdoc/views/classSummary.php b/extensions/yii/phpdoc/views/classSummary.php deleted file mode 100644 index ca84167..0000000 --- a/extensions/yii/phpdoc/views/classSummary.php +++ /dev/null @@ -1,60 +0,0 @@ - -- - - - - - - - - -interfaces)): ?> - - - - - -traits)): ?> - - - - - -subclasses)): ?> - - - - - -since)): ?> - - - - - -version)): ?> - - - - - - - -renderSourceLink($item->sourcePath); ?> - -
Inheritancecontext->renderInheritance($item); ?>
Implementscontext->renderImplements($item); ?>
Uses Traitscontext->renderTraitUses($item); ?>
Subclassescontext->renderSubclasses($item); ?>
Sincesince; ?>
Versionversion; ?>
Source Code
- -
-description; ?> -
\ No newline at end of file diff --git a/extensions/yii/phpdoc/views/index.php b/extensions/yii/phpdoc/views/index.php deleted file mode 100644 index 1e81798..0000000 --- a/extensions/yii/phpdoc/views/index.php +++ /dev/null @@ -1,30 +0,0 @@ -

Class Reference

- - -- - - - - - - -$class): ?> - - - - - -
ClassDescription
context->link($class, $class->name); ?>shortDescription; ?>
diff --git a/extensions/yii/phpdoc/views/layouts/offline.php b/extensions/yii/phpdoc/views/layouts/offline.php deleted file mode 100644 index 809de75..0000000 --- a/extensions/yii/phpdoc/views/layouts/offline.php +++ /dev/null @@ -1,64 +0,0 @@ -beginPage(); -?> - - - - - - - - -head(); ?> -<?php echo $this->context->pageTitle; ?> - - - -beginBody(); ?> -
- -
-Yii Framework v Class Reference -
- -
- -
- -
-© 2008-2013 by Yii Software LLC
-All Rights Reserved.
-
- - - -
-endBody(); ?> - - -endPage(); ?> \ No newline at end of file