diff --git a/package.json b/package.json index 0fb7e2c2..d886fe2c 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ { "id": "sourcery.login", "title": "Login", - "description": "Unlock all of Sourcery's features, including 14 a day trial of Sourcery Pro\n[Login](command:sourcery.login)", + "description": "Unlock all of Sourcery's features, including a 14 day trial of Sourcery Pro\n[Login](command:sourcery.login)", "media": { "markdown": "walkthrough/login.md" }, @@ -94,8 +94,8 @@ }, { "id": "sourcery.openWelcomeFile", - "title": "Get your first recommendation", - "description": "Get started by opening our tutorial \n[Open tutorial](command:toSide:sourcery.welcome.open)\n Put the cursor over the underlined code to see the refactoring suggestion. \n You can see all Sourcery's recommendations in the [Problems Pane](command:workbench.actions.view.problems)", + "title": "Explore Sourcery", + "description": "Get started by opening our tutorial \n[Open tutorial](command:toSide:sourcery.welcome.open)\n Ask Sourcery a question to improve your code. \n You can enable or disable the Sourcery Code Lenses above code for easy access. \n[Toggle Code Lens](command:sourcery.chat.toggleCodeLens)\n", "media": { "markdown": "walkthrough/view_welcome_file.md" }, @@ -105,8 +105,8 @@ }, { "id": "sourcery.acceptRecommendation", - "title": "Accept your first recommendation", - "description": "Put the cursor on an underline, then click the lightbulb or use the quick fix hotkey to show the code actions.\n Take the `Sourcery - Convert for loop into list comprehension` option to accept the change.\n", + "title": "Use Sourcery's In-Line Suggestions", + "description": "Sourcery suggests ways to improve your code quality while you work. Put your cursor on an underline, then click the lightbulb or use the quick fix hotkey to show the code actions.\n To see this in action scroll down to the `refactoring_example` function and take the `Sourcery - Convert for loop into list comprehension` option to accept the change.\n", "media": { "markdown": "walkthrough/accept_recommendation.md" }, @@ -124,25 +124,6 @@ "completionEvents": [ "onCommand:sourcery.config.create" ] - }, - { - "id": "sourcery.customRules", - "title": "Add custom rules", - "description": "You can add your own custom rules to Sourcery!\nFollow the tutorial to find out how.", - "media": { - "markdown": "walkthrough/custom_rules_tutorial.md" - } - }, - { - "id": "sourcery.advancedFeatures", - "title": "Advanced Features", - "description": "With a Sourcery Pro account you can use Sourcery's advanced features on any project. Otherwise, you can use them on any open source project. \nThese include:\nRight click on a folder and choose 'Sourcery - Scan for refactorings'\n\n You can also try out 'Sourcery - Detect Clones' to find duplicate or near-duplicate code\nTo find out about our Team plan, including pre-commit hook and CLI:\n[Open our documentation](https://docs.sourcery.ai/Plans/Sourcery-Team/)\n", - "media": { - "markdown": "walkthrough/refactoring_scan.md" - }, - "completionEvents": [ - "onCommand:sourcery.refactor.workspace" - ] } ] } diff --git a/walkthrough/Ask_Sourcery.gif b/walkthrough/Ask_Sourcery.gif new file mode 100644 index 00000000..aff38c92 Binary files /dev/null and b/walkthrough/Ask_Sourcery.gif differ diff --git a/walkthrough/Sourcery_Login.gif b/walkthrough/Sourcery_Login.gif new file mode 100644 index 00000000..eb67c835 Binary files /dev/null and b/walkthrough/Sourcery_Login.gif differ diff --git a/walkthrough/accept_recommendation.md b/walkthrough/accept_recommendation.md index 14a300bd..e05bfe04 100644 --- a/walkthrough/accept_recommendation.md +++ b/walkthrough/accept_recommendation.md @@ -1,3 +1,10 @@ +## In-Line Suggestions +In addition to interacting with Sourcery through chat or through recipes and code lenses, Sourcery will also passively review your code and make suggestions to improve your code quality, readability, and maintainability. + +In Python, JavaScript, and TypeScript files you'll start to see Sourcery underline sections of your code where it has a reccomendation. You can hover over these underlined pieces of code to see the suggestion Sourcery is proposing. + +![Refactoring code with Sourcery](Sourcery_3_Ways_to_Refactor_VS_Code.gif) + ### Accept a Suggestion To accept a suggestion you can: diff --git a/walkthrough/configuration.md b/walkthrough/configuration.md index 6d9c122f..6ff1f02a 100644 --- a/walkthrough/configuration.md +++ b/walkthrough/configuration.md @@ -39,6 +39,23 @@ github: Here is the full list of configurable settings +## Enabling or Disabling the Coding Assistant +You can control whether or not the Sourcery Coding Assistant (Chat, Recipes, & Code Reviews) is enabled through your user level `sourcery.yaml` file or your project level `.sourcery.yaml` file. + +To enable the coding assistant add in the following lines: + +```yaml +coding_assistant: + enabled: True +``` + +To disable it, update the code above to: + +```yaml +coding_assistant: + enabled: False +``` + ## Ignoring Paths or Files Any path or file you specify to be ignored will be ignored both in your IDE & in @@ -290,8 +307,3 @@ For example: github: sourcery_branch: sourcery/{base_branch} ``` - -## Advanced Features - -For refactorings related to the detect clones feature please see our section on -[Advanced Features](https://docs.sourcery.ai/Advanced-Features.md) diff --git a/walkthrough/login.md b/walkthrough/login.md index 608f20d5..2a2510ce 100644 --- a/walkthrough/login.md +++ b/walkthrough/login.md @@ -11,8 +11,16 @@ After those 14 days you can choose to upgrade to Pro or you can keep using Sourc Sourcery is free to use for students and educators on open source and closed source projects. Email us at [students@sourcery.ai](mailto:students@sourcery.ai) and we'll get you set up with a free plan. -### Login +### Log In -After [signing up](https://sourcery.ai/signup/?utm_source=VS-Code), login by +After [signing up](https://sourcery.ai/signup/?utm_source=VS-Code), log in by opening the command palette (Ctrl/Cmd+Shift+P) and executing the -`Sourcery: Login` command. +`Sourcery: Login` command. Or open the Sourcery sidebar (click our hexagonal logo) and click the log in button. + +![Logging in with Sourcery](Sourcery_Login.gif) + +### Opting Into Sourcery's Coding Assistant + +There are two main ways you can use Sourcery as a pair programmer. One is through our rules-based in-line suggestions that run fully locally and that you'll see appear in your code. The other is through our Coding Assistant which you can ask questions to, can write new code or update your existing code, and more. The Coding Assistant relies on third party large language models and you need to opt into using it before you can start. + +To opt into use the Coding Assistant, open the Sourcery sidebar, and click the Opt In button. If you choose not to opt in, you can still use the rules-based suggestions from Sourcery fully locally diff --git a/walkthrough/view_welcome_file.md b/walkthrough/view_welcome_file.md index 8526413a..ef9fbc7f 100644 --- a/walkthrough/view_welcome_file.md +++ b/walkthrough/view_welcome_file.md @@ -1,34 +1,28 @@ -## Finding Your First Refactoring +## Using Sourcery as Your Pair Programmer -Sourcery continually checks your code and looks for opportunities to refactor it -to make it clearer, cleaner, and easier to work with. In your IDE, Sourcery will -underline or highlight any section of code where it can make a refactoring. +Sourcery works in 2 ways: +1. Gives you instant suggestions for improvements and refactorings to your Python, JavaScript, and TypeScript code. +2. Acts as an AI powered pair programmer allowing you to ask it questions, write new code, and interact with existing code + +Let's take a look at how you can interact with it in VS Code ### In the tutorial Once you open the tutorial you should see this example: ```python -def refactoring_example(spellbook): - result = [] - for spell in spellbook: - if spell.is_awesome: - result.append(spell) - return result +def days_between_dates(date1, date2): + d1 = datetime.datetime.strptime(date1, '%Y-%m-%d').date() + d2 = datetime.datetime.strptime(date2, '%Y-%m-%d').date() + delta = d2 - d1 + return delta.days ``` -You should see Sourcery immediately highlight the `result = []` line with a -refactoring suggestion. - -Hover your mouse over the underlined section to see a description of the change -and a diff of Sourcery's refactoring. +Above the function you'll see a few commands - these are Code Lenses that you can use to interact with Sourcery. Try clicking the "Ask Sourcery" Code Lens and asking it to update the code to use `dateutil`. The answer will appear in the Sourcery sidebar chat. -To accept one of Sourcery's changes, bring up the code actions/quick fix menu, -and choose to apply the changes. Or you can click on the lightbulb icon to apply -the changes. +![Sourcery updating code](Ask_Sourcery.gif) -![Accepting Changes In VS Code](Sourcery_3_Ways_to_Refactor_VS_Code.gif) +### More ways Sourcery can help -You can also bring up all of the changes Sourcery is suggesting to your open -files by opening up the Problems window. +Sourcery can interact with your code in a number of other ways. On the same function try clicking the `Generate Docstrings`, `Generate Tests`, and `Explain Code`Code Lenses.