In this tutorial, you'll build a documentation generator coding assistant that reads source code, understands its structure, and automatically generates comprehensive documentation. This demonstrates how to use the Agent SDK for documentation maintenance.

Prerequisites:
  • Completed Code Reviewer Agent
  • Node.js 16+ (for TypeScript), Python 3.10+ (for Python), Java 11+ (for Java), Go 1.16+ (for Go), Swift 5.5+ (for Swift), or Rust 1.60+ (for Rust)
  • SDK installed for your chosen language
  • API key from your LLM provider (set as AUTOHAND_API_KEY)

What You'll Build

A documentation generator coding assistant that:

  • Reads source code files
  • Identifies functions, classes, and methods
  • Generates README.md documentation
  • Creates inline code comments
  • Generates API documentation in Markdown
  • Updates existing documentation

Step 1: Create Sample Code

Create a sample code file to document in your chosen language:

Step 2: Create Documentation Agent

Create an agent with documentation generation capabilities in your chosen language:

Step 3: Generate Documentation

Run the documentation generator agent on your sample code in your chosen language:

Key Concepts

1
Code Understanding

The agent reads and analyzes source code to understand its structure and purpose.

2
Documentation Generation

Using WRITE_FILE to create comprehensive README.md and documentation files.

3
Inline Comments

Using EDIT_FILE to add inline documentation comments directly in source code.

4
API Documentation

Generating API documentation in Markdown format with examples.

Complete Example

Here's the complete example with cleanup:

Real-World Applications

This pattern can be applied to:

  • API documentation: Auto-generate API docs from source code
  • README maintenance: Keep project READMEs up to date automatically
  • Code comments: Add documentation to undocumented code
  • Migration guides: Generate documentation for version upgrades
  • Onboarding: Create developer onboarding documentation

Next Steps

๐Ÿ“ View the Example

See the complete example in the SDK repositories.

TypeScript Examples โ†’

๐Ÿงช Testing Agent

Learn how to build agents that generate automated tests.

Next Tutorial โ†’

๐Ÿ“š Explore More

Check out all examples in the SDK repositories.

Agent SDK Overview โ†’