|
| 1 | +# Contributing to Django SEO Optimizer |
| 2 | + |
| 3 | +First off, thank you for considering contributing to Django SEO Optimizer! It's people like you that make Django SEO Optimizer such a great tool. |
| 4 | + |
| 5 | +## Code of Conduct |
| 6 | + |
| 7 | +This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code. |
| 8 | + |
| 9 | +## How Can I Contribute? |
| 10 | + |
| 11 | +### Reporting Bugs |
| 12 | + |
| 13 | +Before creating bug reports, please check the issue list as you might find out that you don't need to create one. When you are creating a bug report, please include as many details as possible: |
| 14 | + |
| 15 | +* Use a clear and descriptive title |
| 16 | +* Describe the exact steps which reproduce the problem |
| 17 | +* Provide specific examples to demonstrate the steps |
| 18 | +* Describe the behavior you observed after following the steps |
| 19 | +* Explain which behavior you expected to see instead and why |
| 20 | +* Include details about your configuration and environment |
| 21 | + |
| 22 | +### Suggesting Enhancements |
| 23 | + |
| 24 | +Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion, please include: |
| 25 | + |
| 26 | +* Use a clear and descriptive title |
| 27 | +* Provide a step-by-step description of the suggested enhancement |
| 28 | +* Provide specific examples to demonstrate the steps |
| 29 | +* Describe the current behavior and explain which behavior you expected to see instead |
| 30 | +* Explain why this enhancement would be useful |
| 31 | + |
| 32 | +### Pull Requests |
| 33 | + |
| 34 | +* Fill in the required template |
| 35 | +* Do not include issue numbers in the PR title |
| 36 | +* Follow the Python style guide |
| 37 | +* Include thoughtfully-worded, well-structured tests |
| 38 | +* Document new code |
| 39 | +* End all files with a newline |
| 40 | + |
| 41 | +## Development Process |
| 42 | + |
| 43 | +1. Fork the repo and create your branch from `develop` |
| 44 | +2. Install development dependencies: |
| 45 | + ```bash |
| 46 | + pip install -e ".[dev]" |
| 47 | + ``` |
| 48 | +3. Run tests to ensure everything is working: |
| 49 | + ```bash |
| 50 | + pytest |
| 51 | + ``` |
| 52 | +4. Make your changes and add tests |
| 53 | +5. Run the test suite again |
| 54 | +6. Push to your fork and submit a pull request |
| 55 | + |
| 56 | +## Testing |
| 57 | + |
| 58 | +We use pytest for our test suite. To run tests: |
| 59 | + |
| 60 | +```bash |
| 61 | +# Run all tests |
| 62 | +pytest |
| 63 | + |
| 64 | +# Run specific test file |
| 65 | +pytest tests/test_fields.py |
| 66 | + |
| 67 | +# Run with coverage report |
| 68 | +pytest --cov=seo_optimizer |
| 69 | +``` |
| 70 | + |
| 71 | +### Writing Tests |
| 72 | + |
| 73 | +* Write test docstrings |
| 74 | +* Each test should have a single assertion |
| 75 | +* Use descriptive test names |
| 76 | +* Follow the Arrange-Act-Assert pattern |
| 77 | + |
| 78 | +Example: |
| 79 | +```python |
| 80 | +def test_metadata_field_validates_max_length(): |
| 81 | + """Test that MetadataField correctly validates max_length.""" |
| 82 | + # Arrange |
| 83 | + field = MetadataField(max_length=10) |
| 84 | + |
| 85 | + # Act & Assert |
| 86 | + with pytest.raises(ValidationError): |
| 87 | + field.clean("This is too long") |
| 88 | +``` |
| 89 | + |
| 90 | +## Style Guide |
| 91 | + |
| 92 | +We follow PEP 8 with some modifications: |
| 93 | + |
| 94 | +* Line length limit is 100 characters |
| 95 | +* Use double quotes for strings |
| 96 | +* Use trailing commas in multi-line structures |
| 97 | +* Sort imports using isort |
| 98 | + |
| 99 | +Use black for code formatting: |
| 100 | +```bash |
| 101 | +black seo_optimizer |
| 102 | +``` |
| 103 | + |
| 104 | +## Documentation |
| 105 | + |
| 106 | +* Use Google-style docstrings |
| 107 | +* Update the README.md if needed |
| 108 | +* Add docstrings to all public methods |
| 109 | +* Include code examples in docstrings |
| 110 | +* Update type hints |
| 111 | + |
| 112 | +Example: |
| 113 | +```python |
| 114 | +def get_metadata( |
| 115 | + self, |
| 116 | + path: str, |
| 117 | + language: Optional[str] = None |
| 118 | +) -> Dict[str, Any]: |
| 119 | + """Get metadata for the given path and language. |
| 120 | + |
| 121 | + Args: |
| 122 | + path: The URL path to get metadata for |
| 123 | + language: Optional language code (e.g., 'en', 'es') |
| 124 | + |
| 125 | + Returns: |
| 126 | + Dictionary containing metadata fields |
| 127 | + |
| 128 | + Example: |
| 129 | + >>> meta = MetadataManager().get_metadata('/products/') |
| 130 | + >>> print(meta['title']) |
| 131 | + 'Our Products' |
| 132 | + """ |
| 133 | +``` |
| 134 | + |
| 135 | +## Commit Messages |
| 136 | + |
| 137 | +* Use the present tense ("Add feature" not "Added feature") |
| 138 | +* Use the imperative mood ("Move cursor to..." not "Moves cursor to...") |
| 139 | +* Limit the first line to 72 characters or less |
| 140 | +* Reference issues and pull requests liberally after the first line |
| 141 | + |
| 142 | +Example: |
| 143 | +``` |
| 144 | +Add async support for metadata retrieval |
| 145 | +
|
| 146 | +- Implement AsyncMetadataManager |
| 147 | +- Add async_get_metadata method |
| 148 | +- Update documentation with async examples |
| 149 | +
|
| 150 | +Fixes #123 |
| 151 | +``` |
| 152 | + |
| 153 | +## Release Process |
| 154 | + |
| 155 | +1. Update version in `seo_optimizer/version.py` |
| 156 | +2. Update CHANGELOG.md |
| 157 | +3. Create release notes |
| 158 | +4. Tag the release |
| 159 | +5. Push to PyPI |
| 160 | + |
| 161 | +## Questions? |
| 162 | + |
| 163 | +Feel free to contact the project maintainers if you have any questions or need help with the contribution process. |
| 164 | + |
| 165 | +## License |
| 166 | + |
| 167 | +By contributing, you agree that your contributions will be licensed under the MIT License. |
0 commit comments