-
Notifications
You must be signed in to change notification settings - Fork 4
Contributing
Chris W edited this page Dec 9, 2024
·
2 revisions
Thank you for your interest in contributing to Goshot! This guide will help you get started with contributing to the project.
By participating in this project, you are expected to uphold our Code of Conduct:
- Be respectful and inclusive
- Exercise consideration and empathy
- Focus on what is best for the community
- Use welcoming and inclusive language
- Be collaborative
- Gracefully accept constructive criticism
.
βββ cmd/
β βββ goshot/ # CLI implementation
β βββ examples/ # Example code and demos
βββ pkg/
β βββ background/ # Background processing
β β βββ background.go # Main background interface
β β βββ color.go # Solid color backgrounds
β β βββ gradient.go # Gradient backgrounds
β β βββ image.go # Image backgrounds
β β βββ shadow.go # Shadow effects
β βββ chrome/ # Window styling and rendering
β β βββ chrome.go # Window chrome interface
β β βββ mac.go # macOS window chrome
β β βββ windows.go # Windows window chrome
β β βββ gnome.go # GNOME window chrome
β β βββ utils.go # Utility functions
β βββ content/ # Content rendering
β β βββ content.go # Content interface
β β βββ code/ # Code rendering
β β β βββ code.go # Code renderer
β β β βββ formatter.go # Code formatting
β β β βββ redactor.go # Code redaction
β β β βββ themes/ # Syntax themes
β β βββ term/ # Terminal rendering
β β βββ term.go # Terminal renderer
β β βββ themes/ # Terminal themes
β βββ fonts/ # Font loading and management
β β βββ fonts.go # Core font functionality
β β βββ embedded/ # Embedded fonts
β β βββ utils.go # Font utilities
β βββ render/ # Final image composition
β β βββ canvas.go # Main rendering canvas
β β βββ export.go # Export functionality
β βββ utils/ # Shared utilities
β βββ version/ # Version information
βββ go.mod
βββ go.sum
βββ README.md
-
Fork the Repository
- Visit Goshot on GitHub
- Click the "Fork" button in the top-right corner
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/goshot.git cd goshot
-
Set Up Development Environment
- Install Go (1.21 or later)
- Install required dependencies:
go mod download
-
Create a Branch
- Create a branch for your work:
git checkout -b feature/your-feature-name # or git checkout -b fix/your-bug-fix
- Create a branch for your work:
-
Make Your Changes
- Write clear, concise commit messages
- Follow the existing code style
- Add tests for new functionality
- Update documentation as needed
-
Test Your Changes
# Run tests go test ./... # Run linter go vet ./...
-
Submit a Pull Request
- Push your changes to your fork
- Create a Pull Request from your branch
- Fill out the PR template with all relevant information
- Link any related issues
-
Code Style
- Follow standard Go code formatting (
go fmt
) - Use meaningful variable and function names
- Add comments for complex logic
- Keep functions focused and concise
- Follow standard Go code formatting (
-
Error Handling
- Return errors instead of panicking
- Use descriptive error messages
- Wrap errors with context when appropriate
if err != nil { return fmt.Errorf("failed to render code: %w", err) }
-
Interface Design
- Keep interfaces small and focused
- Use the
With*
pattern for option methods - Provide sensible defaults
type Renderer interface { Render() (image.Image, error) } func (r *MyRenderer) WithOption(opt string) *MyRenderer { r.option = opt return r }
-
Unit Tests
- Write tests for new functionality
- Follow table-driven test patterns
- Use meaningful test names
func TestRenderer_WithOption(t *testing.T) { tests := []struct { name string option string expected string }{ { name: "valid option", option: "test", expected: "test", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { r := NewRenderer() r.WithOption(tt.option) if r.option != tt.expected { t.Errorf("got %v, want %v", r.option, tt.expected) } }) } }
-
Visual Testing
- Add example images for visual changes
- Test with different themes and configurations
- Consider accessibility in visual designs
-
Code Documentation
- Document all exported types and functions
- Include examples for complex functionality
- Keep comments up to date with code changes
-
Wiki Documentation
- Update relevant wiki pages
- Include code examples
- Add visual examples where appropriate
- Keep the sidebar up to date
-
Examples
- Add examples for new features
- Update existing examples
- Include comments explaining the code
-
Performance
- Profile code for performance bottlenecks
- Optimize image operations
- Reuse objects when possible
- Close resources properly
-
Memory Management
- Be mindful of large image allocations
- Clean up resources in defer statements
- Use appropriate buffer sizes
-
Compatibility
- Test on different platforms
- Consider font availability
- Handle different color spaces
- Support various image formats
This project is licensed under the MIT License - see the LICENSE file for details.
-
π€ Contributing
- Code of Conduct
- Development Workflow
- Project Structure
- Guidelines
- Testing
- Documentation