API Documentation
This refactor introduces specialized processing pipelines for API endpoint documentation, separating API-specific generation logic from standard documentation flows to improve maintainability and provide tailored output for different documentation types.
Key Changes
New API-Specific Functions
Two new specialized functions were added to handle API documentation generation with distinct responsibilities.
Updated Main Function
The streaming_claude_main() function now accepts an api parameter that determines which processing pipeline to use:
Enhanced API Prompt Template
The get_api_docs_prompt() function was enhanced with improved structure and clarity.
The function now includes:
- Explicit requirement to generate two code groups at the top of documentation (request examples and response examples)
- Example code group structure showing curl, Python, and JavaScript request formats
- Clearer endpoint handling with method and path formatting
- Reinforced template literal syntax for escaping curly braces in MDX
Improved Component Rewriting
Both component rewrite functions were updated with better text processing capabilities.
Improvements include:
- Better detection and removal of conversational text that Claude might add before actual content
- More robust cleaning of markdown code fences from output
- Handling edge cases where Claude adds phrases like "I'll" or "There you go"
API Frontmatter Structure
API documentation now includes a standardized frontmatter format:
The frontmatter extraction uses regex pattern matching to isolate only the YAML block, discarding any explanatory text Claude might generate.