templates/html/GuideRenderer.php
public function render($files, $targetDir)
    {
        $this->_targetDir = $targetDir;

        $fileCount = count($files) + 1;
        if ($this->controller !== null) {
            Console::startProgress(0, $fileCount, 'Rendering markdown files: ', false);
        }
        $done = 0;
        $fileData = [];
        $chapters = $this->loadGuideStructure($files);
        foreach ($files as $file) {
            $fileData[$file] = file_get_contents($file);
            if (basename($file) == 'README.md') {
                continue; // to not add index file to nav
            }
        }

        foreach ($fileData as $file => $content) {
            $output = ApiMarkdown::process($content); // TODO generate links to yiiframework.com by default
            $output = $this->afterMarkdownProcess($file, $output, Markdown::$flavors['api']);
            if ($this->layout !== false) {
                $params = [
                    'chapters' => $chapters,
                    'currentFile' => $file,
                    'content' => $output,
                ];
                $output = $this->getView()->renderFile($this->layout, $params, $this);
            }
            $fileName = $this->generateGuideFileName($file);
            file_put_contents($targetDir . '/' . $fileName, $output);

            if ($this->controller !== null) {
                Console::updateProgress(++$done, $fileCount);
            }
        }
        if ($this->controller !== null) {
            Console::updateProgress(++$done, $fileCount);
            Console::endProgress(true);
            $this->controller->stdout('done.' . PHP_EOL, Console::FG_GREEN);
        }
    }
public function render($files, $targetDir)
    {
        $this->_targetDir = $targetDir;

        $fileCount = count($files) + 1;
        if ($this->controller !== null) {
            Console::startProgress(0, $fileCount, 'Rendering markdown files: ', false);
        }
        $done = 0;
        $fileData = [];
        $chapters = $this->loadGuideStructure($files);
        foreach ($files as $file) {
            $fileData[$file] = file_get_contents($file);
            if (basename($file) == 'README.md') {
                continue; // to not add index file to nav
            }
        }

        foreach ($fileData as $file => $content) {
            $output = ApiMarkdown::process($content); // TODO generate links to yiiframework.com by default
            $output = $this->afterMarkdownProcess($file, $output, Markdown::$flavors['api']);
            if ($this->layout !== false) {
                $params = [
                    'chapters' => $chapters,
                    'currentFile' => $file,
                    'content' => $output,
                ];
                $output = $this->getView()->renderFile($this->layout, $params, $this);
            }
            $fileName = $this->generateGuideFileName($file);
            file_put_contents($targetDir . '/' . $fileName, $output);

            if ($this->controller !== null) {
                Console::updateProgress(++$done, $fileCount);
            }
        }
        if ($this->controller !== null) {
            Console::updateProgress(++$done, $fileCount);
            Console::endProgress(true);
            $this->controller->stdout('done.' . PHP_EOL, Console::FG_GREEN);
        }
    }
public function render ( $ files , $ targetDir ) { $ this -> _targetDir = $ targetDir ; $ fileCount = count ( $ files ) + 1 ; if ( $ this -> controller !== null ) { Console :: startProgress ( 0 , $ fileCount , 'Rendering markdown files: ' , false ) ; } $ done = 0 ; $ fileData = [ ] ; $ chapters = $ this -> loadGuideStructure ( $ files ) ; foreach ( $ files as $ file ) { $ fileData [ $ file ] = file_get_contents ( $ file ) ; if ( basename ( $ file ) == 'README.md' ) { continue ; // to not add index file to nav } } foreach ( $ fileData as $ file => $ content ) { $ output = ApiMarkdown :: process ( $ content ) ; // TODO generate links to yiiframework.com by default $ output = $ this -> afterMarkdownProcess ( $ file , $ output , Markdown :: $ flavors [ 'api' ] ) ; if ( $ this -> layout !== false ) { $ params = [ 'chapters' => $ chapters , 'currentFile' => $ file , 'content' => $ output , ] ; $ output = $ this -> getView ( ) -> renderFile ( $ this -> layout , $ params , $ this ) ; } $ fileName = $ this -> generateGuideFileName ( $ file ) ; file_put_contents ( $ targetDir . '/' . $ fileName , $ output ) ; if ( $ this -> controller !== null ) { Console :: updateProgress ( ++ $ done , $ fileCount ) ; } } if ( $ this -> controller !== null ) { Console :: updateProgress ( ++ $ done , $ fileCount ) ; Console :: endProgress ( true ) ; $ this -> controller -> stdout ( 'done.' . PHP_EOL , Console :: FG_GREEN ) ; } }
Renders a set of files given into target directory.

@param array $files
@param string $targetDir
Renders a set of files given into target directory .