from docs import generate_docs
import gradio as gr

DESCRIPTION = "GitHub Repo Documentation Generator"

# Define the Gradio Blocks interface.
with gr.Blocks(theme=gr.themes.Origin(primary_hue="red", secondary_hue="pink"), title="GitHub Repo Documentation Generator") as demo:
    gr.HTML(
        f"""<h1><span>{DESCRIPTION}</span></h1>""",
        elem_id="title",
    )
    gr.Markdown(
        "Enter a GitHub repository URL or ID (in the format `user/repo`) below. "
        "This tool fetches repository details and uses the Groq API to generate documentation."
    )
    gr.Markdown("liek this spaces if this spaces helpfull")
    with gr.Row():
        repo_id_input = gr.Textbox(
            label="GitHub Repository URL or ID",
        )
        generate_button = gr.Button("Generate Documentation")

    output_box = gr.Textbox(
        label="Generated Documentation",
        lines=20, 
        interactive=True,
    )
    gr.Markdown("<div style='text-align: center;'>Made with ❤ by <a href='https://huggingface.co/theNeofr'>NeoPy</a></div>")

    # When the button is clicked, call the generate_docs function.
    generate_button.click(fn=generate_docs, inputs=repo_id_input, outputs=output_box)

# Launch the Gradio app.
demo.launch(debug=True)