1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Godbout\DashDocsetBuilder\Services; |
4
|
|
|
|
5
|
|
|
use LaravelZero\Framework\Commands\Command; |
6
|
|
|
use Godbout\DashDocsetBuilder\Contracts\Docset; |
7
|
|
|
use Illuminate\Console\Command as LaravelCommand; |
8
|
|
|
|
9
|
|
|
class DocsetBuilder |
10
|
|
|
{ |
11
|
|
|
protected $docset; |
12
|
|
|
|
13
|
|
|
protected $grabber; |
14
|
|
|
protected $packager; |
15
|
|
|
protected $archiver; |
16
|
|
|
|
17
|
|
|
protected $command; |
18
|
|
|
|
19
|
|
|
|
20
|
18 |
|
public function __construct(Docset $docset, ?Command $command = null) |
21
|
|
|
{ |
22
|
18 |
|
$this->docset = $docset; |
23
|
|
|
|
24
|
18 |
|
$this->grabber = new DocsetGrabber($this->docset); |
25
|
18 |
|
$this->packager = new DocsetPackager($this->docset); |
26
|
18 |
|
$this->archiver = new DocsetArchiver($this->docset); |
27
|
|
|
|
28
|
18 |
|
$this->command = $command ?? new LaravelCommand(); |
29
|
18 |
|
} |
30
|
|
|
|
31
|
6 |
|
public function build() |
32
|
|
|
{ |
33
|
6 |
|
$this->grab(); |
34
|
6 |
|
$this->package(); |
35
|
6 |
|
$this->archive(); |
36
|
6 |
|
} |
37
|
|
|
|
38
|
6 |
|
public function grab() |
39
|
|
|
{ |
40
|
6 |
|
if (method_exists($this->docset, 'grab')) { |
41
|
|
|
return $this->grabFromDocset(); |
42
|
|
|
} |
43
|
|
|
|
44
|
6 |
|
if ($this->grabber->sitemapExists()) { |
45
|
|
|
return $this->grabFromSitemap(); |
46
|
|
|
} |
47
|
|
|
|
48
|
6 |
|
return $this->grabFromIndex(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
protected function grabFromDocset() |
52
|
|
|
{ |
53
|
|
|
return $this->command->task(' - Downloading doc from docset custom instructions', function () { |
54
|
|
|
return $this->docset->grab(); |
|
|
|
|
55
|
|
|
}); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
protected function grabFromSitemap() |
59
|
|
|
{ |
60
|
|
|
return $this->command->task(' - Downloading doc from sitemap', function () { |
61
|
|
|
return $this->grabber->grabFromSitemap(); |
62
|
|
|
}); |
63
|
|
|
} |
64
|
|
|
|
65
|
6 |
|
protected function grabFromIndex() |
66
|
|
|
{ |
67
|
|
|
return $this->command->task(' - Downloading doc from index', function () { |
68
|
6 |
|
return $this->grabber->grabFromIndex(); |
69
|
6 |
|
}); |
70
|
|
|
} |
71
|
|
|
|
72
|
12 |
|
public function package() |
73
|
|
|
{ |
74
|
|
|
$this->command->task(' - Remove previous .docset', function () { |
75
|
12 |
|
$this->packager->removePreviousDocsetFile(); |
76
|
12 |
|
}); |
77
|
|
|
|
78
|
|
|
$this->command->task(' - Create new .docset', function () { |
79
|
12 |
|
return $this->packager->createDocsetFile(); |
80
|
12 |
|
}); |
81
|
|
|
|
82
|
|
|
$this->command->task(' - Copy original doc files', function () { |
83
|
12 |
|
return $this->packager->copyDocFiles(); |
84
|
12 |
|
}); |
85
|
|
|
|
86
|
|
|
$this->command->task(' - Create Info.plist', function () { |
87
|
12 |
|
return $this->packager->createInfoPlist(); |
88
|
12 |
|
}); |
89
|
|
|
|
90
|
|
|
$this->command->task(' - Populate SQLiteIndex', function () { |
91
|
12 |
|
return $this->packager->createAndPopulateSQLiteIndex(); |
|
|
|
|
92
|
12 |
|
}); |
93
|
|
|
|
94
|
|
|
$this->command->task(' - Format doc files for Dash', function () { |
95
|
12 |
|
return $this->packager->formatDocFiles(); |
|
|
|
|
96
|
12 |
|
}); |
97
|
|
|
|
98
|
|
|
$this->command->task(' - Copy icons', function () { |
99
|
12 |
|
$this->packager->copyIcons(); |
100
|
12 |
|
}); |
101
|
12 |
|
} |
102
|
|
|
|
103
|
12 |
|
public function archive() |
104
|
|
|
{ |
105
|
|
|
$this->command->task(' - Archiving package', function () { |
106
|
12 |
|
return $this->archiver->archive(); |
107
|
12 |
|
}); |
108
|
12 |
|
} |
109
|
|
|
} |
110
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.