feat(widget): implement modular widget rendering and data processing for GitHub profiles

This commit is contained in:
shay
2026-02-18 12:28:51 -05:00
parent 1f427f10b7
commit 88d0003e72
18 changed files with 1203 additions and 0 deletions
+87
View File
@@ -0,0 +1,87 @@
# GitHub Profile Widget Generator
A modular system for generating polished SVG widgets from GitHub profile data.
## Project Structure
```
src/
├── models/ # Data classes and types
│ ├── __init__.py
│ └── types.py # Widget data models
│
├── themes/ # Color schemes and styling
│ ├── __init__.py
│ └── themes.py # Theme definitions
│
├── widgets/ # Widget rendering modules
│ ├── __init__.py
│ ├── grade.py # Developer grade widget
│ ├── impact.py # Impact timeline chart
│ ├── collaborators.py # Top collaborators
│ ├── focus.py # Focus areas bars
│ ├── languages.py # Languages donut chart
│ ├── achievements.py # Achievements list
│ └── composite.py # Full widget composer
│
├── data/ # Data fetching and processing
│ ├── __init__.py
│ ├── fetcher.py # GitHub API client
│ └── processor.py # Data transformation
│
├── utils/ # Helper functions
│ ├── __init__.py
│ └── svg_helpers.py # SVG utilities
│
└── generate.py # Main CLI entry point
```
## Usage
Run from the project root directory:
```bash
# Generate widgets for a user
python run.py <username> [theme]
# Or run as a module
python -m src.generate <username> [theme]
# With GitHub token for higher rate limits
GITHUB_TOKEN=your_token python run.py <username>
# Use light theme
python run.py <username> light
```
## PyCharm Setup
To fix import resolution in PyCharm:
1. Right-click on the `src` folder
2. Select **Mark Directory as** → **Sources Root**
3. PyCharm will now resolve all imports correctly
Alternatively, the project is set up with proper relative imports, so imports should work automatically once `src` is marked as a source root.
## Extending
### Adding a New Widget
1. Create a new file in `widgets/` (e.g., `widgets/my_widget.py`)
2. Implement `render_my_widget(data, theme_name="dark") -> str`
3. Add to `widgets/__init__.py` exports
4. Update `data/processor.py` to include it in `generate_widgets_from_github()`
### Adding a New Theme
1. Add theme definition to `themes/themes.py`
2. Use the theme name when calling `generate_full_widget(theme="my_theme")`
## Development
All widgets follow the same pattern:
- Accept data models from `models/`
- Use themes from `themes/`
- Return SVG strings
- Use `utils.card_wrapper()` for consistent styling