Proton is an opinionated, open-source documentation generator specifically designed for Go libraries. It automatically creates comprehensive, GitBook-compatible documentation from your Go source code, comments, and configurable templates.
- 📦 Multi-Package Support - Handle single and multi-package Go libraries effortlessly
- 🤖 Auto-Discovery - Automatically discover and document all packages in your project
- 📖 GitBook Integration - Generate GitBook-compatible documentation with
.gitbook.yml - 🎨 Customizable Templates - Use built-in templates or create your own
- ⚡ GitHub Actions - Automated documentation deployment with GitHub Actions
- 🔧 Configurable Output - Flexible output directory and structure configuration
- 📝 API Documentation - Generate detailed API reference from Go comments
- 💡 Examples & Guides - Auto-extract examples and generate comprehensive guides
- 🔍 Smart Parsing - Parse Go AST to extract documentation, types, and examples
- ✅ Configuration Validation - Validate your configuration before generation
- 🧹 Selective Cleaning - Preserve custom content while regenerating auto-generated docs
go install github.com/kolosys/proton/cmd/proton@latestAdd to your .github/workflows/docs.yml:
name: Generate Documentation
on:
push:
branches: [main]
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: kolosys/proton@v1
with:
deploy-to-pages: true# Initialize in current directory
proton init
# Initialize in specific project
proton init ./my-go-projectThis creates a .proton/config.yml file with sensible defaults.
# Validate current directory
proton validate
# Validate specific project
proton validate ./my-go-project
# Validate with custom config
proton validate --config custom-config.yml# Generate with default settings
proton generate
# Generate with custom output directory
proton generate --output my-docs
# Generate with custom configuration
proton generate --config custom-config.ymlProton uses a YAML configuration file (.proton/config.yml) to customize documentation generation:
repository:
name: my-library
owner: myuser
description: "A fantastic Go library"
import_path: github.com/myuser/my-library
output:
directory: docs
clean: true
gitbook_config: true
discovery:
packages:
auto_discover: true
exclude_patterns:
- "./vendor/..."
- "./test/..."
- "./.git/..."
- "**/*_test.go"
api_generation:
enabled: true
include_unexported: false
include_examples: true
examples:
enabled: true
auto_discover: true
guides:
enabled: true
include_contributing: true
include_faq: true
gitbook:
title: My Library Documentation
description: Complete documentation for My LibrarySee Configuration Schema for complete documentation of all available options.
Proton generates a well-organized documentation structure:
docs/
├── README.md # Main documentation index
├── .gitbook.yml # GitBook configuration
├── SUMMARY.md # GitBook navigation
├── getting-started/
│ ├── README.md # Getting started overview
│ └── [package-name].md # Package-specific getting started guides
├── api-reference/
│ ├── README.md # API reference index
│ └── [package-name].md # Package-specific API documentation
├── examples/
│ ├── README.md # Examples overview
│ └── [example-category]/ # Example categories
│ ├── README.md # Category overview
│ └── [example-name].md # Individual examples
└── guides/
├── README.md # Guides overview
├── contributing.md # Contributing guidelines
├── faq.md # Frequently asked questions
└── [package-name]/ # Package-specific guides
└── best-practices.md # Package best practices
Proton comes with built-in templates that work great out of the box, but you can customize them:
index.md- Main documentation pagepackages-index.md- Package overviewpackage.md- Individual package documentationapi-reference.md- API reference documentationexamples-index.md- Examples overviewguides-index.md- Guides overviewcontributing.md- Contributing guidelinesfaq.md- FAQ pagegitbook-config.yml- GitBook configuration
-
Create a custom templates directory inside
.proton:.proton/ ├── config.yml └── templates/ ├── custom-index.md └── custom-api.md -
Configure in your
.proton/config.yml:templates: directory: ./.proton/templates custom_templates: - name: index file: ./.proton/templates/custom-index.md
- name: Generate Documentation
uses: kolosys/proton@v1- name: Generate Documentation
uses: kolosys/proton@v1
with:
config-file: ".proton/config.yml"
output-directory: "documentation"
clean-output: "false"
deploy-to-pages: true
deploy-to-branch: "gh-pages"
auto-commit: true
commit-message: "📚 Update documentation"
go-version: "1.24"
proton-version: "latest"| Input | Description | Default |
|---|---|---|
config-file |
Path to configuration file | .proton/config.yml |
output-directory |
Output directory | docs |
clean-output |
Clean output directory | true |
deploy-to-pages |
Deploy to GitHub Pages | false |
deploy-to-branch |
Deploy to specific branch | `` |
auto-commit |
Auto-commit changes | false |
commit-message |
Commit message | 📚 Update documentation (auto-generated) |
go-version |
Go version to use | 1.24 |
proton-version |
Proton version to install | latest |
token |
GitHub token for auth | ${{ github.token }} |
When clean-output is set to false, Proton preserves custom content in guides and other directories while only regenerating auto-generated content (api-reference, examples, packages, README.md, SUMMARY.md).
# .proton/config.yml
repository:
name: my-package
import_path: github.com/user/my-package
discovery:
packages:
auto_discover: true
include_patterns: ["."]# .proton/config.yml
discovery:
packages:
auto_discover: true
include_patterns: ["./..."]
exclude_patterns:
- "./internal/..."
- "./test/..."
- "./vendor/..."# .proton/config.yml
discovery:
packages:
manual_packages:
- name: core
path: ./pkg/core
description: Core functionality
- name: utils
path: ./pkg/utils
description: Utility functions- Go 1.21 or later
- Git
git clone https://github.com/kolosys/proton.git
cd proton
go build -o proton ./cmd/protongo test ./...We welcome contributions! Please see our Contributing Guide for details.
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by the need for better Go library documentation
- Built with love for the Go community
- Thanks to all contributors and users
- 📄 Documentation
- 🐛 Issue Tracker
- 💬 Discussions
- 📧 Contact
Made with ❤️ by Kolosys