/** * Writes documentation to file * * @param [string] $namespace Namespace to which the doc file will pertain * @param [array <string>] $docs Documentation to add to file * @return [boolean] True if write was successful */ function writeDocFile($namespace, $docs) { $filename = TERMINUS_ROOT . '/docs/' . str_replace(array('Terminus\\', '\\'), array('', '/'), $namespace) . '.md'; $rendered_doc = Utils\twigRender('doc.twig', $docs, array('namespace' => $namespace)); file_put_contents($filename, $rendered_doc); return true; }
/** * Takes a command to get help for and processes its internal documentation * * @param CompositeCommand $command The command to offer help for * @return int */ private function showHelp(CompositeCommand $command) { $out = $this->getMarkdown($command); $exit_status = 0; if (Terminus::getConfig('format') == 'json') { $this->output()->outputRecord($out); } else { $rendered_help = Utils\twigRender('man.twig', $out, array('recursive' => $this->recursive)); if (Terminus::getConfig('format') == 'normal') { $exit_status = $this->passThroughPager($rendered_help); } else { $this->output()->outputRecord($rendered_help); } } return $exit_status; }
public function testTwigRender() { $template_name = 'man.twig'; $rendered_template = Utils\twigRender($template_name, [], []); $this->assertTrue(strpos($rendered_template, '##NAME') === 0); }