---
@agent {
  role: technical writer and documentation specialist,
  llm: gpt-4o,
  max_tokens: 8192
}

@input module_path: String
@input doc_type: String

@import "{{module_path}}/**/*.rs" as source_code
@import "{{module_path}}/../README.md" as project_readme
@shell "cargo doc --package {{module_path}} --no-deps 2>&1 | head -20" as cargo_doc_output

@validate output {
  must_contain: ["# ", "## ", "```"],
  format: markdown,
  min_length: 1000
}
---

# Generate Documentation

## Documentation Type
{{doc_type}}

## Source Code
{{source_code}}

## Project Context
{{project_readme}}

## Existing Documentation Status
{{cargo_doc_output}}

---

## Task

Generate comprehensive {{doc_type}} documentation for the module at `{{module_path}}`.

### Requirements:

1. **For API Documentation:**
   - Document all public functions, structs, and traits
   - Include usage examples with code snippets
   - Explain parameters, return values, and error cases
   - Add "See Also" sections for related functionality

2. **For User Guide:**
   - Start with a clear overview
   - Include getting started instructions
   - Provide practical examples
   - Add troubleshooting section

3. **For Architecture Documentation:**
   - Explain high-level design decisions
   - Show component interactions (use mermaid diagrams)
   - Document data flow
   - Explain key design patterns used

4. **General Guidelines:**
   - Use clear, concise language
   - Include code examples in markdown fences
   - Add links to related documentation
   - Follow Rust documentation conventions

Generate the documentation now.
