코드를 변경하여 문서를 최신 상태로 유지하는 것은 어려울 수 있습니다. 그러나 코드베이스를 유지 관리하고 개발자가 코드를 효과적으로 사용할 수 있도록 하려면 좋은 설명서가 필요합니다. Copilot Chat은 기존 코드 설명서를 업데이트하는 데 도움이 될 수 있습니다.
예제 시나리오
범주 이름으로 제품을 검색하는 TypeScript 함수가 있지만 설명서가 최신 상태가 아닌 시나리오를 상상해 보세요.
/**
* Retrieves all products belonging to a specific category.
*
* @param categoryId - The unique identifier of the product category
* @returns Promise that resolves to an array of Product objects
*
* @example
* const products = await getByCategoryName(5);
* // Returns: [{id: 1, name: "Product 1", categoryId: 5}, ...]
*
* @throws {PrismaClientKnownRequestError} If database query fails
* @see {@link https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#findmany}
*/
async getByCategoryName(categoryId: number, page = 1, pageSize = 10): Promise<Products[]> {
return await prisma.products.findMany({
where: { categoryId },
skip: (page - 1) * pageSize,
take: pageSize,
include: {
reviews: {
orderBy: { date: 'desc' },
take: 5,
},
},
});
}
예시 프롬프트
Copilot Chat에게 현재 코드에 따라 문서를 업데이트하도록 요청할 수 있습니다.
Update the existing documentation for the getByCategoryName function to reflect the current implementation.
Update the existing documentation for the getByCategoryName function to reflect the current implementation.
예제 응답
참고 항목
다음 응답이 예제입니다. Copilot Chat 응답은 비결정적이므로 여기에 표시된 응답과 다른 응답을 얻을 수 있습니다.
Copilot에서는 getByCategoryName
함수에 대한 업데이트된 설명서를 만들 것이라고 설명합니다. 그런 다음, 업데이트된 문서를 제공하며 여기에는 이제 발생할 수 있는 PrismaClientKnownRequestError
오류뿐만 아니라 매개 변수와 page
및 pageSize
매개 변수가 포함될 수 있습니다.
예시:
/**
* Retrieves all products belonging to a specific category with pagination and recent reviews.
*
* @param categoryId - The unique identifier of the product category
* @param page - The page number for pagination (default: 1)
* @param pageSize - Number of products per page (default: 10)
* @returns Promise that resolves to an array of Product objects with their 5 most recent reviews
*
* @example
* const products = await getByCategoryName(5, 2, 20);
* // Returns: [{id: 1, name: "Product 1", categoryId: 5, reviews: [...5 recent reviews]}, ...]
*
* @throws {PrismaClientKnownRequestError} If database query fails
* @see {@link https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#findmany}
*/