コード例 #1
0
 /**
  * @covers phpDocumentor\Command\Command::getProgressBar
  */
 public function testIfProgressBarIsNotReturnedWhenDisabledAsOption()
 {
     // Arrange
     $loggerHelperMock = m::mock('Symfony\\Component\\Console\\Helper\\HelperInterface');
     $loggerHelperMock->shouldReceive('getName')->andReturn('phpdocumentor_logger');
     $loggerHelperMock->shouldIgnoreMissing();
     $progressBarHelperMock = m::mock('Symfony\\Component\\Console\\Helper\\HelperInterface');
     $progressBarHelperMock->shouldReceive('getName')->andReturn('progress');
     $progressBarHelperMock->shouldIgnoreMissing();
     $this->fixture->setHelperSet(new HelperSet(array('progress' => $progressBarHelperMock, 'phpdocumentor_logger' => $loggerHelperMock)));
     $inputInterface = m::mock('Symfony\\Component\\Console\\Input\\InputInterface');
     $inputInterface->shouldReceive('getOption')->with('progressbar')->andReturn(false);
     $r = new \ReflectionObject($this->fixture);
     $m = $r->getMethod('getProgressBar');
     $m->setAccessible(true);
     // Act
     $result = $m->invoke($this->fixture, $inputInterface);
     // Assert
     $this->assertNull($result);
 }
コード例 #2
0
    /**
     * Initializes this command and sets the name, description, options and
     * arguments.
     *
     * @return void
     */
    protected function configure()
    {
        $this->setName('project:run')->setAliases(array('run'))->setDescription('Parses and transforms the given files to a specified location')->setHelp(<<<HELP
phpDocumentor creates documentation from PHP source files. The simplest way
to use it is:

    <info>\$ phpdoc run -d [directory to parse] -t [output directory]</info>

This will parse every file ending with .php, .php3 and .phtml in <directory
to parse> and then output a HTML site containing easily readable documentation
in <output directory>.

phpDocumentor will try to look for a phpdoc.dist.xml or phpdoc.xml file in your
current working directory and use that to override the default settings if
present. In the configuration file can you specify the same settings (and
more) as the command line provides.

<comment>Other commands</comment>
In addition to this command phpDocumentor also supports additional commands:

<comment>Available commands:</comment>
<info>  help
  list
  parse
  run
  transform
<comment>project</comment>
  project:parse
  project:run
  project:transform
<comment>template</comment>
  template:generate
  template:list
  template:package</info>

You can get a more detailed listing of the commands using the <info>list</info>
command and get help by prepending the word <info>help</info> to the command
name.
HELP
)->addOption('target', 't', InputOption::VALUE_OPTIONAL, 'Path where to store the generated output')->addOption('cache-folder', null, InputOption::VALUE_OPTIONAL, 'Path where to store the cache files')->addOption('filename', 'f', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of files to parse. The wildcards ? and * are supported')->addOption('directory', 'd', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of directories to (recursively) parse')->addOption('encoding', null, InputOption::VALUE_OPTIONAL, 'encoding to be used to interpret source files with')->addOption('extensions', 'e', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of extensions to parse, defaults to php, php3 and phtml')->addOption('ignore', 'i', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of file(s) and directories (relative to the source-code directory) that will be ' . 'ignored. Wildcards * and ? are supported')->addOption('ignore-tags', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of tags that will be ignored, defaults to none. package, subpackage and ignore ' . 'may not be ignored.')->addOption('hidden', null, InputOption::VALUE_NONE, 'Use this option to tell phpDocumentor to parse files and directories that begin with a period (.), ' . 'by default these are ignored')->addOption('ignore-symlinks', null, InputOption::VALUE_NONE, 'Ignore symlinks to other files or directories, default is on')->addOption('markers', 'm', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of markers/tags to filter')->addOption('title', null, InputOption::VALUE_OPTIONAL, 'Sets the title for this project; default is the phpDocumentor logo')->addOption('force', null, InputOption::VALUE_NONE, 'Forces a full build of the documentation, does not increment existing documentation')->addOption('validate', null, InputOption::VALUE_NONE, 'Validates every processed file using PHP Lint, costs a lot of performance')->addOption('visibility', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Specifies the parse visibility that should be displayed in the documentation (comma separated e.g. ' . '"public,protected")')->addOption('defaultpackagename', null, InputOption::VALUE_OPTIONAL, 'Name to use for the default package.', 'Default')->addOption('sourcecode', null, InputOption::VALUE_NONE, 'Whether to include syntax highlighted source code')->addOption('progressbar', 'p', InputOption::VALUE_NONE, 'Whether to show a progress bar; will automatically quiet logging to stdout')->addOption('template', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Name of the template to use (optional)')->addOption('parseprivate', null, InputOption::VALUE_NONE, 'Whether to parse DocBlocks marked with @internal tag');
        parent::configure();
    }
