codetodocx

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2025 License: MIT Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

codetodocx

A smart Go package that exports your code to Microsoft Word documents. codetodocx automatically detects if you're in a git repository and exports only changed files, or exports the entire project if it's not a git repository.

Features

  • 🚀 Smart Detection: First-time export includes all tracked files, incremental exports only changed files
  • 📝 Word Document Export: Creates professional Word documents with your code
  • 🔢 Line Numbers: Automatically adds line numbers to all code
  • 🎯 Git Integration: Exports files with git status M (modified), A (added), or U (untracked)
  • 📁 File Filtering: Automatically skips binary files and detects text files
  • 💪 Improved Formatting: Bold headings with full file paths, horizontal separators between files
  • ⚙️ Flexible Options: Command-line flags for full or changed-only exports

Installation

go get github.com/Karthikeya-Akhandam/codetodocx

Usage

Basic Usage
package main

import (
    "fmt"
    "github.com/Karthikeya-Akhandam/codetodocx"
)

func main() {
    // One function call - automatically does the smart thing!
    err := codetodocx.ExportProject("./myproject", "mycode.docx")
    if err != nil {
        fmt.Println("Error:", err)
    }
}
How It Works

The ExportProject() function is intelligent and automatically:

  1. First-Time Git Export: Exports ALL git-tracked files
  2. Incremental Git Export: Exports only changed files (M/A/U status)
  3. Regular Folder: Exports entire project
  4. Document Creation: Always creates a fresh Word document (overwrites if exists)
Example Output

For Git Repositories (First Time):

  • Document Title: "Code Export from [project] (All Tracked Files - First Export)"

For Git Repositories (Incremental):

  • Document Title: "Code Export from [project] (Changed Files Only - Incremental)"

For Regular Folders:

  • Document Title: "Code Export from [project] (Full Export)"

Git Integration

codetodocx automatically detects git repositories and exports files with the following status:

  • M - Modified files
  • A - Added files
  • U - Untracked files

If you're not in a git repository, it exports all text files in the project.

File Filtering

The package automatically:

  • ✅ Includes text files (source code, config files, etc.)
  • ❌ Skips binary files (.exe, .dll, .so, .dylib, .bin)
  • ❌ Skips directories
  • ❌ Skips files with null bytes (binary detection)

CLI Usage

Build and use as a command-line tool:

# Build the CLI
go build -o codetodocx ./cmd

# First-time export (exports all tracked files in git repo)
./codetodocx -project ./myproject -output mycode.docx

# Incremental export (exports only changed files)
./codetodocx -project ./myproject -output mycode.docx

# Force full export (export all files even on subsequent runs)
./codetodocx -project ./myproject -output mycode.docx -full

# Force changed-only export (export only changed files even on first run)
./codetodocx -project ./myproject -output mycode.docx -changed-only

# Show help
./codetodocx -help

Requirements

  • Go 1.24.4 or later
  • Git (optional, for git integration)
  • Microsoft Word or compatible software to view the output

Dependencies

  • github.com/fumiama/go-docx - Open-source library for Word document generation (AGPL-3.0)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

Created by Karthikeya Akhandam


codetodocx - Smart code export to Word documents! 📄✨

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportProject

func ExportProject(projectFolder, outputDocx string) error

ExportProject exports the project to a Word document Automatically detects if it's a git repo and exports appropriately First-time export: exports all git-tracked files Incremental export: exports only changed files Usage: codetodocx.ExportProject("path/to/project", "output.docx")

func ExportProjectWithOptions added in v1.1.0

func ExportProjectWithOptions(projectFolder, outputDocx string, forceFullExport, forceChangedOnly bool) error

ExportProjectWithOptions exports the project with custom options forceFullExport: if true, export all files even on incremental update forceChangedOnly: if true, export only changed files even on first run

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址