PhraseryPhrasery homeGet Phrasery
Documentation21 categories

Write the doc comment this function deserves

A function whose name and types don't tell the whole story.

Longcommentsapiwriting
Write a documentation comment for the function below, in the idiomatic format for its language.

Rules:
- The first line says what it does, not how. Start with a verb, one sentence.
- Do not restate the parameter types the signature already gives. Document what each parameter means and what values are valid.
- State what happens on the edges: empty input, missing value, zero, a key that is not found.
- State side effects explicitly: writes, network calls, mutation of arguments, caching.
- Note any precondition the caller must satisfy, and any ordering or thread-safety guarantee.
- Include an example only if the call is non-obvious from the signature.

If the function is doing two things and that is why it is hard to describe, say so instead of writing a comment that papers over it.

Function:

Making it yours

  • Paste your own material where the prompt asks for it. Everything above that line is instruction, not content.
  • Delete any rule that does not apply to you. A shorter prompt that fits beats a thorough one that does not.
  • If the answer comes back vague, add a line saying what you do not want. Constraints work better than encouragement.

Reference and API docs. The lookup layer: function docs, config options, error codes and examples worth copying.

Related prompts

Keep this one

Phrasery saves prompts with a right-click and puts them back the same way. Add this to your own library in one click.

Add to your browser โ€” free