function generateApiClassesReference($rootDir, $versionName)
 {
     $iterator = Finder::create()->files()->name('*.php')->notName('tcpdf_config.php')->exclude(array('tests', 'config', 'ScheduledReports/config'))->in(array(PIWIK_DOCUMENT_ROOT . '/core', PIWIK_DOCUMENT_ROOT . '/plugins', PIWIK_DOCUMENT_ROOT . '/libs/PiwikTracker'));
     $sami = new Sami($iterator, array('theme' => 'markdown', 'versions' => $versionName, 'title' => 'Piwik Plugin API', 'build_dir' => $rootDir . '/docs/generated/%version%', 'cache_dir' => $rootDir . '/docs/cache/%version%', 'template_dirs' => array($rootDir . '/generator/template'), 'default_opened_level' => 5, 'include_parent_data' => true, 'filter' => new ApiClassFilter()));
     /** @var Twig_Environment $twig */
     $twig = $sami->offsetGet('twig');
     $twig->addFilter(new Twig_SimpleFilter('inlinelinkparser', function ($description, ClassReflection $class) use($sami) {
         $scope = new Scope();
         $scope->class = $class;
         $scope->classes = $sami->offsetGet('project')->getProjectClasses();
         $scope->namespace = $class->getNamespace();
         $linkConverter = new InlineLinkParser($scope);
         return $linkConverter->parse($description);
     }));
     $twig->addFilter(new Twig_SimpleFilter('linkparser', function ($description, ClassReflection $class) use($sami) {
         $scope = new Scope();
         $scope->class = $class;
         $scope->classes = $sami->offsetGet('project')->getProjectClasses();
         $scope->namespace = $class->getNamespace();
         $linkConverter = new LinkParser($scope);
         return $linkConverter->parse($description);
     }));
     $sami['project']->update();
     return $sami;
 }
 public function generateDocumentation($viewVariables, $target)
 {
     $loader = new \Twig_Loader_Filesystem(__DIR__ . '/../template');
     $twig = new \Twig_Environment($loader, array());
     $filter = new \Twig_SimpleFilter('onlyalnum', function ($string) {
         return preg_replace("/[^a-zA-Z0-9]+/", "", $string);
     });
     $twig->addFilter($filter);
     $self = $this;
     $twig->addFilter(new \Twig_SimpleFilter('linkparser', function ($text, $hook) use($self) {
         $scope = $self->generateScope($hook);
         $linkConverter = new LinkParser($scope);
         $parsedText = $linkConverter->parse($text);
         return $parsedText;
     }));
     $twig->addFilter(new \Twig_SimpleFilter('inlinelinkparser', function ($description, $hook) use($self) {
         $scope = $self->generateScope($hook);
         $linkConverter = new InlineLinkParser($scope);
         $parsedDescription = $linkConverter->parse($description);
         return $parsedDescription;
     }));
     $documentation = $twig->render('events.twig', $viewVariables);
     file_put_contents($target, $documentation);
 }