Recipes and Code LensesΒΆ

Recipes are shortcuts to allow Sourcery to easily interact with a section of your code in powerful ways.

Sourcery Chat

Recipes and Code Lenses are available in VS Code and JetBrains IDEs.

To start using a recipe, click on the code lens text above a function or class (eg. Generate Tests), select the Ask Sourcery code lens and choose a recipe from the drop down, or select a section of code and click the recipe button in the sidebar.

Currently we have 5 Recipes available:

  • Explain Code: Gives an explanation of what the code selection does and how it does it.
  • Generate Tests: Creates a series of tests for the selected code
  • Generate Docstrings: Creates a docstring for the function/class selected.
  • Optimize Performance: Suggests improvements to the code to improve performance.
  • Simplify Code: Suggests improvements to simplify the code and make it more readable.
Was this page helpful?