This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
/
build-manual2.php
79 lines (63 loc) · 2 KB
/
build-manual2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace cli;
$topDir = realpath(__DIR__ . '/../');
$tempDir = $topDir . '/tmp';
if (!file_exists($tempDir)) {
colorPrint('Creating a tmp directory at ' . $tempDir . ' to work in ... ', 'green');
mkdir($tempDir);
}
$output = null;
exec('which svn', $output);
if (empty($output)) {
colorPrint('Error: svn is required to check out the Phd tools!', 'red');
}
if (!file_exists($tempDir . '/phd')) {
colorPrint('Checking out PhD via SVN ...', 'green');
exec('svn co http://framework.zend.com/svn/framework/build-tools/trunk/build-tools/docs/ ' . $tempDir . '/phd', $output);
nl();
}
$output = null;
exec('which xsltproc', $output);
if (empty($output)) {
colorPrint('Error: xsltproc is required!', 'red');
}
$command = 'xsltproc --xinclude ' . $tempDir . '/phd/db4-upgrade.xsl '
. $topDir . '/documentation/manual/en/manual2.xml.in > '
. $tempDir . '/manual2.full.xml | tee -a '
. $tempDir . '/manual2-err.txt';
colorPrint('Running: ' . $command, 'green');
nl();
system($command);
nl();
$command = $tempDir . '/phd/pear/phd -g \'phpdotnet\phd\Highlighter_GeSHi\' --xinclude -f zfpackage -d '
. $tempDir . '/manual2.full.xml -o ' . $tempDir . '/manual-html';
colorPrint('Running: ' . $command, 'green');
nl();
system($command);
nl();
colorPrint('[DONE]', 'green');
nl();
colorPrint('HTML Manual located in ' . $tempDir . '/manual-html/zf-package-chunked-xhtml/manual.html', 'green');
nl();
/** FUNCTIONS **/
function colorPrint($message, $color) {
static $isColor = null;
if ($isColor === null) {
$isColor = (function_exists('posix_isatty'));
}
list($prefix, $postfix) = array('', '');
if ($isColor) {
switch ($color) {
case 'green':
list($prefix, $postfix) = array("\033[32m", "\033[37m");
break;
case 'red':
list($prefix, $postfix) = array("\033[31m", "\033[37m");
break;
}
}
echo $prefix . $message . $postfix;
}
function nl() {
echo "\r\n";
}