Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/config/check/PhabricatorPygmentSetupCheck.php
12262 views
1
<?php
2
3
final class PhabricatorPygmentSetupCheck extends PhabricatorSetupCheck {
4
5
public function getDefaultGroup() {
6
return self::GROUP_OTHER;
7
}
8
9
protected function executeChecks() {
10
$pygment = PhabricatorEnv::getEnvConfig('pygments.enabled');
11
12
if ($pygment) {
13
if (!Filesystem::binaryExists('pygmentize')) {
14
$summary = pht(
15
'You enabled pygments but the %s script is not '.
16
'actually available, your %s is probably broken.',
17
'pygmentize',
18
'$PATH');
19
20
$message = pht(
21
'The environmental variable %s does not contain %s. '.
22
'You have enabled pygments, which requires '.
23
'%s to be available in your %s variable.',
24
'$PATH',
25
'pygmentize',
26
'pygmentize',
27
'$PATH');
28
29
$this
30
->newIssue('pygments.enabled')
31
->setName(pht('%s Not Found', 'pygmentize'))
32
->setSummary($summary)
33
->setMessage($message)
34
->addRelatedPhabricatorConfig('pygments.enabled')
35
->addPhabricatorConfig('environment.append-paths');
36
} else {
37
list($err) = exec_manual('pygmentize -h');
38
if ($err) {
39
$summary = pht(
40
'You have enabled pygments and the %s script is '.
41
'available, but does not seem to work.',
42
'pygmentize');
43
44
$message = pht(
45
'This server has %s available in %s, but the binary '.
46
'exited with an error code when run as %s. Check that it is '.
47
'installed correctly.',
48
phutil_tag('tt', array(), 'pygmentize'),
49
phutil_tag('tt', array(), '$PATH'),
50
phutil_tag('tt', array(), 'pygmentize -h'));
51
52
$this
53
->newIssue('pygments.failed')
54
->setName(pht('%s Not Working', 'pygmentize'))
55
->setSummary($summary)
56
->setMessage($message)
57
->addRelatedPhabricatorConfig('pygments.enabled')
58
->addPhabricatorConfig('environment.append-paths');
59
}
60
}
61
} else {
62
$summary = pht(
63
'Pygments should be installed and enabled '.
64
'to provide advanced syntax highlighting.');
65
66
$message = pht(
67
'This software can highlight a few languages by default, '.
68
'but installing and enabling Pygments (a third-party highlighting '.
69
"tool) will add syntax highlighting for many more languages. \n\n".
70
'For instructions on installing and enabling Pygments, see the '.
71
'%s configuration option.'."\n\n".
72
'If you do not want to install Pygments, you can ignore this issue.',
73
phutil_tag('tt', array(), 'pygments.enabled'));
74
75
$this
76
->newIssue('pygments.noenabled')
77
->setName(pht('Install Pygments to Improve Syntax Highlighting'))
78
->setSummary($summary)
79
->setMessage($message)
80
->addRelatedPhabricatorConfig('pygments.enabled');
81
}
82
}
83
}
84
85