opengrep 1.1.0

Advanced AST-aware code search tool with tree-sitter parsing and AI integration capabilities
Documentation
//! Documentation generation utilities

use std::fs;
use std::path::Path;

/// Generate API documentation
pub fn generate_api_docs() -> anyhow::Result<()> {
    println!("Generating API documentation...");
    
    let output = std::process::Command::new("cargo")
        .args(&["doc", "--all-features", "--no-deps"])
        .output()?;
    
    if !output.status.success() {
        return Err(anyhow::anyhow!(
            "Failed to generate docs: {}",
            String::from_utf8_lossy(&output.stderr)
        ));
    }
    
    println!("API documentation generated in target/doc/");
    Ok(())
}

/// Generate user guide
pub fn generate_user_guide() -> anyhow::Result<()> {
    let guide_content = include_str!("../docs/guide/user-guide.md");
    let output_path = Path::new("target/doc/user-guide.html");
    
    // Convert markdown to HTML (simplified)
    let html = markdown_to_html(guide_content);
    fs::write(output_path, html)?;
    
    println!("User guide generated: {}", output_path.display());
    Ok(())
}

/// Simple markdown to HTML converter
fn markdown_to_html(markdown: &str) -> String {
    let mut html = String::new();
    html.push_str("<!DOCTYPE html><html><head><title>OpenGrep User Guide</title></head><body>");
    
    for line in markdown.lines() {
        if line.starts_with("# ") {
            html.push_str(&format!("<h1>{}</h1>", &line[2..]));
        } else if line.starts_with("## ") {
            html.push_str(&format!("<h2>{}</h2>", &line[3..]));
        } else if line.starts_with("### ") {
            html.push_str(&format!("<h3>{}</h3>", &line[4..]));
        } else if line.starts_with("```") {
            if line.len() > 3 {
                html.push_str(&format!("<pre><code class='{}'>", &line[3..]));
            } else {
                html.push_str("</code></pre>");
            }
        } else if line.is_empty() {
            html.push_str("<br>");
        } else {
            html.push_str(&format!("<p>{}</p>", line));
        }
    }
    
    html.push_str("</body></html>");
    html
}