1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2017 Julius Härtl <[email protected]> |
4
|
|
|
* @author Julius Härtl <[email protected]> |
5
|
|
|
* @license GNU AGPL version 3 or any later version |
6
|
|
|
* |
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License as |
9
|
|
|
* published by the Free Software Foundation, either version 3 of the |
10
|
|
|
* License, or (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace JuliusHaertl\PHPDocToRst\Builder; |
22
|
|
|
|
23
|
|
|
use JuliusHaertl\PHPDocToRst\Extension\Extension; |
24
|
|
|
use phpDocumentor\Reflection\Element; |
25
|
|
|
use phpDocumentor\Reflection\Php\File; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Abstract building class to build sphinxcontrib-phpdomain from a php file. |
29
|
|
|
*/ |
30
|
|
|
abstract class FileBuilder extends PhpDomainBuilder |
31
|
|
|
{ |
32
|
|
|
/** @var File */ |
33
|
|
|
protected $file; |
34
|
|
|
|
35
|
|
|
/** @var Element */ |
36
|
|
|
protected $element; |
37
|
|
|
|
38
|
|
|
/** @var Extension[] */ |
39
|
|
|
protected $extensions = []; |
40
|
|
|
|
41
|
|
|
public function __construct($file, $element, $extensions) |
42
|
|
|
{ |
43
|
|
|
parent::__construct($extensions); |
44
|
|
|
$this->file = $file; |
45
|
|
|
$this->element = $element; |
46
|
|
|
$this->render(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
abstract protected function render(); |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return Element that is used to build the rst file |
53
|
|
|
*/ |
54
|
|
|
public function getElement() |
55
|
|
|
{ |
56
|
|
|
return $this->element; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return File |
61
|
|
|
*/ |
62
|
|
|
public function getFile() |
63
|
|
|
{ |
64
|
|
|
return $this->file; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|