Guide-linked quiz · Medium Level

How to Write Code Documentation with AI Quiz

Check how to prompt AI for code docs, validate examples against implementation, and keep generated explanations accurate.

Question 1 of 8

An assistant drafts a docstring for a function that validates a file path. What should the developer verify first?

Preview every question8 questions

Answers and explanations appear as you take the quiz.

  1. An assistant drafts a docstring for a function that validates a file path. What should the developer verify first?
    • The described inputs, return value, side effects and edge cases against the code and tests
    • Whether the prose uses the most technical vocabulary
    • Whether the comment is longer than the function
    • Whether the model sounds confident
  2. A README says to run a setup command generated by AI. What is a strong validation step?
    • Assume it works because the command is familiar
    • Remove all installation steps
    • Run it in a clean environment and confirm it matches the project scripts and configuration
    • Ask the assistant to repeat the command with more confidence
  3. Which inline comment is most useful?
    • A paraphrase of the next line with no added context
    • A note explaining a non-obvious invariant or reason for the code
    • A claim that the function is secure without evidence
    • A list of unrelated TODOs
  4. A generated API example imports a plausible package name not used in the repository. What should happen?
    • Keep it because the package name looks conventional
    • Change the dependency file to match the example without review
    • Delete the API documentation
    • Check the import against actual dependencies and run the example
  5. Why should developers avoid sending secrets to an unapproved coding assistant?
    • The code or context may be processed under data-handling terms that have not been approved
    • Secrets make comments harder to read
    • The assistant needs every credential to understand a function
    • A README cannot describe a credential safely
  6. A performance paragraph claims an algorithm is O(n), but no analysis or test supports it. What is the responsible edit?
    • Keep it because asymptotic notation sounds precise
    • Ask the model to invent a benchmark
    • Remove or qualify the claim until it is verified
    • Replace it with a security guarantee
  7. A new CLI flag changes behavior. When should its documentation be updated?
    • Only after users report that the README is wrong
    • With the code change and review, including a checked example
    • Never, because flags are discoverable from source
    • After deleting the tests
  8. Why might a code assistant describe an incorrect design reason even when it reads the function?
    • Source code contains every team decision automatically
    • Tests always explain product intent completely
    • Documentation never needs human input
    • The rationale or operational context may not be inferable from source code alone

Keep testing yourself

More quizzes picked for your level.

View all quizzes