Example #1
0
 /**
  * Converts the input files into one or more output files in the intended format.
  *
  * This method reads the files, converts them into the correct format and returns the contents of the conversion.
  *
  * The template is provided using the $template parameter and is used to decorate the individual files. It can be
  * obtained using the `\phpDocumentor\Plugin\Scrybe\Template\Factory` class.
  *
  * @param TemplateInterface $template
  *
  * @see manual://internals#build_cycle for more information regarding the build process.
  *
  * @return string[]|null The contents of the resulting file(s) or null if the files are written directly to file.
  */
 protected function create(TemplateInterface $template)
 {
     $result = array();
     /** @var File $file */
     foreach ($this->fileset as $file) {
         $rst = new Document($this, $file);
         $destination = $this->getDestinationFilenameRelativeToProjectRoot($file);
         $this->setDestinationRoot($destination);
         if ($this->getLogger()) {
             $this->getLogger()->info('Parsing file "' . $file->getRealPath() . '"');
         }
         try {
             $xhtml_document = $rst->getAsXhtml();
             $converted_contents = $template->decorate($xhtml_document->save(), $this->options);
             $rst->logStats(null, $this->getLogger());
         } catch (\Exception $e) {
             $rst->logStats($e, $this->getLogger());
             continue;
         }
         $result[$destination] = $converted_contents;
     }
     return $result;
 }
 /**
  * Adds the assets of the template to the Assets manager.
  *
  * @param TemplateInterface $template
  *
  * @return void
  */
 protected function addTemplateAssets($template)
 {
     /** @var SplFileInfo $file_info */
     foreach ($template->getAssets() as $filename => $file_info) {
         $this->assets->set($filename, $file_info->getRelativePathname());
     }
 }