2013-02-28 09:17:01 -08:00
|
|
|
<?php
|
|
|
|
|
2015-01-02 15:27:45 +11:00
|
|
|
final class PhabricatorPygmentSetupCheck extends PhabricatorSetupCheck {
|
2013-02-28 09:17:01 -08:00
|
|
|
|
2015-02-10 12:53:00 -08:00
|
|
|
public function getDefaultGroup() {
|
|
|
|
return self::GROUP_OTHER;
|
|
|
|
}
|
|
|
|
|
2013-02-28 09:17:01 -08:00
|
|
|
protected function executeChecks() {
|
|
|
|
$pygment = PhabricatorEnv::getEnvConfig('pygments.enabled');
|
|
|
|
|
|
|
|
if ($pygment) {
|
2014-10-02 09:48:04 -07:00
|
|
|
if (!Filesystem::binaryExists('pygmentize')) {
|
2013-02-28 09:17:01 -08:00
|
|
|
$summary = pht(
|
2015-05-22 17:27:56 +10:00
|
|
|
'You enabled pygments but the %s script is not '.
|
|
|
|
'actually available, your %s is probably broken.',
|
|
|
|
'pygmentize',
|
|
|
|
'$PATH');
|
2013-02-28 09:17:01 -08:00
|
|
|
|
|
|
|
$message = pht(
|
2015-05-22 17:27:56 +10:00
|
|
|
'The environmental variable %s does not contain %s. '.
|
|
|
|
'You have enabled pygments, which requires '.
|
|
|
|
'%s to be available in your %s variable.',
|
|
|
|
'$PATH',
|
|
|
|
'pygmentize',
|
|
|
|
'pygmentize',
|
|
|
|
'$PATH');
|
2013-02-28 09:17:01 -08:00
|
|
|
|
|
|
|
$this
|
|
|
|
->newIssue('pygments.enabled')
|
2015-05-22 17:27:56 +10:00
|
|
|
->setName(pht('%s Not Found', 'pygmentize'))
|
2013-02-28 09:17:01 -08:00
|
|
|
->setSummary($summary)
|
|
|
|
->setMessage($message)
|
2013-04-10 13:10:52 -07:00
|
|
|
->addRelatedPhabricatorConfig('pygments.enabled')
|
2013-04-03 10:04:17 -07:00
|
|
|
->addPhabricatorConfig('environment.append-paths');
|
2014-10-02 09:48:04 -07:00
|
|
|
} else {
|
|
|
|
list($err) = exec_manual('pygmentize -h');
|
|
|
|
if ($err) {
|
|
|
|
$summary = pht(
|
2015-05-22 17:27:56 +10:00
|
|
|
'You have enabled pygments and the %s script is '.
|
|
|
|
'available, but does not seem to work.',
|
|
|
|
'pygmentize');
|
2014-10-02 09:48:04 -07:00
|
|
|
|
|
|
|
$message = pht(
|
2015-05-22 17:27:56 +10:00
|
|
|
'Phabricator has %s available in %s, but the binary '.
|
2014-10-02 09:48:04 -07:00
|
|
|
'exited with an error code when run as %s. Check that it is '.
|
|
|
|
'installed correctly.',
|
|
|
|
phutil_tag('tt', array(), 'pygmentize'),
|
2015-10-16 09:51:39 -07:00
|
|
|
phutil_tag('tt', array(), '$PATH'),
|
2014-10-02 09:48:04 -07:00
|
|
|
phutil_tag('tt', array(), 'pygmentize -h'));
|
|
|
|
|
|
|
|
$this
|
|
|
|
->newIssue('pygments.failed')
|
2015-05-22 17:27:56 +10:00
|
|
|
->setName(pht('%s Not Working', 'pygmentize'))
|
2014-10-02 09:48:04 -07:00
|
|
|
->setSummary($summary)
|
|
|
|
->setMessage($message)
|
|
|
|
->addRelatedPhabricatorConfig('pygments.enabled')
|
|
|
|
->addPhabricatorConfig('environment.append-paths');
|
|
|
|
}
|
2013-02-28 09:17:01 -08:00
|
|
|
}
|
2014-12-29 09:49:17 -08:00
|
|
|
} else {
|
2015-05-22 17:27:56 +10:00
|
|
|
$summary = pht(
|
|
|
|
'Pygments should be installed and enabled '.
|
2014-12-29 09:49:17 -08:00
|
|
|
'to provide advanced syntax highlighting.');
|
|
|
|
|
2015-05-22 17:27:56 +10:00
|
|
|
$message = pht(
|
|
|
|
'Phabricator can highlight a few languages by default, '.
|
2014-12-29 09:49:17 -08:00
|
|
|
'but installing and enabling Pygments (a third-party highlighting '.
|
2015-05-22 17:27:56 +10:00
|
|
|
"tool) will add syntax highlighting for many more languages. \n\n".
|
2014-12-29 09:49:17 -08:00
|
|
|
'For instructions on installing and enabling Pygments, see the '.
|
|
|
|
'%s configuration option.'."\n\n".
|
|
|
|
'If you do not want to install Pygments, you can ignore this issue.',
|
|
|
|
phutil_tag('tt', array(), 'pygments.enabled'));
|
|
|
|
|
|
|
|
$this
|
|
|
|
->newIssue('pygments.noenabled')
|
|
|
|
->setName(pht('Install Pygments to Improve Syntax Highlighting'))
|
|
|
|
->setSummary($summary)
|
|
|
|
->setMessage($message)
|
|
|
|
->addRelatedPhabricatorConfig('pygments.enabled');
|
2013-02-28 09:17:01 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|