Skip to content

๐Ÿค Contributing Guide

Thank you for your interest in the EmailWidget project! We welcome all forms of contributions, whether code, documentation, testing, or feedback suggestions.

๐ŸŽฏ Ways to Contribute

๐Ÿ“ Code Contributions

  • ๐Ÿ› Bug Fixes - Help us fix known issues
  • โœจ New Features - Add new Widgets or functionality
  • โšก Performance Optimization - Improve code performance and efficiency
  • ๐Ÿ”ง Refactoring - Improve code structure and maintainability

๐Ÿ“š Documentation Contributions

  • ๐Ÿ“– Improve Documentation - Enhance existing documentation
  • ๐Ÿ’ก Add Examples - Provide more usage examples
  • ๐ŸŒ Translation - Help translate documentation to other languages
  • ๐Ÿ“น Tutorials - Create video or illustrated tutorials

๐Ÿงช Testing Contributions

  • ๐Ÿ” Write Tests - Add tests for existing functionality
  • ๐Ÿ› Report Bugs - Find and report issues
  • ๐Ÿ“Š Performance Testing - Test performance in different environments

๐Ÿš€ Quick Start

1. ๐Ÿด Fork the Project

Click the "Fork" button in the top right corner of the GitHub page to copy the project to your account.

2. ๐Ÿ“ฅ Clone the Code

Bash
git clone https://github.com/YOUR_USERNAME/SpiderDaily.git
cd SpiderDaily

3. ๐Ÿ”ง Setup Development Environment

Bash
# Create virtual environment
python -m venv venv
source venv/bin/activate  # Linux/macOS
# or venv\Scripts\activate  # Windows

# Install development dependencies
pip install -e ".[dev]"

4. ๐ŸŒฟ Create Branch

Bash
git checkout -b feature/your-feature-name
# or
git checkout -b bugfix/issue-number

5. ๐Ÿ’ป Start Development

Now you can start developing!

๐Ÿ“‹ Development Standards

๐Ÿ Code Style

We use the following tools to maintain code quality:

Bash
# Code formatting
black email_widget/
isort email_widget/

# Code linting
flake8 email_widget/
mypy email_widget/

๐Ÿ“ Commit Standards

We use Conventional Commits specification:

Bash
# Feature addition
git commit -m "feat: add new progress bar Widget"

# Bug fix
git commit -m "fix: fix encoding issue in table rendering"

# Documentation update
git commit -m "docs: update API documentation"

# Testing
git commit -m "test: add unit tests for TextWidget"

# Refactoring
git commit -m "refactor: optimize Email class rendering logic"

๐Ÿงช Testing Requirements

  • All new features should have corresponding tests
  • Bug fixes should include regression tests
  • Ensure test coverage doesn't decrease
Bash
# Run tests
pytest tests/ -v

# Check coverage
pytest tests/ --cov=email_widget --cov-report=html

๐ŸŽจ Creating New Widgets

If you want to add new components to EmailWidget, please follow these steps:

1. ๐Ÿ“ File Structure

Text Only
email_widget/ewidget/widgets/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ your_new_widget.py  # New Widget file
โ””โ”€โ”€ ...

2. ๐Ÿ“ Widget Base Template

Python
"""ไฝ ็š„ๆ–ฐWidgetๅฎž็Žฐ

่ฟ™ไธชๆจกๅ—ๆไพ›ไบ†XXXๅŠŸ่ƒฝ็š„Widgetใ€‚
"""
from typing import Optional
from email_widget.core.base import BaseWidget


class YourNewWidget(BaseWidget):
    """ไฝ ็š„ๆ–ฐWidget็ฑป๏ผŒ็”จไบŽXXXๅŠŸ่ƒฝใ€‚

    ่ฏฆ็ป†็š„็ฑป่ฏดๆ˜Ž...

    Attributes:
        _your_attr: ๅฑžๆ€ง่ฏดๆ˜Ž

    Examples:
        >>> widget = YourNewWidget()
        >>> widget.set_something("value")
        >>> html = widget.render_html()
    """

    def __init__(self, widget_id: Optional[str] = None):
        """ๅˆๅง‹ๅŒ–Widgetใ€‚

        Args:
            widget_id: ๅฏ้€‰็š„Widget ID
        """
        super().__init__(widget_id)
        # ๅˆๅง‹ๅŒ–ไฝ ็š„ๅฑžๆ€ง
        self._your_attr = "default_value"

    def set_something(self, value: str) -> 'YourNewWidget':
        """่ฎพ็ฝฎๆŸไธชๅฑžๆ€งใ€‚

        Args:
            value: ๅฑžๆ€งๅ€ผ

        Returns:
            ่ฟ”ๅ›žselfไปฅๆ”ฏๆŒ้“พๅผ่ฐƒ็”จ
        """
        self._your_attr = value
        return self

    def _get_template_name(self) -> str:
        """่Žทๅ–ๆจกๆฟๅ็งฐใ€‚

        Returns:
            ๆจกๆฟๆ–‡ไปถๅ
        """
        return "your_new_widget.html"

    def render_html(self) -> str:
        """ๆธฒๆŸ“ไธบHTMLๅญ—็ฌฆไธฒใ€‚

        Returns:
            ๆธฒๆŸ“ๅŽ็š„HTMLๅญ—็ฌฆไธฒ
        """
        # ๅฎž็Žฐไฝ ็š„ๆธฒๆŸ“้€ป่พ‘
        return f'<div>{self._your_attr}</div>'

