M365 GitHub Copilot Sharing
M365 GitHub 副驾驶分享
5 月 17 日 · 阅读 1 分钟 · 5 月 17 日编辑
M365 GitHub Copilot 每周分享#12
在代码文件中提供顶级注释
This is most helpful if you have a blank file or empty codebase. In other words, if GitHub Copilot has zero context of what you want to build or accomplish, provide the context with a top-level comment in your code file, it could help both GitHub Copilot and yourself.
如果您有空白文件或空代码库,这将非常有帮助。换句话说,如果 GitHub Copilot 对您想要构建或完成的内容的上下文为零,请在代码文件中通过顶级注释提供上下文,这对 GitHub Copilot 和您自己都有帮助。
When prompting GitHub Copilot, think of the process as having a conversation with someone: How should I break down the problem so we can solve it together? How would I approach pair programming with this person?
当提示 GitHub Copilot 时,将这个过程想象成与某人对话:我应该如何分解问题,以便我们可以一起解决它?我将如何与这个人进行结对编程?
For example, when building a markdown editor in Next.js, we could write a comment like this
例如,在 Next.js 中构建 Markdown 编辑器时,我们可以编写这样的注释
/* Create a basic markdown editor in Next.js with the following features: 在 Next.js 中创建一个基本的 Markdown 编辑器,具有以下功能: - Use react hooks
- Create state for markdown with default text "type markdown here" - 使用反应钩子 - 使用默认文本“在此处键入 markdown”创建 markdown 状态 - A text area where users can write markdown - 用户可以在其中编写 Markdown 的文本区域 - Show a live preview of the markdown text as I type - 在我输入时显示 Markdown 文本的实时预览 - Support for basic markdown syntax like headers, bold, italics - 支持基本的 Markdown 语法,如标题、粗体、斜体 - Use React markdown npm package - 使用 React markdown npm 包 - The markdown text and resulting HTML should be saved in the component's state and updated in real time - Markdown 文本和生成的 HTML 应保存在组件的状态中并实时更新 */ |