Proton is an opinionated, open-source documentation generator specifically designed for Go libraries. It automatically creates comprehensive 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
- π¨ 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
- β‘ Benchmark Documentation - Run benchmarks and generate performance documentation automatically
- π Smart Parsing - Parse Go AST to extract documentation, types, and examples
- β Configuration Validation - Validate your configuration before generation
- π§Ή Smart Preservation - Only regenerates API reference and examples, preserves all other documentation
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.yml# Run benchmarks for entire project
proton benchmark
# Run benchmarks for specific package
proton benchmark ./internal/cli
# Save benchmark results to file
proton benchmark --output benchmark_results.txtProton 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
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
benchmarks:
enabled: true
pattern: "./..."
skip_empty_packages: false
# Optional: load from file instead of running
# output_file: "benchmark_results.txt"See Configuration Schema for complete documentation of all available options.
Proton generates a well-organized documentation structure:
docs/
βββ getting-started/
β βββ quick-start.md
βββ core-concepts/
β βββ core-concepts.md
βββ advanced/
β βββ advanced.md
βββ api-reference/
β βββ [package-name].md
βββ examples/
β βββ [example-category]/
β βββ [example-name].md
βββ benchmarks/
β βββ [package-name].md
Proton comes with built-in templates that work great out of the box, but you can customize them:
api-reference.md- API reference documentationexamples.md- Examples documentationbenchmarks.md- Benchmark performance documentation
-
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 |
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 }} |
Proton can automatically run benchmarks and generate performance documentation for your packages.
Run benchmarks manually using the benchmark command:
# Run benchmarks for entire project
proton benchmark
# Run benchmarks for specific package
proton benchmark ./internal/cli
# Save results to file for later use
proton benchmark --output benchmark_results.txtEnable benchmark generation in your configuration:
discovery:
benchmarks:
enabled: true
pattern: "./..."
skip_empty_packages: false # Skip packages without benchmarks
# Optional: load from pre-generated file instead of running
# output_file: "benchmark_results.txt"When you run proton generate, it will:
- Execute
go test -bench=. -benchmemfor your packages (or load from file) - Parse benchmark results (ns/op, B/op, allocs/op)
- Generate
docs/benchmarks/{package-name}.mdfiles with performance metrics
Each benchmark file includes:
- Summary table of all benchmarks
- Detailed breakdown for each benchmark
- Instructions for adding benchmarks if none exist
- Links to related documentation
# .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
Made with β€οΈ by Kolosys