|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This software package is licensed under `AGPL, Commercial` license[s]. |
|
5
|
|
|
* |
|
6
|
|
|
* @package maslosoft/zamm |
|
7
|
|
|
* @license AGPL, Commercial |
|
8
|
|
|
* |
|
9
|
|
|
* @copyright Copyright (c) Peter Maselkowski <[email protected]> |
|
10
|
|
|
* @link https://maslosoft.com/zamm/ |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Maslosoft\Zamm\Converters; |
|
14
|
|
|
|
|
15
|
|
|
use Maslosoft\MiniView\MiniView; |
|
16
|
|
|
use Maslosoft\Zamm\FileDecorators\FileDecorator; |
|
17
|
|
|
use Maslosoft\Zamm\Interfaces\ConverterInterface; |
|
18
|
|
|
use Maslosoft\Zamm\Interfaces\OutputInterface; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Convert PHP documentation file into md |
|
22
|
|
|
* |
|
23
|
|
|
* @author Piotr Maselkowski <pmaselkowski at gmail.com> |
|
24
|
|
|
*/ |
|
25
|
|
|
class PhpConverter implements ConverterInterface |
|
26
|
|
|
{ |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* |
|
30
|
|
|
* @var MiniView |
|
31
|
|
|
*/ |
|
32
|
|
|
private $view = null; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* File decorator |
|
36
|
|
|
* @var FileDecorator |
|
37
|
|
|
*/ |
|
38
|
|
|
private $decorator = null; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* |
|
42
|
|
|
* @var string |
|
43
|
|
|
*/ |
|
44
|
|
|
private $_fileName; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* |
|
48
|
|
|
* @var string |
|
49
|
|
|
*/ |
|
50
|
|
|
private $_tempName; |
|
51
|
|
|
private $_doc = ''; |
|
52
|
|
|
|
|
53
|
|
|
public function __construct() |
|
54
|
|
|
{ |
|
55
|
|
|
$this->decorator = new FileDecorator($this); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function input($documentation, $fileName) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->decorator->decorate($documentation); |
|
61
|
|
|
|
|
62
|
|
|
$this->_tempName = sprintf('%s.tmp', $this->_fileName); |
|
63
|
|
|
$this->_fileName = $fileName; |
|
64
|
|
|
$this->view = new MiniView($this, dirname($this->_tempName)); |
|
65
|
|
|
$this->_doc = $this->view->render(basename($this->_tempName), [], true); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function output(OutputInterface $output) |
|
69
|
|
|
{ |
|
70
|
|
|
$outputName = preg_replace('~\.php~', '', $this->_fileName); |
|
71
|
|
|
$output->output($this->_doc, $outputName); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
} |
|
75
|
|
|
|