コード例 #3
0
 /**
  * Adds the transformer.transformation.post event to advance the progressbar.
  *
  * @param InputInterface $input
  *
  * @return HelperInterface|null
  */
 protected function getProgressBar(InputInterface $input)
 {
     $progress = parent::getProgressBar($input);
     if (!$progress) {
         return null;
     }
     /** @var Dispatcher $eventDispatcher */
     $eventDispatcher = $this->getService('event_dispatcher');
     $eventDispatcher->addListener('transformer.transformation.post', function () use($progress) {
         $progress->advance();
     });
     return $progress;
 }
コード例 #4
0
ファイル: ParseCommand.php プロジェクト: kminh/phpDocumentor2
 /**
  * Adds the parser.file.pre event to the advance the progressbar.
  *
  * @param InputInterface $input
  *
  * @return \Symfony\Component\Console\Helper\HelperInterface|null
  */
 protected function getProgressBar(InputInterface $input)
 {
     $progress = parent::getProgressBar($input);
     if (!$progress) {
         return null;
     }
     $this->getService('event_dispatcher')->addListener('parser.file.pre', function (PreFileEvent $event) use($progress) {
         $progress->advance();
     });
     return $progress;
 }
コード例 #5
0
 /**
  * Initializes this command with a template and converter factory.
  *
  * @param string           $name
  * @param Factory          $templateFactory
  * @param ConverterFactory $converterFactory
  */
 public function __construct($name, Factory $templateFactory, ConverterFactory $converterFactory)
 {
     parent::__construct($name);
     $this->templateFactory = $templateFactory;
     $this->converterFactory = $converterFactory;
 }
コード例 #6
0
 /**
  * Logs an event with the output.
  *
  * This method will also colorize the message based on priority and withhold
  * certain logging in case of verbosity or not.
  *
  * @param OutputInterface $output
  * @param LogEvent        $event
  * @param Command         $command
  *
  * @return void
  */
 public function logEvent(OutputInterface $output, LogEvent $event, Command $command)
 {
     $numericErrors = array(LogLevel::DEBUG => 0, LogLevel::NOTICE => 1, LogLevel::INFO => 2, LogLevel::WARNING => 3, LogLevel::ERROR => 4, LogLevel::ALERT => 5, LogLevel::CRITICAL => 6, LogLevel::EMERGENCY => 7);
     $threshold = LogLevel::ERROR;
     if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) {
         $threshold = LogLevel::DEBUG;
     }
     if ($numericErrors[$event->getPriority()] >= $numericErrors[$threshold]) {
         /** @var Translator $translator  */
         $translator = $command->getContainer()->offsetGet('translator');
         $message = vsprintf($translator->translate($event->getMessage()), $event->getContext());
         switch ($event->getPriority()) {
             case LogLevel::WARNING:
                 $message = '<comment>' . $message . '</comment>';
                 break;
             case LogLevel::EMERGENCY:
             case LogLevel::ALERT:
             case LogLevel::CRITICAL:
             case LogLevel::ERROR:
                 $message = '<error>' . $message . '</error>';
                 break;
         }
         $output->writeln('  ' . $message);
     }
 }