Tokens Not Jokin’
- How API Documentation Format Affects AI Code Generation
Acknowledgments
Chapter 1: Who’s Reading Your Docs Now?
- The Shift Nobody Planned For
- The Invisible Integration
- What AI Actually Does With Your Docs
- Your Docs Have Two Audiences Now
- The Metrics Blind Spot
- What This Book Will Show You
Chapter 2: The Token Budget
- What Tokens Actually Are
- The Four-Format Comparison
- The Attention Problem
- Why Bigger Windows Don’t Fix This
- The Compounding Problem
- The Caching Argument
- The Cost Math
- The Real Budget
Chapter 3: The Measurement Gap
- An Autopsy of Traditional Metrics
- The Metrics That Matter for AI
- AI Acceptance Testing
- Building Your Testing Pipeline
- The Dashboard You Actually Need
- Closing the Gap
Chapter 4: Building a Fair Test
- The Contamination Problem
- The BookClub API: Simple Baseline
- The EventForge API: Complexity Gradient
- Why Two APIs
- The Four Formats
- Controlling Variables
- Why Temperature 0
- Reproducibility
Chapter 5: The Models
- Cloud Models
- Local Models
- Why These Four
- What We Ran
- The Cost of Testing
- What the Models Tell Us (Preview)
Chapter 6: The Results
- Cloud Models: 100% Across the Board
- Small Models: Where Format Matters Most
- Beyond Pass Rates: Format and Code Patterns
- The Variance Finding
- The Four Formats
- The Summary
Chapter 7: The Four Formats
- YAML
- OpenAPI 3.0
- DON
- Markdown
- The Format Summary
Chapter 8: DON: A New Kind of Documentation
- The Hypothesis
- The Result: 100% on Cloud Models
- The Aggregate
- Explicit vs Implicit: The Critical Distinction
- Documentation as a Code Quality Control Mechanism
- Small Model Behavior: The Complexity Wall
- What Else Could Annotations Influence?
- DON as a Proof of Concept
Chapter 9: Choosing Your Format
- The Decision Framework
- The Dual-Format Strategy
- Adding Behavioral Annotations
- What to Cut
- Migration Checklist
Chapter 10: Building AI Acceptance Tests
- What You’re Building
- Prerequisites
- Step 1: Define Your Tasks
- Step 2: Prepare Your Documentation
- Step 3: Build the Test Harness
- Step 4: Run Your First Test
- Step 5: Interpret the Results
- Step 6: Compare Formats
- Step 7: Add a Local Model
- Sample Size and Statistical Power
- Integrating with CI/CD
- Using Our APIs for Benchmarking
- Common Pitfalls
Chapter 11: Token Optimization Techniques
- The Optimization Stack
- Removing Redundancy
- Consolidating Descriptions
- Strategic Ordering
- Per-Endpoint Delivery
- The Annotation Budget
- Before/After: A Real Optimization
- Measuring Improvement
- When to Stop
Chapter 12: Serving Docs to AI
- The Serving Problem
- Approach 1: Separate Paths
- Approach 2: Content Negotiation
- Approach 3: Discovery Mechanisms
- Per-Endpoint Delivery
- MCP Server Integration
- CDN and Caching
- Versioning Strategy
- Monitoring
- Implementation Checklist
Chapter 13: What the Data Shows
- Format Explains More Than Model Choice
- The Wrong Question
- The Documentation Author’s Influence
- The Cost Argument
- What API Providers Can Control
- Implications
- The One-Sentence Version
Chapter 14: What We Don’t Know Yet
- Single-Endpoint Tasks
- Python Only
- REST APIs Only
- Four Models at One Point in Time
- No Models Between 7B and Cloud Scale
- DON Annotations Beyond Error Handling
- Determinism and Temperature
- Long-Term Format Drift
- What Should Be Tested Next
Chapter 15: What Comes Next
- Structured Specs as Source of Truth
- Documentation as Code Quality Input
- Automated Testing Loops
- MCP and Documentation Convergence
- What Standards Could Help
- What Might Change
- What to Do This Week
Appendix A: Complete Test Methodology
- Study Design
- Test Infrastructure
- Dataset Size
- Statistical Methods
- Power Analysis
- Task Design
- Reproducibility
- Data Availability
- Threats to Validity
Appendix B: Format Specifications
- Format Size Comparison
- YAML Format
- OpenAPI 3.0 Format
- DON Format
- Markdown Format
- Conversion Examples
Appendix C: The DON Specification
- Format Structure
- Annotation Syntax
- Complete Example: BookClub API in DON
- Writing Your Own DON Spec
- Incorporating DON Principles Into Existing Formats
Appendix D: Results Tables
- Master Pass Rate Table
- OpenAPI Failure Detail
- Code Pattern Tables
- Code Length Tables
- Variance Explained (Eta-Squared)
- Determinism Analysis
- Complex Task Handling (EventForge Cloud)
- Token Efficiency Summary
- Statistical Test Reference
Appendix E: Verified Claims Reference
- Claims You Can Use Freely
- Claims That Require Qualification
- Common Misinterpretations to Avoid
- Every Statistical Claim with Source
- For Presentations
Appendix F: Tools & Resources
- Companion Repository
- Token Counting
- AI Model APIs
- Format Conversion
- Test Frameworks
- Documentation Platforms
- Discovery Mechanisms
- AI Acceptance Testing Starter Kit
- Repository Contents
- Further Reading