Thank you for your interest in contributing to CodeSnippetBank! This guide will help you get started with contributing to the project.
By participating in this project, you agree to abide by our Code of Conduct:
- Be respectful and inclusive
- Welcome newcomers and help them get started
- Focus on constructive criticism
- Respect differing viewpoints and experiences
-
Fork the repository
# Click the 'Fork' button on GitHub -
Clone your fork
git clone https://github.com/yourusername/CodeSnippetBank.git cd CodeSnippetBank -
Set up development environment
# Create virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install development dependencies pip install -r requirements-dev.txt # Install in editable mode pip install -e .
-
Create a feature branch
git checkout -b feature/your-feature-name
Follow these guidelines:
- Write clean, readable code
- Follow PEP 8 style guidelines
- Add type hints where appropriate
- Include docstrings for all public functions/classes
- Keep commits focused and atomic
All new features should include tests:
# tests/test_your_feature.py
import pytest
from CodeSnippetBank.your_module import your_function
def test_your_function():
result = your_function(input_data)
assert result == expected_output
def test_edge_case():
with pytest.raises(ValueError):
your_function(invalid_input)Run tests:
# Run all tests
pytest
# Run specific test file
pytest tests/test_your_feature.py
# Run with coverage
pytest --cov=CodeSnippetBank- Update relevant documentation in
docs/ - Add docstrings to your code
- Update README.md if needed
- Add examples if introducing new features
Before submitting:
# Format code with black
black CodeSnippetBank/
# Check style with flake8
flake8 CodeSnippetBank/
# Type checking with mypy
mypy CodeSnippetBank/
# Run all checks
make lint # If Makefile is available-
Push your changes:
git push origin feature/your-feature-name
-
Create a Pull Request on GitHub
-
Fill out the PR template:
- Describe what changes you made
- Link any related issues
- Include screenshots if relevant
- List any breaking changes
CodeSnippetBank/
├── core/ # Core functionality
│ ├── models.py # Data models
│ ├── storage.py # Storage system
│ └── validator.py # Validation logic
├── converters/ # Conversion modules
│ ├── text2snippet/ # Text to snippet conversion
│ └── code2snippet/ # Code to snippet conversion
├── tests/ # Test suite
│ ├── test_core/ # Core module tests
│ └── test_converters/ # Converter tests
├── docs/ # Documentation
└── examples/ # Example usage
Create an issue with:
- Clear description of the bug
- Steps to reproduce
- Expected vs actual behavior
- System information (OS, Python version)
- Minimal code example
Create an issue with:
- Clear description of the feature
- Use cases and benefits
- Potential implementation approach
- Any mockups or examples
Help improve docs by:
- Fixing typos and grammar
- Adding examples
- Clarifying confusing sections
- Translating documentation
Areas where we need help:
- Parsers: Add support for new documentation formats
- Analyzers: Improve code analysis capabilities
- Validators: Add new validation rules
- Categories: Expand snippet categories
- Tests: Increase test coverage
- Performance: Optimize search and storage
# Good: Clear, documented function
def extract_code_blocks(text: str, language: str = "python") -> List[Dict[str, Any]]:
"""
Extract code blocks from text.
Args:
text: The input text to parse
language: Programming language to filter by
Returns:
List of dictionaries containing code blocks and metadata
"""
blocks = []
# Implementation...
return blocks
# Bad: Unclear, undocumented
def get_blocks(t, l="python"):
b = []
# ...
return bFollow conventional commits:
feat: add RST parser for documentation
fix: handle empty code blocks in markdown parser
docs: update installation guide
test: add tests for snippet validation
refactor: simplify storage indexing logic
Use descriptive branch names:
feature/add-html-parserfix/validation-error-handlingdocs/improve-api-referencerefactor/storage-optimization
class TestSnippetValidator:
"""Test suite for SnippetValidator."""
def setup_method(self):
"""Set up test fixtures."""
self.validator = SnippetValidator()
self.valid_snippet = create_test_snippet()
def test_valid_snippet_passes(self):
"""Test that valid snippets pass validation."""
is_valid, errors = self.validator.validate(self.valid_snippet)
assert is_valid
assert len(errors) == 0
def test_missing_title_fails(self):
"""Test that snippets without title fail validation."""
snippet = create_test_snippet(title="")
is_valid, errors = self.validator.validate(snippet)
assert not is_valid
assert any(e.field == "metadata.title" for e in errors)Aim for:
- Minimum 80% code coverage
- 100% coverage for critical paths
- Edge cases and error conditions
- Integration tests for converters
If you need to add a new dependency:
- Ensure it's necessary and well-maintained
- Add to
requirements.txtorrequirements-dev.txt - Document why it's needed in the PR
- Consider optional dependencies for heavy packages
Maintainers handle releases:
- Update version in
__version__.py - Update CHANGELOG.md
- Create release PR
- Tag release after merge
- Deploy to PyPI
- Start with "good first issue" labeled issues
- Read existing code to understand patterns
- Ask questions in issues or discussions
- Don't be afraid to submit small PRs
- Profile code for performance bottlenecks
- Use generators for large datasets
- Cache expensive computations
- Consider async operations where beneficial
- Never commit secrets or API keys
- Validate all user inputs
- Use safe parsing methods
- Report security issues privately
Contributors are recognized in:
- AUTHORS.md file
- Release notes
- Project documentation
- GitHub contributors page
- 💬 GitHub Discussions
- 🐛 Issue Tracker
- 📧 Email: codesnippetbank@example.com
Thank you for contributing to CodeSnippetBank! Together we're building something amazing 🚀