wedocs-plugin icon indicating copy to clipboard operation
wedocs-plugin copied to clipboard

feat: AI doc writer

Open sapayth opened this issue 1 month ago • 7 comments
trafficstars

fixes #176, fixes #177

AI Doc Writer Feature Implementation

📋 Overview

This PR introduces a comprehensive AI-powered documentation writing feature that allows users to generate high-quality documentation content using multiple AI providers directly within the WordPress editor. The feature integrates seamlessly with the existing weDocs plugin architecture and provides a modern, intuitive interface for content generation.

✨ Features

🎯 Core Functionality

  • AI-Powered Content Generation: Generate documentation content using advanced language models
  • Multi-Provider Support: Integration with OpenAI, Anthropic Claude, Google Gemini
  • Context-Aware Generation: Uses existing post content to maintain consistency and avoid duplication
  • Real-time Preview: Preview generated content before insertion into the document
  • Flexible Insertion Modes: Choose between appending to existing content or overwriting the entire document

🛠️ Technical Features

  • WordPress Block Editor Integration: Native Gutenberg sidebar plugin with custom AI icon
  • Centralized AI Settings: Unified settings panel for managing all AI providers and configurations
  • Content Validation: Comprehensive validation of AI-generated content for security and quality
  • Error Handling: Robust error handling with user-friendly messages
  • Internationalization: Full translation support using WordPress i18n functions

🏗️ Architecture

Frontend Components

  • AiDocWriterModal.js: Main modal component for content generation interface
  • AiDocWriterPreview.js: Preview component for reviewing generated content
  • AiDocWriter.js: WordPress plugin registration and sidebar integration
  • AiSettings.js: Settings panel for AI provider configuration
  • aiService.js: Centralized service for AI API interactions

Backend Implementation

  • SettingsApi.php: REST API endpoints for AI settings management
  • functions.php: AI provider configuration and utility functions
  • Assets.php: Asset management and script localization
  • Admin.php: Admin interface integration

Content Generation Flow

  1. User Input: Title, keywords, and optional custom instructions
  2. Context Enhancement: Include existing post content if enabled
  3. AI Processing: Send request to selected AI provider
  4. Content Validation: Validate and sanitize generated content
  5. Preview & Insert: Allow user to review and insert content as WordPress blocks

Workflow

  1. Access: Click AI Doc Writer icon in Gutenberg sidebar
  2. Configure: Enter title, keywords, and review auto-generated instructions
  3. Generate: Click "Generate Content" to create AI-powered documentation
  4. Preview: Review generated content in preview mode
  5. Insert: Accept and insert content as properly formatted WordPress blocks

Privacy Considerations

  • No Data Storage: AI-generated content is not stored on our servers
  • User Control: Users have full control over their content and API usage
  • Transparent Processing: Clear indication of which AI provider is being used

🔄 Extensibility

WordPress Filters

// Customize AI provider configurations
add_filter('wedocs_ai_provider_configs', 'my_custom_providers');

// Customize AI service providers
add_filter('wedocs_ai_service_providers', 'my_custom_service_config');

Summary by CodeRabbit

  • New Features

    • AI Doc Writer in the editor: modal, preview, and insert/overwrite controls for AI-generated docs
    • AI Settings panel: configure providers, models, and API keys
    • Centralized AI service and editor integration plus a new icon and editor panel
    • Modular data stores for docs and settings (improved client-side data handling)
  • Bug Fixes

    • Removed stray debug logging from search
  • Chores

    • Bumped asset build versions, added source maps and build metadata
    • Removed an unused translation entry

sapayth avatar Oct 06 '25 11:10 sapayth