Copilot: Add new prompt formatting to Markdown files (#57347)
Co-authored-by: Sarah Schneider <sarahs@github.com> Co-authored-by: Sarah Schneider <sarahs@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -24,7 +24,7 @@ Working with legacy code can be challenging for developers, especially when the
|
||||
|
||||
The block of COBOL below connects to a database and inserts a record. The code lacks documentation, which makes it difficult to understand what it does and how it works.
|
||||
|
||||
```text
|
||||
```text id=cobol-insert-record
|
||||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. INSERT-RECORD.
|
||||
|
||||
@@ -75,9 +75,11 @@ INSERT-AND-VALIDATE.
|
||||
|
||||
## Example prompt
|
||||
|
||||
We can use a simple prompt to ask {% data variables.copilot.copilot_chat_short %} to document the code.
|
||||
We can use a simple prompt to ask {% data variables.copilot.copilot_chat_short %} to add documentation to the code.
|
||||
|
||||
`Document this code`
|
||||
```copilot copy prompt ref=cobol-insert-record
|
||||
Comment this code thoroughly
|
||||
```
|
||||
|
||||
> [!NOTE] If you want the documentation generated in another format like Markdown, you can specify the desired output format in the prompt. For example: `Document this code in Markdown`.
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ There may be times where you need to explain complex algorithms or logic in your
|
||||
|
||||
In the C# code below, we have a method which fetches data, retries if there's an error, and updates a status label. You might want to explain, in comments in the code, how the method works and how it handles retries and cancellations.
|
||||
|
||||
```csharp
|
||||
```csharp id=fetch-data-with-retry
|
||||
private static readonly HttpClient _client = new HttpClient();
|
||||
|
||||
public async Task<string> FetchDataFromApiWithRetryAsync(string apiUrl, CancellationToken cancellationToken, int maxRetries, int cancellationDelay, Label statusLabel)
|
||||
@@ -82,7 +82,9 @@ private void UpdateStatusLabel(string message, Label statusLabel)
|
||||
|
||||
We can ask {% data variables.copilot.copilot_chat_short %} to make this code easier to understand using comments.
|
||||
|
||||
`Add comments to this code to make it more understandable`
|
||||
```copilot copy prompt ref=fetch-data-with-retry
|
||||
Add comments to this code to make it more understandable
|
||||
```
|
||||
|
||||
## Example response
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ One of the biggest challenges with legacy code is helping developers understand
|
||||
|
||||
Consider the following COBOL code. If you're a Python developer (as an example), you might not be familiar with COBOL, so you could ask {% data variables.copilot.copilot_chat_short %} to explain the code to you.
|
||||
|
||||
```text
|
||||
```text id=cobol-insert-record
|
||||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. INSERT-RECORD.
|
||||
|
||||
@@ -78,7 +78,9 @@ INSERT-AND-VALIDATE.
|
||||
|
||||
You can ask for an explanation of the COBOL code from the point of view of a Python developer.
|
||||
|
||||
`I'm a Python developer. Help me better understand this code. Please provide analogies.`
|
||||
```copilot copy prompt ref=cobol-insert-record
|
||||
I'm a Python developer. Help me better understand this code. Please provide analogies.
|
||||
```
|
||||
|
||||
## Example response
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ It can be difficult to keep documentation up to date with changes to code. Howev
|
||||
|
||||
Imagine a scenario where you have a TypeScript function that retrieves products by category name, but the documentation is out of date.
|
||||
|
||||
```typescript
|
||||
```typescript id=fetch-products-by-category
|
||||
/**
|
||||
* Retrieves all products belonging to a specific category.
|
||||
*
|
||||
@@ -58,7 +58,9 @@ async getByCategoryName(categoryId: number, page = 1, pageSize = 10): Promise<Pr
|
||||
|
||||
You can ask {% data variables.copilot.copilot_chat_short %} to update the documentation according to the current code.
|
||||
|
||||
`Update the existing documentation for the getByCategoryName function to reflect the current implementation.`
|
||||
```copilot copy prompt ref=fetch-products-by-category
|
||||
Update the existing documentation for the getByCategoryName function to reflect the current implementation.
|
||||
```
|
||||
|
||||
## Example response
|
||||
|
||||
|
||||
Reference in New Issue
Block a user