Google Drive: Generate Docs from New Code Files

This workflow automates documentation generation for newly uploaded code files in Google Drive. It leverages DocuWriter.ai nodes to produce technical documentation and UML diagrams, then stores results in both Google Docs and Markdown formats. Finally, it notifies your team via email and Slack.

Workflow Overview

  • 🟢 Trigger: Detect new file creation in a Drive folder
  • 🔍 Filter: Allow only code file extensions
  • 📥 Download: Retrieve file content
  • 🛠️ Prepare: Convert binary to text and enrich metadata
  • 📄 Generate Documentation: Create comprehensive docs via DocuWriter.ai
  • 📊 Generate UML: Produce class diagrams from source
  • 🔧 Format: Build HTML payload for Google Docs and content for Markdown
  • 📂 Create Folder: Organize outputs in a timestamped Drive folder
  • 📑 Create Google Doc: Save HTML-formatted documentation
  • 📝 Create Markdown File: Save developer-friendly .md file
  • 🗒️ Create Summary: Aggregate links and metadata
  • 📧 Notify via Email: Send a rich HTML summary
  • 💬 Notify via Slack: Post interactive message with buttons
flowchart TD
  A[Google Drive File Created] --> B[Filter Code Files]
  B --> C[Download File]
  C --> D[Prepare Source Code]
  D --> E[Generate Documentation]
  D --> F[Generate UML]
  E & F --> G[Format Documentation]
  G --> H[Create Docs Folder]
  H --> I[Create Google Doc]
  H --> J[Create Markdown File]
  I & J --> K[Create Summary]
  K --> L[Send Notification Email]
  K --> M[Notify Slack]

Node Summary

Node Name Type Purpose Key Parameters
Google Drive File Created n8n-nodes-base.googleDriveTrigger Listen for new files in Drive folder event: fileCreated
Filter Code Files n8n-nodes-base.code Skip non-code uploads .js, .ts, .py, .java, etc.
Download File n8n-nodes-base.googleDrive Fetch binary data of the code file fileId: {{$json.id}}
Prepare Source Code n8n-nodes-base.code Decode binary, extract sourceCode, metadata filename, extension, size
Generate Documentation n8n-nodes-docuwriter-ai.docuWriter Call DocuWriter.ai for codeDocumentation resource: codeDocumentation
Generate UML n8n-nodes-docuwriter-ai.docuWriter Call DocuWriter.ai for umlDiagram resource: umlDiagram
Format Documentation n8n-nodes-base.code Build HTML & Markdown payloads Inline JS combining docs & UML
Create Docs Folder n8n-nodes-base.googleDrive Make a timestamped folder for outputs operation: create, name
Create Google Doc n8n-nodes-base.googleDrive Save HTML documentation into a Google Doc resource: document, bodyData
Create Markdown File n8n-nodes-base.googleDrive Save .md version alongside the Doc uploadType: media, fileContent
Create Summary n8n-nodes-base.code Aggregate links & metadata for notifications Custom JS to collect IDs & URLs
Send Notification Email n8n-nodes-base.emailSend Email a styled summary with output links HTML table, attachments
Notify Slack n8n-nodes-base.slack Post interactive card with buttons channel, attachments, actions

Detailed Node Descriptions

1. Google Drive File Created

Watches a specified Drive folder and triggers on any new file.

  • Type: googleDriveTrigger
  • Credentials: OAuth2 service account
  • Parameters:
    • event: fileCreated

2. Filter Code Files

Executes a JavaScript snippet to allow only files ending in common code extensions.

  • Type: code
  • Logic: Checks file.name extension against list such as .js, .py, .java

3. Download File

Downloads the binary content of the filtered file.

  • Type: googleDrive
  • Operation: download
  • Parameter: fileId from trigger output

4. Prepare Source Code

Converts binary data to UTF-8 text and enriches the JSON payload with filename, extension, and size.

  • Type: code
  • Output: { sourceCode, filename, fileId, extension, mimeType, size }

5. Generate Documentation

Calls the DocuWriter.ai action node with resource = codeDocumentation to generate technical documentation.

  • Type: docuWriter
  • Parameters:
    • resource: codeDocumentation
    • operation: generate

6. Generate UML

Calls the DocuWriter.ai action node with resource = umlDiagram to produce UML diagrams.

  • Type: docuWriter
  • Parameters:
    • resource: umlDiagram
    • operation: generate, diagramType: class

7. Format Documentation

A code node merges documentation HTML and UML code blocks into one rich HTML string for Google Docs, and composes Markdown content for the .md file.

  • Type: code
  • Features:
    • Embeds generated documentation in <div> containers
    • Inserts UML with <pre><code> blocks

8. Create Docs Folder

Creates a new folder in Drive, named with the current date or timestamp.

  • Type: googleDrive
  • Operation: create on folder
  • Parameter: name: Documentation - <timestamp>

9. Create Google Doc

Creates a Google Doc inside the new folder, using the HTML from Format Documentation.

  • Type: googleDrive
  • Resource: document, operation: create
  • Body: bodyData from formatting node

10. Create Markdown File

Creates a .md file in the same folder containing the Markdown version of the documentation and UML.

  • Type: googleDrive
  • Resource: file, operation: create
  • Options: uploadType: media, fileContent from formatting node

11. Create Summary

Aggregates the Drive folder ID, Doc ID, and Markdown file ID into a summary JSON object for notifications.

  • Type: code
  • Output: { summary: { sourceFile, docsFolder, googleDoc, markdownFile, timestamp } }

12. Send Notification Email

Sends an HTML email with a table of output links and metadata.

  • Type: emailSend
  • Credentials: SMTP
  • Features: Rich HTML table and bullet lists

13. Notify Slack

Posts a Slack message with interactive buttons to view the Google Doc and folder.

  • Type: slack
  • Attachments: Buttons View Google Doc, View Folder

This ready-to-adapt example demonstrates how to integrate DocuWriter.ai’s documentation and UML generation into Google Drive triggers. Simply adjust folder IDs, credential names, and formatting to match your workspace.