Skip to content

Contributing

Chris Watson edited this page Nov 20, 2024 · 1 revision

Contributing to Goshot

Thank you for your interest in contributing to Goshot! This guide will help you get started with contributing to the project.

Code of Conduct

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

πŸ“ Project Structure

.
β”œβ”€β”€ cmd/
β”‚   β”œβ”€β”€ goshot/          # CLI implementation
β”‚   └── examples/        # Example code
β”œβ”€β”€ pkg/
β”‚   β”œβ”€β”€ background/      # Background processing
β”‚   β”‚   β”œβ”€β”€ background.go # Main background interface
β”‚   β”‚   β”œβ”€β”€ color.go     # Solid color backgrounds
β”‚   β”‚   β”œβ”€β”€ gradient.go  # Gradient backgrounds
β”‚   β”‚   └── image.go     # Image backgrounds
β”‚   β”œβ”€β”€ chrome/          # Window styling and rendering
β”‚   β”‚   β”œβ”€β”€ chrome.go    # Window chrome rendering
β”‚   β”‚   └── macos.go     # macOS-specific window chrome
β”‚   β”‚   └── windows11.go # Windows 11-specific window chrome
β”‚   β”‚   └── utils.go     # Utility functions
β”‚   β”œβ”€β”€ fonts/           # Font loading and management
β”‚   β”‚   β”œβ”€β”€ fonts.go     # Core font functionality
β”‚   β”‚   β”œβ”€β”€ fonts_bundled.go   # Bundled font support
β”‚   β”‚   └── fonts_nobundled.go # Fallback for bundled fonts
β”‚   β”‚   └── bundled/     # Bundled font files
β”‚   β”œβ”€β”€ render/          # Final image composition
β”‚   β”‚   β”œβ”€β”€ canvas.go    # Main rendering canvas
β”‚   β”‚   └── export.go    # Export functionality
β”‚   └── syntax/          # Syntax highlighting
β”‚       β”œβ”€β”€ syntax.go    # Main syntax interface
β”‚       └── render.go    # Syntax rendering
β”œβ”€β”€ go.mod
β”œβ”€β”€ go.sum
└── README.md

Getting Started

  1. 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
  2. Set Up Development Environment

    • Install Go (1.20 or later)
    • Install required dependencies:
      go mod download
  3. Create a Branch

    • Create a branch for your work:
      git checkout -b feature/your-feature-name
      # or
      git checkout -b fix/your-bug-fix

Development Workflow

  1. Make Your Changes

    • Write clear, concise commit messages
    • Follow the existing code style
    • Add tests for new functionality
    • Update documentation as needed
  2. Test Your Changes

    # Run tests
    go test ./...
    
    # Run linter
    go vet ./...
  3. 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

Pull Request Guidelines

PR Title Format

Use one of these prefixes:

  • feat: for new features
  • fix: for bug fixes
  • docs: for documentation changes
  • test: for test changes
  • refactor: for code refactoring
  • chore: for routine tasks and maintenance

Example: feat: add gradient background support

PR Description

Include:

  • What changes you've made
  • Why you've made these changes
  • How to test the changes
  • Any breaking changes
  • Screenshots (if relevant)

Code Style Guidelines

Go Code Style

  • Follow the Go Code Review Comments
  • Use gofmt to format your code
  • Follow these naming conventions:
    // Package names should be short and clear
    package background
    
    // Interface names should usually end in -er
    type Renderer interface {
        Render() error
    }
    
    // Getter methods should not include Get
    func (c *Canvas) Size() (width, height int)
    
    // Acronyms should be all caps
    var HTTPClient *http.Client

Documentation Style

  • Write clear, concise documentation
  • Include examples where appropriate
  • Use proper markdown formatting
  • Keep line length under 100 characters
  • Use code blocks with language specifiers

Commit Messages

Follow these guidelines:

<type>(<scope>): <subject>

<body>

<footer>

Example:

feat(background): add gradient background support

Implement linear and radial gradient backgrounds with customizable
colors and stops. Include tests and documentation.

Closes #123

Testing Guidelines

  1. Unit Tests

    • Write tests for new functionality
    • Follow table-driven test patterns
    • Use meaningful test names
    func TestGradientBackground_Render(t *testing.T) {
        tests := []struct {
            name     string
            gradient *GradientBackground
            want     image.Image
            wantErr  bool
        }{
            // test cases...
        }
        // ...
    }
  2. Integration Tests

    • Test interactions between components
    • Use realistic test data
    • Clean up test resources

Documentation Guidelines

  1. Code Documentation

    • Document all exported types and functions
    • Include examples in documentation
    • Use complete sentences
    // GradientBackground represents a gradient background configuration.
    // It supports both linear and radial gradients with multiple color stops.
    type GradientBackground struct {
        // Type defines whether this is a linear or radial gradient.
        Type GradientType
        
        // Stops contains the color stops for this gradient.
        Stops []GradientStop
    }
  2. Wiki Documentation

    • Keep documentation up-to-date
    • Include code examples
    • Use proper formatting
    • Add screenshots where helpful

Issue Guidelines

When creating an issue:

  1. Bug Reports

    • Describe the bug clearly
    • Include steps to reproduce
    • Provide system information
    • Include error messages
    • Add screenshots if relevant
  2. Feature Requests

    • Describe the feature
    • Explain why it's needed
    • Provide example use cases
    • Consider implementation details

Getting Help

If you need help:

  1. Check the documentation
  2. Search existing issues
  3. Ask in the discussions

License

By contributing to Goshot, you agree that your contributions will be licensed under the project's MIT License.