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