-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsami.php
50 lines (42 loc) · 1.3 KB
/
sami.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
use Sami\Sami;
use Sami\RemoteRepository\AbstractRemoteRepository;
use Symfony\Component\Finder\Finder;
class GitHubPath extends AbstractRemoteRepository
{
public function getFileUrl($projectVersion, $relativePath, $line)
{
$pieces = explode('/', $relativePath);
$package = $pieces[1];
unset($pieces[1]);
$path = implode('/', $pieces);
$url = 'https://github.com/' . $this->name . '/' . $package .
'/blob/' . str_replace('\\', '/', $projectVersion . $path);
if (null !== $line) {
$url .= '#L' . (int)$line;
}
return $url;
}
}
$dir = dirname(__DIR__, 2);
/** @noinspection PhpUndefinedClassInspection, PhpUndefinedMethodInspection */
$iterator = Finder::create()
->files()
->name('*.php')
->exclude('docs')
->exclude('config')
->exclude('resources')
->exclude('vendor')
->exclude('tests')
->in($dir);
/** @noinspection PhpUndefinedClassInspection */
$options = [
'theme' => 'default',
'title' => 'Simples',
'build_dir' => $dir . '/core/.docs/html',
'cache_dir' => $dir . '/core/.docs/cache',
'remote_repository' => new GitHubPath('phpzm', $dir),
'default_opened_level' => 2,
];
/** @noinspection PhpUndefinedClassInspection */
return new Sami($iterator, $options);