1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Godbout\DashDocsetBuilder\Docsets; |
4
|
|
|
|
5
|
|
|
use Godbout\DashDocsetBuilder\Contracts\Docset; |
6
|
|
|
use Illuminate\Support\Collection; |
7
|
|
|
use Illuminate\Support\Facades\Storage; |
8
|
|
|
|
9
|
|
|
abstract class BaseDocset implements Docset |
10
|
|
|
{ |
11
|
|
|
public const CODE = self::CODE; |
12
|
|
|
public const NAME = self::NAME; |
13
|
|
|
public const URL = self::URL; |
14
|
|
|
public const INDEX = self::INDEX; |
15
|
|
|
public const PLAYGROUND = self::PLAYGROUND; |
16
|
|
|
public const ICON_16 = self::ICON_16; |
17
|
|
|
public const ICON_32 = self::ICON_32; |
18
|
|
|
public const EXTERNAL_DOMAINS = self::EXTERNAL_DOMAINS; |
19
|
|
|
|
20
|
|
|
|
21
|
24 |
|
final public function code(): string |
22
|
|
|
{ |
23
|
24 |
|
return static::CODE; |
24
|
|
|
} |
25
|
|
|
|
26
|
16 |
|
final public function name(): string |
27
|
|
|
{ |
28
|
16 |
|
return static::NAME; |
29
|
|
|
} |
30
|
|
|
|
31
|
24 |
|
final public function url(): string |
32
|
|
|
{ |
33
|
24 |
|
return static::URL; |
34
|
|
|
} |
35
|
|
|
|
36
|
16 |
|
final public function index(): string |
37
|
|
|
{ |
38
|
16 |
|
return static::URL . '/' . static::INDEX; |
39
|
|
|
} |
40
|
|
|
|
41
|
16 |
|
final public function playground(): string |
42
|
|
|
{ |
43
|
16 |
|
return static::PLAYGROUND; |
44
|
|
|
} |
45
|
|
|
|
46
|
16 |
|
final public function icon16(): string |
47
|
|
|
{ |
48
|
16 |
|
return static::URL . '/' . static::ICON_16; |
49
|
|
|
} |
50
|
|
|
|
51
|
16 |
|
final public function icon32(): string |
52
|
|
|
{ |
53
|
16 |
|
return static::URL . '/' . static::ICON_32; |
54
|
|
|
} |
55
|
|
|
|
56
|
8 |
|
final public function externalDomains(): string |
57
|
|
|
{ |
58
|
8 |
|
return implode( |
59
|
8 |
|
',', |
60
|
8 |
|
array_merge((array) static::URL, (array) static::EXTERNAL_DOMAINS) |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
|
64
|
64 |
|
final public function file(): string |
65
|
|
|
{ |
66
|
64 |
|
return static::CODE . '/' . static::CODE . '.docset'; |
67
|
|
|
} |
68
|
|
|
|
69
|
24 |
|
final public function innerDirectory(): string |
70
|
|
|
{ |
71
|
24 |
|
return $this->file() . '/Contents/Resources/Documents'; |
72
|
|
|
} |
73
|
|
|
|
74
|
8 |
|
final public function innerIndex(): string |
75
|
|
|
{ |
76
|
8 |
|
return $this->innerDirectory() . '/' . $this->url() . '/' . static::INDEX; |
77
|
|
|
} |
78
|
|
|
|
79
|
24 |
|
final public function downloadedDirectory(): string |
80
|
|
|
{ |
81
|
24 |
|
return static::CODE . '/docs'; |
82
|
|
|
} |
83
|
|
|
|
84
|
8 |
|
final public function downloadedIndex(): string |
85
|
|
|
{ |
86
|
8 |
|
return $this->downloadedDirectory() . '/' . $this->url() . '/' . static::INDEX; |
87
|
|
|
} |
88
|
|
|
|
89
|
24 |
|
final public function infoPlistFile(): string |
90
|
|
|
{ |
91
|
24 |
|
return $this->file() . '/Contents/Info.plist'; |
92
|
|
|
} |
93
|
|
|
|
94
|
32 |
|
final public function databaseFile(): string |
95
|
|
|
{ |
96
|
32 |
|
return $this->file() . '/Contents/Resources/docSet.dsidx'; |
97
|
|
|
} |
98
|
|
|
|
99
|
16 |
|
final public function htmlFiles(): Collection |
100
|
|
|
{ |
101
|
16 |
|
$files = Storage::allFiles( |
102
|
16 |
|
$this->innerDirectory() |
103
|
|
|
); |
104
|
|
|
|
105
|
16 |
|
return collect($files)->reject(static function ($file) { |
106
|
16 |
|
return substr($file, -5) !== '.html'; |
107
|
16 |
|
}); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
abstract public function entries(string $file): Collection; |
111
|
|
|
|
112
|
|
|
abstract public function format(string $file): string; |
113
|
|
|
} |
114
|
|
|
|