Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

MarkdownDescriptor.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 4.51 KiB


001  <?php
002   
003  /*
004   * This file is part of the Symfony package.
005   *
006   * (c) Fabien Potencier <fabien@symfony.com>
007   *
008   * For the full copyright and license information, please view the LICENSE
009   * file that was distributed with this source code.
010   */
011   
012  namespace Symfony\Component\Console\Descriptor;
013   
014  use Symfony\Component\Console\Application;
015  use Symfony\Component\Console\Command\Command;
016  use Symfony\Component\Console\Input\InputArgument;
017  use Symfony\Component\Console\Input\InputDefinition;
018  use Symfony\Component\Console\Input\InputOption;
019   
020  /**
021   * Markdown descriptor.
022   *
023   * @author Jean-François Simon <contact@jfsimon.fr>
024   */
025  class MarkdownDescriptor extends Descriptor
026  {
027      /**
028       * {@inheritdoc}
029       */
030      protected function describeInputArgument(InputArgument $argument, array $options = array())
031      {
032          return '**'.$argument->getName().':**'."\n\n"
033              .'* Name: '.($argument->getName() ?: '<none>')."\n"
034              .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
035              .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
036              .'* Description: '.($argument->getDescription() ?: '<none>')."\n"
037              .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`';
038      }
039   
040      /**
041       * {@inheritdoc}
042       */
043      protected function describeInputOption(InputOption $option, array $options = array())
044      {
045          return '**'.$option->getName().':**'."\n\n"
046              .'* Name: `--'.$option->getName().'`'."\n"
047              .'* Shortcut: '.($option->getShortcut() ? '`-'.implode('|-', explode('|', $option->getShortcut())).'`' : '<none>')."\n"
048              .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
049              .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
050              .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
051              .'* Description: '.($option->getDescription() ?: '<none>')."\n"
052              .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`';
053      }
054   
055      /**
056       * {@inheritdoc}
057       */
058      protected function describeInputDefinition(InputDefinition $definition, array $options = array())
059      {
060          $blocks = array();
061   
062          if (count($definition->getArguments()) > 0) {
063              $blocks[] = '### Arguments:';
064              foreach ($definition->getArguments() as $argument) {
065                  $blocks[] = $this->describeInputArgument($argument);
066              }
067          }
068   
069          if (count($definition->getOptions()) > 0) {
070              $blocks[] = '### Options:';
071              foreach ($definition->getOptions() as $option) {
072                  $blocks[] = $this->describeInputOption($option);
073              }
074          }
075   
076          return implode("\n\n", $blocks);
077      }
078   
079      /**
080       * {@inheritdoc}
081       */
082      protected function describeCommand(Command $command, array $options = array())
083      {
084          $command->getSynopsis();
085          $command->mergeApplicationDefinition(false);
086   
087          $markdown = $command->getName()."\n"
088              .str_repeat('-', strlen($command->getName()))."\n\n"
089              .'* Description: '.($command->getDescription() ?: '<none>')."\n"
090              .'* Usage: `'.$command->getSynopsis().'`'."\n"
091              .'* Aliases: '.(count($command->getAliases()) ? '`'.implode('`, `', $command->getAliases()).'`' : '<none>');
092   
093          if ($help = $command->getProcessedHelp()) {
094              $markdown .= "\n\n".$help;
095          }
096   
097          if ($definitionMarkdown = $this->describeInputDefinition($command->getNativeDefinition())) {
098              $markdown .= "\n\n".$definitionMarkdown;
099          }
100   
101          return $markdown;
102      }
103   
104      /**
105       * {@inheritdoc}
106       */
107      protected function describeApplication(Application $application, array $options = array())
108      {
109          $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
110          $description = new ApplicationDescription($application, $describedNamespace);
111          $blocks = array($application->getName()."\n".str_repeat('=', strlen($application->getName())));
112   
113          foreach ($description->getNamespaces() as $namespace) {
114              if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
115                  $blocks[] = '**'.$namespace['id'].':**';
116              }
117   
118              $blocks[] = implode("\n", array_map(function ($commandName) {
119                  return '* '.$commandName;
120              } , $namespace['commands']));
121          }
122   
123          foreach ($description->getCommands() as $command) {
124              $blocks[] = $this->describeCommand($command);
125          }
126   
127          return implode("\n\n", $blocks);
128      }
129  }
130