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 generateScope($hook) { $scope = new Scope(); $scope->classes = $this->sami->offsetGet('project')->getProjectClasses(); $scope->namespace = str_replace('/', '\\', $hook['namespace']); $scope->class = $scope->findClass($hook['class']); return $scope; }
<?php use Sami\Parser\Filter\FilterInterface; use Sami\Reflection\ClassReflection; use Sami\Reflection\MethodReflection; use Sami\Reflection\PropertyReflection; use Sami\Sami; use Symfony\Component\Finder\Finder; $sami = new Sami(Finder::create()->files()->name('*.php')->in(__DIR__ . '/source'), array('build_dir' => __DIR__ . '/build', 'cache_dir' => __DIR__ . '/cache', 'template_dirs' => array(__DIR__ . '/..'), 'theme' => 'github')); $sami['filter'] = $sami->share(function () { return new CustomFilter(); }); /** * Allows public and protected members to be rendered. * * @author Kevin Herrera <*****@*****.**> */ class CustomFilter implements FilterInterface { public function acceptClass(ClassReflection $class) { return true; } public function acceptMethod(MethodReflection $method) { return $method->isPublic() || $method->isProtected(); } public function acceptProperty(PropertyReflection $property) { return $property->isPublic() || $property->isProtected(); }