| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* $Id: PhpDocumentorExternalTask.php 352 2008-02-06 15:26:43Z mrook $
|
|
|
5 |
*
|
|
|
6 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
7 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
8 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
9 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
10 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
11 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
12 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
13 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
14 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
15 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
16 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
17 |
*
|
|
|
18 |
* This software consists of voluntary contributions made by many individuals
|
|
|
19 |
* and is licensed under the LGPL. For more information please see
|
|
|
20 |
* <http://phing.info>.
|
|
|
21 |
*/
|
|
|
22 |
|
|
|
23 |
require_once 'phing/tasks/ext/phpdoc/PhpDocumentorTask.php';
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Task to run phpDocumentor with an external process
|
|
|
27 |
*
|
|
|
28 |
* This classes uses the commandline phpdoc script to build documentation.
|
|
|
29 |
* Use this task instead of the PhpDocumentorTask when you've a clash with the
|
|
|
30 |
* Smarty libraries.
|
|
|
31 |
*
|
|
|
32 |
* @author Michiel Rook <michiel.rook@gmail.com>
|
|
|
33 |
* @author Markus Fischer <markus@fischer.name>
|
|
|
34 |
* @version $Id: PhpDocumentorExternalTask.php 352 2008-02-06 15:26:43Z mrook $
|
|
|
35 |
* @package phing.tasks.ext.phpdoc
|
|
|
36 |
*/
|
|
|
37 |
class PhpDocumentorExternalTask extends PhpDocumentorTask
|
|
|
38 |
{
|
|
|
39 |
/**
|
|
|
40 |
* The path to the executable for phpDocumentor
|
|
|
41 |
*/
|
|
|
42 |
protected $programPath = 'phpdoc';
|
|
|
43 |
|
|
|
44 |
protected $sourcepath = NULL;
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* @var bool ignore symlinks to other files or directories
|
|
|
48 |
*/
|
|
|
49 |
protected $ignoresymlinks = false;
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Sets the path to the phpDocumentor executable
|
|
|
53 |
*/
|
|
|
54 |
public function setProgramPath($programPath)
|
|
|
55 |
{
|
|
|
56 |
$this->programPath = $programPath;
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
* Returns the path to the phpDocumentor executable
|
|
|
61 |
*/
|
|
|
62 |
public function getProgramPath()
|
|
|
63 |
{
|
|
|
64 |
return $this->programPath;
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
/**
|
|
|
68 |
* Set the source path. A directory or a comma separate list of directories.
|
|
|
69 |
*/
|
|
|
70 |
public function setSourcepath($sourcepath)
|
|
|
71 |
{
|
|
|
72 |
$this->sourcepath = $sourcepath;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
/**
|
|
|
76 |
* Ignore symlinks to other files or directories.
|
|
|
77 |
*
|
|
|
78 |
* @param bool $bSet
|
|
|
79 |
*/
|
|
|
80 |
public function setIgnoresymlinks($bSet) {
|
|
|
81 |
$this->ignoresymlinks = $bSet;
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
/**
|
|
|
85 |
* Main entrypoint of the task
|
|
|
86 |
*/
|
|
|
87 |
public function main()
|
|
|
88 |
{
|
|
|
89 |
$this->validate();
|
|
|
90 |
$arguments = join(' ', $this->constructArguments());
|
|
|
91 |
|
|
|
92 |
$this->log("Running phpDocumentor...");
|
|
|
93 |
|
|
|
94 |
exec($this->programPath . " " . $arguments, $output, $return);
|
|
|
95 |
|
|
|
96 |
if ($return != 0)
|
|
|
97 |
{
|
|
|
98 |
throw new BuildException("Could not execute phpDocumentor: " . implode(' ', $output));
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
foreach($output as $line)
|
|
|
102 |
{
|
|
|
103 |
if(strpos($line, 'ERROR') !== false)
|
|
|
104 |
{
|
|
|
105 |
$this->log($line, Project::MSG_ERR);
|
|
|
106 |
continue;
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
$this->log($line, Project::MSG_VERBOSE);
|
|
|
110 |
}
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
/**
|
|
|
114 |
* Constructs an argument string for phpDocumentor
|
|
|
115 |
* @return array
|
|
|
116 |
*/
|
|
|
117 |
protected function constructArguments()
|
|
|
118 |
{
|
|
|
119 |
$aArgs = array();
|
|
|
120 |
if ($this->title)
|
|
|
121 |
{
|
|
|
122 |
$aArgs[] = '--title "' . $this->title . '"';
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
if ($this->destdir)
|
|
|
126 |
{
|
|
|
127 |
$aArgs[] = '--target "' . $this->destdir->getAbsolutePath() . '"';
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
if ($this->sourcepath)
|
|
|
131 |
{
|
|
|
132 |
$aArgs[] = '--directory "' . $this->sourcepath . '"';
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
if ($this->output)
|
|
|
136 |
{
|
|
|
137 |
$aArgs[] = '--output ' . $this->output;
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
if ($this->linksource)
|
|
|
141 |
{
|
|
|
142 |
$aArgs[] = '--sourcecode on';
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
if ($this->parseprivate)
|
|
|
146 |
{
|
|
|
147 |
$aArgs[] = '--parseprivate on';
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
// append any files in filesets
|
|
|
151 |
$filesToParse = array();
|
|
|
152 |
foreach($this->filesets as $fs) {
|
|
|
153 |
$files = $fs->getDirectoryScanner($this->project)->getIncludedFiles();
|
|
|
154 |
foreach($files as $filename) {
|
|
|
155 |
$f = new PhingFile($fs->getDir($this->project), $filename);
|
|
|
156 |
$filesToParse[] = $f->getAbsolutePath();
|
|
|
157 |
}
|
|
|
158 |
}
|
|
|
159 |
if (count($filesToParse) > 0) {
|
|
|
160 |
$aArgs[] = '--filename "' . join(',', $filesToParse) . '"';
|
|
|
161 |
}
|
|
|
162 |
|
|
|
163 |
// append any files in filesets
|
|
|
164 |
$ricFiles = array();
|
|
|
165 |
foreach($this->projDocFilesets as $fs) {
|
|
|
166 |
$files = $fs->getDirectoryScanner($this->project)->getIncludedFiles();
|
|
|
167 |
foreach($files as $filename) {
|
|
|
168 |
$f = new PhingFile($fs->getDir($this->project), $filename);
|
|
|
169 |
$ricFiles[] = $f->getAbsolutePath();
|
|
|
170 |
}
|
|
|
171 |
}
|
|
|
172 |
if (count($ricFiles) > 0) {
|
|
|
173 |
$aArgs[] = '--readmeinstallchangelog "' .
|
|
|
174 |
join(',', $ricFiles) . '"';
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
if ($this->javadocDesc) {
|
|
|
178 |
$aArgs[] = '--javadocdesc on';
|
|
|
179 |
}
|
|
|
180 |
|
|
|
181 |
if ($this->quiet) {
|
|
|
182 |
$aArgs[] = '--quiet on';
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
if ($this->packages) {
|
|
|
186 |
$aArgs[] = '--packageoutput "' . $this->packages . '"';
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
if ($this->ignoreTags) {
|
|
|
190 |
$aArgs[] = '--ignore-tags "' . $this->ignoreTags . '"';
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
if ($this->defaultCategoryName) {
|
|
|
194 |
$aArgs[] = '--defaultcategoryname "' . $this->defaultCategoryName .
|
|
|
195 |
'"';
|
|
|
196 |
}
|
|
|
197 |
|
|
|
198 |
if ($this->examplesDir) {
|
|
|
199 |
$aArgs[] = '--examplesdir "' . $this->examplesDir->getAbsolutePath()
|
|
|
200 |
. '"';
|
|
|
201 |
}
|
|
|
202 |
|
|
|
203 |
if ($this->templateBase) {
|
|
|
204 |
$aArgs[] = '--templatebase "' . $this->templateBase->getAbsolutePath()
|
|
|
205 |
. '"';
|
|
|
206 |
}
|
|
|
207 |
|
|
|
208 |
if ($this->pear) {
|
|
|
209 |
$aArgs[] = '--pear on';
|
|
|
210 |
}
|
|
|
211 |
|
|
|
212 |
if ($this->undocumentedelements) {
|
|
|
213 |
$aArgs[] = '--undocumentedelements on';
|
|
|
214 |
}
|
|
|
215 |
|
|
|
216 |
if ($this->customtags) {
|
|
|
217 |
$aArgs[] = '--customtags "' . $this->customtags . '"';
|
|
|
218 |
}
|
|
|
219 |
|
|
|
220 |
if ($this->ignoresymlinks) {
|
|
|
221 |
$aArgs[] = '--ignoresymlinks on';
|
|
|
222 |
}
|
|
|
223 |
|
|
|
224 |
var_dump($aArgs);exit;
|
|
|
225 |
return $aArgs;
|
|
|
226 |
}
|
|
|
227 |
|
|
|
228 |
/**
|
|
|
229 |
* Override PhpDocumentorTask::init() because they're specific to the phpdoc
|
|
|
230 |
* API which we don't use.
|
|
|
231 |
*/
|
|
|
232 |
public function init() {
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
/**
|
|
|
236 |
* Validates that necessary minimum options have been set. Based on
|
|
|
237 |
* PhpDocumentorTask::validate().
|
|
|
238 |
*/
|
|
|
239 |
protected function validate() {
|
|
|
240 |
if (!$this->destdir) {
|
|
|
241 |
throw new BuildException("You must specify a destdir for phpdoc.",
|
|
|
242 |
$this->getLocation());
|
|
|
243 |
}
|
|
|
244 |
if (!$this->output) {
|
|
|
245 |
throw new BuildException("You must specify an output format for " .
|
|
|
246 |
"phpdoc (e.g. HTML:frames:default).", $this->getLocation());
|
|
|
247 |
}
|
|
|
248 |
if (empty($this->filesets) && !$this->sourcepath) {
|
|
|
249 |
throw new BuildException("You have not specified any files to " .
|
|
|
250 |
"include (<fileset> or sourcepath attribute) for phpdoc.",
|
|
|
251 |
$this->getLocation());
|
|
|
252 |
}
|
|
|
253 |
if ($this->configdir) {
|
|
|
254 |
$this->log('Ignoring unsupported configdir-Attribute',
|
|
|
255 |
Project::MSG_VERBOSE);
|
|
|
256 |
}
|
|
|
257 |
}
|
|
|
258 |
};
|
|
|
259 |
|
|
|
260 |
|
|
|
261 |
|