Differential D9431 Diff 22523 src/applications/config/option/PhabricatorSyntaxHighlightingConfigOptions.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/option/PhabricatorSyntaxHighlightingConfigOptions.php
| <?php | <?php | ||||
| final class PhabricatorSyntaxHighlightingConfigOptions | final class PhabricatorSyntaxHighlightingConfigOptions | ||||
| extends PhabricatorApplicationConfigOptions { | extends PhabricatorApplicationConfigOptions { | ||||
| public function getName() { | public function getName() { | ||||
| return pht("Syntax Highlighting"); | return pht('Syntax Highlighting'); | ||||
| } | } | ||||
| public function getDescription() { | public function getDescription() { | ||||
| return pht("Options relating to syntax highlighting source code."); | return pht('Options relating to syntax highlighting source code.'); | ||||
| } | } | ||||
| public function getOptions() { | public function getOptions() { | ||||
| return array( | return array( | ||||
| $this->newOption( | $this->newOption( | ||||
| 'syntax-highlighter.engine', | 'syntax-highlighter.engine', | ||||
| 'class', | 'class', | ||||
| 'PhutilDefaultSyntaxHighlighterEngine') | 'PhutilDefaultSyntaxHighlighterEngine') | ||||
| ->setBaseClass('PhutilSyntaxHighlighterEngine') | ->setBaseClass('PhutilSyntaxHighlighterEngine') | ||||
| ->setSummary(pht("Default non-pygments syntax highlighter engine.")) | ->setSummary(pht('Default non-pygments syntax highlighter engine.')) | ||||
| ->setDescription( | ->setDescription( | ||||
| pht( | pht( | ||||
| "Phabricator can highlight PHP by default and use Pygments for ". | 'Phabricator can highlight PHP by default and use Pygments for '. | ||||
| "other languages if enabled. You can provide a custom ". | 'other languages if enabled. You can provide a custom '. | ||||
| "highlighter engine by extending class ". | 'highlighter engine by extending class '. | ||||
| "PhutilSyntaxHighlighterEngine.")), | 'PhutilSyntaxHighlighterEngine.')), | ||||
| $this->newOption('pygments.enabled', 'bool', false) | $this->newOption('pygments.enabled', 'bool', false) | ||||
| ->setSummary( | ->setSummary( | ||||
| pht("Should Phabricator shell out to Pygments to highlight code?")) | pht('Should Phabricator shell out to Pygments to highlight code?')) | ||||
| ->setDescription( | ->setDescription( | ||||
| pht( | pht( | ||||
| "If you want syntax highlighting for other languages than PHP ". | "If you want syntax highlighting for other languages than PHP ". | ||||
| "then you can install the python package 'Pygments', make sure ". | "then you can install the python package 'Pygments', make sure ". | ||||
| "the 'pygmentize' script is available in the \$PATH of the ". | "the 'pygmentize' script is available in the \$PATH of the ". | ||||
| "webserver, and then enable this.")), | "webserver, and then enable this.")), | ||||
| $this->newOption( | $this->newOption( | ||||
| 'pygments.dropdown-choices', | 'pygments.dropdown-choices', | ||||
| Show All 29 Lines | return array( | ||||
| 'python' => 'Python', | 'python' => 'Python', | ||||
| 'rainbow' => 'Rainbow', | 'rainbow' => 'Rainbow', | ||||
| 'remarkup' => 'Remarkup', | 'remarkup' => 'Remarkup', | ||||
| 'ruby' => 'Ruby', | 'ruby' => 'Ruby', | ||||
| 'xml' => 'XML', | 'xml' => 'XML', | ||||
| 'yaml' => 'YAML', | 'yaml' => 'YAML', | ||||
| )) | )) | ||||
| ->setSummary( | ->setSummary( | ||||
| pht("Set the language list which appears in dropdowns.")) | pht('Set the language list which appears in dropdowns.')) | ||||
| ->setDescription( | ->setDescription( | ||||
| pht( | pht( | ||||
| "In places that we display a dropdown to syntax-highlight code, ". | 'In places that we display a dropdown to syntax-highlight code, '. | ||||
| "this is where that list is defined.")), | 'this is where that list is defined.')), | ||||
| $this->newOption( | $this->newOption( | ||||
| 'syntax.filemap', | 'syntax.filemap', | ||||
| 'wild', | 'wild', | ||||
| array( | array( | ||||
| '@\.arcconfig$@' => 'js', | '@\.arcconfig$@' => 'js', | ||||
| '@\.arclint$@' => 'js', | '@\.arclint$@' => 'js', | ||||
| '@\.divinerconfig$@' => 'js', | '@\.divinerconfig$@' => 'js', | ||||
| )) | )) | ||||
| ->setSummary( | ->setSummary( | ||||
| pht("Override what language files (based on filename) highlight as.")) | pht('Override what language files (based on filename) highlight as.')) | ||||
| ->setDescription( | ->setDescription( | ||||
| pht( | pht( | ||||
| "This is an override list of regular expressions which allows ". | 'This is an override list of regular expressions which allows '. | ||||
| "you to choose what language files are highlighted as. If your ". | 'you to choose what language files are highlighted as. If your '. | ||||
| "projects have certain rules about filenames or use unusual or ". | 'projects have certain rules about filenames or use unusual or '. | ||||
| "ambiguous language extensions, you can create a mapping here. ". | 'ambiguous language extensions, you can create a mapping here. '. | ||||
| "This is an ordered dictionary of regular expressions which will ". | 'This is an ordered dictionary of regular expressions which will '. | ||||
| "be tested against the filename. They should map to either an ". | 'be tested against the filename. They should map to either an '. | ||||
| "explicit language as a string value, or a numeric index into ". | 'explicit language as a string value, or a numeric index into '. | ||||
| "the captured groups as an integer.")) | 'the captured groups as an integer.')) | ||||
| ->addExample('{"@\\.xyz$@": "php"}', pht('Highlight *.xyz as PHP.')) | ->addExample('{"@\\.xyz$@": "php"}', pht('Highlight *.xyz as PHP.')) | ||||
| ->addExample( | ->addExample( | ||||
| '{"@/httpd\\.conf@": "apacheconf"}', | '{"@/httpd\\.conf@": "apacheconf"}', | ||||
| pht('Highlight httpd.conf as "apacheconf".')) | pht('Highlight httpd.conf as "apacheconf".')) | ||||
| ->addExample( | ->addExample( | ||||
| '{"@\\.([^.]+)\\.bak$@": 1}', | '{"@\\.([^.]+)\\.bak$@": 1}', | ||||
| pht( | pht( | ||||
| "Treat all '*.x.bak' file as '.x'. NOTE: We map to capturing group ". | "Treat all '*.x.bak' file as '.x'. NOTE: We map to capturing group ". | ||||
| "1 by specifying the mapping as '1'")), | "1 by specifying the mapping as '1'")), | ||||
| $this->newOption( | $this->newOption( | ||||
| 'style.monospace', | 'style.monospace', | ||||
| 'string', | 'string', | ||||
| '10px "Menlo", "Consolas", "Monaco", monospace') | '10px "Menlo", "Consolas", "Monaco", monospace') | ||||
| ->setLocked(true) | ->setLocked(true) | ||||
| ->setSummary( | ->setSummary( | ||||
| pht("Default monospace font.")) | pht('Default monospace font.')) | ||||
| ->setDescription( | ->setDescription( | ||||
| pht( | pht( | ||||
| "Set the default monospaced font style for users who haven't set ". | "Set the default monospaced font style for users who haven't set ". | ||||
| "a custom style.")), | "a custom style.")), | ||||
| $this->newOption( | $this->newOption( | ||||
| 'style.monospace.windows', | 'style.monospace.windows', | ||||
| 'string', | 'string', | ||||
| '11px "Menlo", "Consolas", "Monaco", monospace') | '11px "Menlo", "Consolas", "Monaco", monospace') | ||||
| ->setLocked(true) | ->setLocked(true) | ||||
| ->setSummary( | ->setSummary( | ||||
| pht("Default monospace font for clients on Windows.")) | pht('Default monospace font for clients on Windows.')) | ||||
| ->setDescription( | ->setDescription( | ||||
| pht( | pht( | ||||
| "Set the default monospaced font style for users who haven't set ". | "Set the default monospaced font style for users who haven't set ". | ||||
| "a custom style and are using Windows.")), | "a custom style and are using Windows.")), | ||||
| ); | ); | ||||
| } | } | ||||
| } | } | ||||