In Parrot, a rule set helps you define the rules that Parrot should follow for a given programming language or framework when generating a snippet.

Rule sets are defined on a per-language, per-framework basis. You can define as many rule sets as you’d like.

Creating a New Rule Set

To create a new rule set, head over to Rule Sets page and click the “Create a New Rule Set” button. This will reveal a modal where you can define:

  1. A name for your rule set.
  2. The language/framework the rule set will apply to.
  3. Optionally, a project the rule set should be assigned with (helpful for sharing rule sets with team members who have access to a project).

Once created, you’ll be redirected to your new rule set where you can define the rules that make up that rule set.

Adding Rules to a Rule Set

Rules give you granular control over how Parrot should use certain language or framework features when generating snippets.

There are two ways to add rules to a rule set:

  1. If available, use a template rule provided by Parrot.
  2. Write your own custom rule.

You can add a mix of templated rules and custom rules to a rule set to ensure Parrot generates code to your liking.

Adding a Template Rule

Templated rules cannot be edited. If you want to make changes to a templated rule, add it manually following the “Adding a Custom Rule” steps below.

If Parrot has templates available for your Rule Set’s choosen language/framework, they will show up on the left-hand side of the rule set editor.

Templates are separated into four tabs:

  1. Syntax
  2. Style
  3. Naming
  4. Organization

To add a template to your rule set, just click the green “plus” button to the right of the template preference that you’d like to use.

Once added, your choosen rule template will show up on the right-hand side of the Rule Set editor. If you’d like to remove a template rule from your rule set, just click the red “x” button next to that rule in the list.

Adding a Custom Rule

Custom rules can be added by using the input at the bottom-right of the Rule Set editor. To add a custom rule, type in your preference and then click the “Add Custom Rule” button.

Once added, your custom rulle will show up on the right-hand side of the Rule Set editor in the list above the custom rule input. If you’d like to make changes to a custom rule, just click into the input in the rule set list. If you’d like to remove a custom rule from your rule set, just click the red “x” button next to that rule in the list.

Using a Rule Set

Rule sets are applied when generating a new snippet. Just select the name of the rule set you created following the steps above from the dropdown under the “Language/Framework Rule Set” label in the “Generate” tab.