happiness (^_^) (^_^) (^_^) (^_^) (^_^) (^_^) (^_^) (^_^) (^_^) (^_^) (^_^) (^_^) happiness

tsdocを書くのが面倒なので、promptエンジニアリングをがんばります

要件

  • 選択した箇所に対して、documentを書いてくれる
  • GenieAI のinsertボタンを押せば、完結する
  • 選択したプログラミング言語に応じて、最も支配的なdocument形式で書いてくれる(or 設定値を読み込んで読んでくれても良い)
  • 書くのはdocumentのコメントのみで、一行一行に書いてはいけない

環境

copilot labsと違って自分でプロンプト定義できるのが良いですね。 多分labsもそのうちできるようになると思う。

試した

※関数は超適当です

default

Q

Add comments for the following code

A

/**
 * This function formats a date string to the nearest half hour.
 * 
 * @param {number} a - Number representing a value.
 * @param {number} b - Number representing another value.
 * @returns {number} - A formatted date string in "yyyy/MM/dd HH:mm" format.
 */
export function formatDateToNearestHalfHour(a: number, b: number): number {
  // create a new Date object
  const date = new Date();

  // get the current minutes of the hour
  const minutes = date.getMinutes();

  // round down the minutes to the nearest half hour
  date.setMinutes(minutes - (minutes % 30));

  // set the seconds to 0 to remove any seconds from the formatted date string
  date.setSeconds(0);

  // return the formatted date string using the formatDate function
  return formatDate(date, "yyyy/MM/dd HH:mm")
}

ちょっと惜しい

2回目

Add comment  for the following code on top of the code as a professional software engineer If the code is a function or class, please infer the programming language and write most appropriate documentation format. 

たまにコメントが付く

3回目

Q

Add comment  for the following code on top of the code as a professional software engineer If the code is a function or class, please infer the programming language and write most appropriate documentation format to the top of the code. 

A

/**
 * Returns a formatted date string to the nearest half hour.
 *
 * @param {number} a - A number representing some value.
 * @param {number} b - Another number representing some value.
 * @returns {number} - A formatted date string in the "yyyy/MM/dd HH:mm" format.
 */
export function formatDateToNearestHalfHour(a: number, b: number): number {
  const date = new Date();
  const minutes = date.getMinutes();
  date.setMinutes(minutes - (minutes % 30));
  date.setSeconds(0);
  return formatDate(date, "yyyy/MM/dd HH:mm")
}

まあまあ良くなった。多分キャッシュがリセット去れても、引き継ぎそうなので良いと思う。