Smart Inline Completions: Use Cases, Examples, and Exercises
28%
From Documentation to Code
Most of us use comments in code to describe and document what we are building, especially when it's complex logic or when we want to share our work with others. This can be useful for Copilot as well.
Depending on the programming language, you can use a docblock, docstring, PhpDocumentor, Javadoc, or any other form of documentation to give Copilot context about what you are building.
This is the starting point of a class that contains a docstring in the talk method.
class Person:
def talk(self, name):
"""
Make the person talk
"""
If you type the above code, Copilot might suggest the following completion:
class Person:
def talk(self, name):
"""
Make the person talk
"""
print(f"Hello, my name is {name}")
You can also use a better Python docstring that respects the standards of the language you are using:
class Person:
"""
A class representing a person
"""
def talk(self, name):
"""
Make the person talk
:param name: The name of the personBuilding with GitHub Copilot
From Autocomplete to Autonomous AgentsEnroll now to unlock all content and receive all future updates for free.