3. ๐Ÿ“ Documentation Requirements

  • Use Google-style docstrings
  • Provide detailed class and method descriptions
  • Include usage examples
  • Describe parameters and return values

4. ๐Ÿงช Test Files

Create corresponding test file tests/test_your_new_widget.py:

Python
import pytest
from email_widget.widgets import YourNewWidget


class TestYourNewWidget:
    def test_init(self):
        """ๆต‹่ฏ•Widgetๅˆๅง‹ๅŒ–"""
        widget = YourNewWidget()
        assert widget._your_attr == "default_value"

    def test_set_something(self):
        """ๆต‹่ฏ•่ฎพ็ฝฎๅฑžๆ€ง"""
        widget = YourNewWidget()
        result = widget.set_something("test_value")

        assert widget._your_attr == "test_value"
        assert result is widget  # ๆต‹่ฏ•้“พๅผ่ฐƒ็”จ

    def test_render_html(self):
        """ๆต‹่ฏ•HTMLๆธฒๆŸ“"""
        widget = YourNewWidget()
        widget.set_something("test")

        html = widget.render_html()
        assert "test" in html

5. ๐Ÿ“ฆ Register Widget

Add import in email_widget/ewidget/widgets/__init__.py:

Python
from .your_new_widget import YourNewWidget

__all__ = [
    # ... ๅ…ถไป–Widget
    'YourNewWidget',
]

๐Ÿ“ค Submitting Pull Request

1. โœ… Pre-submission Checklist

Bash
# Run all tests
pytest tests/ -v

# Check code style
black --check email_widget/
isort --check-only email_widget/
flake8 email_widget/

# Type checking
mypy email_widget/

2. ๐Ÿ“ PR Description Template

Markdown
## ๐Ÿ“‹ Change Type
- [ ] ๐Ÿ› Bug fix
- [ ] โœจ New feature
- [ ] ๐Ÿ’ฅ Breaking change
- [ ] ๐Ÿ“š Documentation update
- [ ] ๐Ÿ”ง Code refactoring
- [ ] โšก Performance optimization
- [ ] ๐Ÿงช Test improvement

## ๐Ÿ“ Change Description
Brief description of your changes...

## ๐Ÿงช Testing Description
- [ ] Added unit tests
- [ ] Passed all existing tests
- [ ] Manually tested functionality

## ๐Ÿ“ธ Screenshots/Examples
If UI-related changes, please provide screenshots or example code

## ๐Ÿ”— Related Issues
Fixes #(issue number)

3. ๐Ÿ” Code Review

  • We carefully review every PR
  • May request some modifications
  • Please be patient for review and actively respond to feedback

๐Ÿ› Reporting Bugs

๐Ÿ“ Bug Report Template

When you find a bug, please create an Issue using the following template:

Markdown
## ๐Ÿ› Bug Description
Brief description of the problem encountered...

## ๐Ÿ”„ Steps to Reproduce
1. Execute '...'
2. Click '....'
3. Scroll to '....'
4. See error

## ๐ŸŽฏ Expected Behavior
Describe what you expected to happen...

## ๐Ÿ“ธ Screenshots
If applicable, add screenshots to help explain the problem

## ๐Ÿ–ฅ๏ธ Environment Information
- OS: [e.g. Windows 10, macOS 12.0, Ubuntu 20.04]
- Python version: [e.g. 3.10.0]
- EmailWidget version: [e.g. 0.1.0]

## ๐Ÿ“‹ Additional Information
Add any other information about the problem...

๐Ÿ’ก Feature Suggestions

We welcome suggestions for new features! When creating a Feature Request, please:

  1. ๐ŸŽฏ Clear Requirements - Describe the feature you want in detail
  2. ๐Ÿค” Explain Reasons - Why is this feature needed
  3. ๐Ÿ’ญ Provide Solutions - If you have ideas, provide implementation solutions
  4. ๐Ÿ“ Give Examples - Provide usage examples

๐ŸŒŸ Recognizing Contributors

We recognize contributors in the following places:

  • ๐Ÿ“œ CONTRIBUTORS.md file
  • ๐ŸŽ‰ Release notes acknowledgments
  • ๐Ÿ’ฌ Social media promotion
  • ๐Ÿ† Special badges (for major contributions)

๐Ÿ“ž Contact Us

If you have any questions or need help:


Thank you for your contribution!

Every contribution makes EmailWidget better. Regardless of the size of the contribution, we are very grateful! ๐Ÿ™