Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Description

Linear ticket: N/A

Adds a new fern docs prettify command that uses AI (via BAML) to analyze markdown documentation files and suggest improvements using Fern's documentation components. The command helps enhance docs by intelligently adding Steps, Cards, Callouts, Code Blocks with tabs, Endpoint snippets, and other Fern components where appropriate.

Changes Made

  • Added PrettifyDocs BAML function with comprehensive prompt for analyzing markdown and suggesting Fern component improvements
  • Created prettifyDocsCommand.ts handler with:
    • Recursive markdown file discovery (skips node_modules and hidden directories)
    • LLM integration for content analysis
    • Dry-run mode (default: true) to preview changes before applying
    • Detailed change summaries for each file
  • Integrated command into CLI as fern docs prettify <path> subcommand under docs
  • Added comprehensive Fern components reference embedded in the command for LLM context
  • Added version 2.1.0 entry to CLI changelog
  • Auto-generated BAML client TypeScript types and functions

Testing

⚠️ This PR has not been manually tested yet. Testing should be done after PR creation:

  • Test with single markdown file
  • Test with directory containing multiple markdown files
  • Test dry-run mode (default behavior)
  • Test with --dry-run=false to verify file writing works
  • Test with empty files
  • Test with files that don't need improvements
  • Verify LLM produces reasonable suggestions
  • Verify error handling for LLM failures

Human Review Checklist

High Priority:

  • Review the BAML prompt in packages/cli/ai/baml_src/main.baml - does it provide clear enough instructions for the LLM?
  • Verify file writing logic is safe and won't cause data loss (check prettifyFile function)
  • Check that dry-run mode correctly prevents file modifications
  • Verify the embedded FERN_COMPONENTS_REFERENCE contains accurate examples of all Fern components

Medium Priority:

  • Review file discovery logic - does it correctly skip node_modules and hidden directories?
  • Check error handling for LLM API failures
  • Verify CLI command registration in cli.ts is correct
  • Confirm version bump to 2.1.0 is appropriate for this feature

Low Priority:

  • Review auto-generated BAML client code (mostly mechanical changes)
  • Consider if the large embedded reference string should be moved to a separate file

Notes

  • The command defaults to dry-run mode for safety - users must explicitly pass --dry-run=false to modify files
  • Uses the existing BAML DefaultClient which has fallback providers (OpenAI, Anthropic, Bedrock)
  • Plant-themed examples are used in the prompt as requested

Add new 'fern docs prettify' command that uses AI to enhance documentation with Fern components. The command analyzes markdown files and suggests improvements using:
- Steps for sequential instructions
- Cards for navigation and feature showcases
- Callouts for important information
- Code blocks with tabs and syntax highlighting
- Endpoint snippets for API references
- Accordions for optional details
- Tables for structured data

Features:
- Accepts a file or folder path as argument
- Includes --dry-run flag (default: true) to preview changes
- Uses BAML for LLM integration with fallback providers
- Recursively processes all markdown files in directories
- Provides detailed change summaries for each file

Implementation:
- Added PrettifyDocs BAML function with comprehensive prompt
- Created prettifyDocsCommand handler with file discovery
- Integrated command into CLI docs subcommand structure
- Added version 2.1.0 entry to CLI changelog

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant