/**
  * Sets up test case
  *
  */
 public function setUp()
 {
     $root = new RootDoc();
     $root->addSourceLoader($this->getClass()->getClassLoader());
     $this->holder = new Doc();
     $this->holder->setRoot($root);
 }
Exemplo n.º 2
0
 /**
  * Runner method
  *
  */
 public static function main(array $args)
 {
     // Show command usage if invoked without arguments
     if (!$args) {
         exit(self::usage(XPClass::forName(xp::nameOf(__CLASS__))));
     }
     $root = new RootDoc();
     for ($i = 0, $s = sizeof($args); $i < $s; $i++) {
         if ('-sp' === $args[$i]) {
             $root->setSourcePath(explode(PATH_SEPARATOR, $args[++$i]));
         } else {
             if ('-cp' === $args[$i]) {
                 foreach (explode(PATH_SEPARATOR, $args[++$i]) as $element) {
                     $root->addSourcePath(ClassLoader::registerPath($element, NULL)->path);
                 }
             } else {
                 try {
                     $class = XPClass::forName($args[$i]);
                 } catch (ClassNotFoundException $e) {
                     Console::$err->writeLine('*** ', $e->getMessage());
                     exit(2);
                 }
                 if (!$class->isSubclassOf('text.doclet.Doclet')) {
                     Console::$err->writeLine('*** ', $class, ' is not a doclet');
                     exit(2);
                 }
                 $doclet = $class->newInstance();
                 $params = new ParamString(array_slice($args, $i));
                 // Show doclet usage if the command line contains "-?" (at any point).
                 if ($params->exists('help', '?')) {
                     self::usage($class);
                     if ($valid = $doclet->validOptions()) {
                         Console::$err->writeLine();
                         Console::$err->writeLine('Options:');
                         foreach ($valid as $name => $value) {
                             Console::$err->writeLine('  * --', $name, OPTION_ONLY == $value ? '' : '=<value>');
                         }
                     }
                     exit(3);
                 }
                 $root->start($doclet, $params);
                 exit(0);
             }
         }
     }
     Console::$err->writeLine('*** No doclet classname given');
     exit(1);
 }
Exemplo n.º 3
0
 /**
  * @param rootDoc rootDoc
  * @param str parent
  */
 function _mergeSuperClassData(RootDoc $rootDoc, $parent = NULL)
 {
     $classes =& $rootDoc->classes();
     foreach ($classes as $name => $class) {
         if ($classes[$name]->superclass() == $parent) {
             $classes[$name]->mergeSuperClassData();
             $this->_mergeSuperClassData($rootDoc, $classes[$name]->name());
         }
     }
 }
 /**
  * Sets up test case
  *
  */
 public function setUp()
 {
     $root = new RootDoc();
     $root->addSourceLoader($this->getClass()->getClassLoader());
     $this->fixture = $root->classNamed($this->getClassName());
 }
Exemplo n.º 5
0
 /** Build the class hierarchy tree which is placed at the top of the page.
  *
  * @param RootDoc rootDoc The root doc
  * @param ClassDoc class Class to generate tree for
  * @param int depth Depth of recursion
  * @return mixed[]
  */
 function _buildTree(RootDoc $rootDoc, ClassDoc $class, $depth = NULL)
 {
     if ($depth === NULL) {
         $start = TRUE;
         $depth = 0;
     } else {
         $start = FALSE;
     }
     $output = '';
     $undefinedClass = FALSE;
     if ($class->superclass()) {
         echo "Class:" . $class->_name . " - Superclass: " . $class->superClass() . PHP_EOL;
         $superclass = $rootDoc->classNamed($class->superclass());
         if ($superclass) {
             $result = $this->_buildTree($rootDoc, $superclass, $depth);
             $output .= $result[0];
             $depth = ++$result[1];
         } else {
             $output .= $class->superclass() . '<br>';
             //$output .= str_repeat('   ', $depth).' └─';
             $output .= str_repeat('   ', $depth) . '&lfloor;&nbsp;';
             $depth++;
             $undefinedClass = TRUE;
         }
     }
     if ($depth > 0 && !$undefinedClass) {
         //$output .= str_repeat('   ', $depth).' └─';
         $output .= str_repeat('   ', $depth) . '&lfloor;&nbsp;';
     }
     if ($start) {
         $output .= '<strong>' . $class->name() . '</strong><br />';
     } else {
         $output .= '<a href="' . str_repeat('../', $this->_depth) . $class->asPath() . '">' . $class->name() . '</a><br>';
     }
     return array($output, $depth);
 }
Exemplo n.º 6
0
<?php

require 'lang.base.php';
uses('text.doclet.RootDoc', 'util.cmd.Console');
$P = new ParamString();
if (!$P->exists('doclet')) {
    die('Parameter "--doclet" is required!');
} else {
    $doclet_name = $P->value('doclet');
    try {
        $Class = XPClass::forName($doclet_name)->newInstance();
        if (!is('Doclet', $Instance)) {
            throw new IllegalArgumentException('Given classname is not a "Doclet" class!');
        }
    } catch (Exception $e) {
        die($e->toString());
    }
    // remove '--doclet' argument and pass the rest to RootDoc
    while (list($key, $val) = each($P->list)) {
        if (0 == strncmp('--doclet', $val, 7)) {
            continue;
        }
        $list[$key] = $val;
    }
    RootDoc::start($Instance, new ParamString($list));
}