Exemple #1
0
 /**
  * Render the reference
  *
  * @return string
  */
 public function render()
 {
     $descriptor = new Descriptor();
     $lines = ['.. header::', '', '   .. image:: ../res/logo/logo.png', '      :width: 200 px', '      :alt: Kite', '', '****************************', 'Kite: Make your projects fly', '****************************', '', '===========================', 'Task and Workflow reference', '===========================', '', '.. sidebar:: Navigation', '', '   `Back to manual <../README.rst>`_', '', '   .. contents::', '      :depth: 2', ''];
     $commonVars = $this->getCommonVariables();
     $lines[] = 'Common options';
     $lines[] = '==============';
     $lines[] = 'The following options are available on the most tasks and workflows (unless they deactivated them):';
     $lines[] = '';
     $this->renderVariables($lines, $commonVars, 'common');
     foreach (['task', 'workflow'] as $type) {
         $lines[] = '';
         $lines[] = ucfirst($type) . 's';
         $lines[] = str_repeat('=', strlen($type) + 1);
         $lines[] = '';
         $taskObjects = $this->loadTaskObjects($type);
         foreach ($taskObjects as $name => $taskObject) {
             if ($taskObject instanceof self) {
                 continue;
             }
             $lines[] = '';
             $lines[] = $name;
             $lines[] = str_repeat('-', strlen($name));
             $lines[] = '';
             $lines[] = str_replace("\n", "\n\n", $descriptor->describeTask($taskObject));
             $lines[] = '';
             $variableConfig = $taskObject->get('_variableConfiguration');
             $taskVariables = [];
             $taskCommonVariables = [];
             foreach ($variableConfig as $configName => $config) {
                 if (is_array($config)) {
                     if (array_key_exists($configName, $commonVars) && $commonVars[$configName] === $config) {
                         $taskCommonVariables[] = $configName;
                     } else {
                         $taskVariables[$configName] = $config;
                     }
                 }
             }
             if ($taskVariables) {
                 $lines[] = 'Options';
                 $lines[] = '```````';
                 $lines[] = '';
                 $this->renderVariables($lines, $taskVariables, $type . '-' . $name);
             }
             if ($taskCommonVariables) {
                 $lines[] = 'Common options';
                 $lines[] = '``````````````';
                 $links = [];
                 foreach ($taskCommonVariables as $configName) {
                     $links[] = "|common-{$configName}|_";
                 }
                 $lines[] = implode(', ', $links);
                 $lines[] = '';
             }
         }
     }
     return implode("\n", $lines);
 }
Exemple #2
0
 /**
  * Get the description
  *
  * @return string
  */
 public function getDescription()
 {
     $description = parent::getDescription();
     if ($description === null) {
         $descriptor = new Descriptor();
         $description = (string) $descriptor->describeTask($this->getJob());
         parent::setDescription($description);
     }
     return $description;
 }