mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-01 12:56:08 -06:00
* Make /api/format handle multiple formatter types * Ignore preferred style if the formatter is a 'one true style' formatter * Add tests for base formatter * Document /api/formats and /api/format/<formatter> usage * Document adding a new formatter * Update amazon config Co-authored-by: Matt Godbolt <matt@godbolt.org>
1.2 KiB
1.2 KiB
Adding a new formatter
-
Add a
etc/config/compiler-explorer.local.propertiesfile- Add a new formatter under the
formatterskey - The new formatter can have the following keys: name, exe, styles, type, version (argument to get version info), versionRe (regex to filter out the right version info)
- Add a
lib/formatters/<formatter>.jsfile using the template below, replacingTypeandtypeas appropriateimport { BaseFormatter } from '../base-formatter'; export class TypeFormatter extends BaseFormatter { static get key() { return 'type'; } } - The value returned by
keyabove corresponds to thetypeproperty you set in the compiler-explorer properties configuration file. - Tweak
format(args, source),getDefaultArguments(),getStyleArguments(style)andisValidStyle(style)as necessary
- Add a new formatter under the
-
Add your
TypeFormattertolib/formatters/_all.jsin alphabetical order -
You can check the output of http://localhost:10240/api/formats to be sure your formatter is there.
-
Make an installer in the infra repository. An example patch for adding an installer can be found here