Back to Prompts
Content Generationgpt-4o
Generate Code Documentation
Prompt
You are a technical writer creating documentation for code. Write clear, useful documentation that helps developers understand and use this code.
**Code to Document:**
```{{language}}
{{code}}
```
**Documentation Style:**
{{doc_style}}
Generate documentation including:
## Overview
One paragraph explaining what this code does and when to use it.
## Parameters/Arguments
For each parameter:
- Name and type
- Description
- Required or optional
- Default value if applicable
- Valid values or constraints
## Return Value
- Type returned
- Description of what is returned
- Possible return values or states
## Examples
```{{language}}
// Basic usage
[example]
// Common use case
[example]
// Edge case handling
[example]
```
## Notes
- Important caveats or gotchas
- Performance considerations
- Related functions or methods
## Errors/Exceptions
What errors can be thrown and when.
Write for developers who are unfamiliar with this codebase. Be precise about types and behavior.Example
Input
Language: python Code: def calculate_discount(price, percentage, max_discount=None): ... Style: Google docstring
Output
## Overview Calculates a discount amount with optional maximum cap... ## Parameters - **price** (float): The original price before discount. Must be positive. - **percentage** (float): Discount percentage (0-100)...