GH-300 - Improve developer productivity with GitHub Copilot - Section 5.1

Use Copilot for code generation, refactoring, documentation, and modernising legacy code.

Use GitHub Copilot to generate code, refactor existing code, write documentation and comments, generate sample data, and modernise legacy code. Match a development task to the Copilot capability that accelerates it without sacrificing review.

Code generationRefactoringDocumentationLegacy modernisation

Practice question for this objective

Free sampleImprove developer productivity with GitHub Copiloteasy

A developer has finished a public utility function and wants Copilot to draft a documentation comment describing its parameters and return value directly above the function in the editor. Which Copilot capability is the most direct fit for this task?

  • APull request summaries, which Copilot writes on GitHub to describe the overall changes in a branch rather than documenting one function inside the editor.
  • BAsking Copilot to generate a documentation comment for the function, which it drafts inline or in Chat covering the parameters and the return value. Correct
  • CContent exclusions, which restrict which files Copilot may read as context and therefore cannot author a documentation comment above the function for the developer.
  • DSeat administration in Copilot Business, which lets an admin assign licences through the REST API but does not draft any documentation for a function.
Use Copilot to generate documentation comments describing a function's parameters and return value, distinct from pull request summaries. Copilot can read a selected function and draft a documentation comment covering its parameters and return value, inline or through Chat. Pull request summaries describe a whole branch on GitHub, while content exclusions and seat administration are unrelated controls that do not author documentation.

Why A is wrong: Tempting because summaries are documentation, but they describe a whole pull request on GitHub, not a single function's parameters and return value in the file.

Why B is correct: Correct: Copilot can generate a doc comment for the selected function, describing its parameters and return value, which is exactly the task described.

Why C is wrong: Content exclusions only limit context sources; they perform no authoring and so cannot produce a documentation comment for the function.

Why D is wrong: Seat administration manages licences for an organisation; it has nothing to do with writing a documentation comment for a function in the editor.

See more GH-300 practice questions, answers explained.

More in this domain

Back to all Improve developer productivity with GitHub Copilot objectives, or the GH-300 cert hub.

Examworthy is not affiliated with or endorsed by GitHub. Original, blueprint-aligned practice material only.