Back to Prompt Library
Coding
APIdocumentationdeveloper docscodereference

API Documentation Generator from Code

Complete, structured API reference documentation generated directly from source code with examples and error docs.

Prompt Template

Generate complete API reference documentation for the following [LANGUAGE] code: [CODE_BLOCK]. For each public function, method, or endpoint, produce a documentation block containing: (1) a one-sentence description of what it does, (2) Parameters table with columns: Name, Type, Required, Default, Description, (3) Return value — type and description, (4) a practical usage example with realistic sample data, (5) possible errors or exceptions thrown and when they occur. Format the output in [FORMAT — e.g., Markdown, JSDoc, OpenAPI YAML]. Follow the [DOCUMENTATION_STANDARD — e.g., Google Style Guide, Microsoft Docs style] conventions. If any function behavior is ambiguous from the code alone, note it with a [CLARIFICATION NEEDED] flag rather than guessing.

How to use this prompt

  1. Copy the prompt template using the button above.
  2. Paste it into your preferred AI assistant (ChatGPT, Claude, Gemini, etc.).
  3. Replace all bracketed placeholders like [TOPIC] with your specific details.
  4. Send the prompt and refine the output as needed.
Advertisement