|
| 1 | +Contributing to docstrfmt |
| 2 | +========================= |
| 3 | + |
| 4 | +Thank you for your interest in contributing to docstrfmt! This document provides |
| 5 | +guidelines and instructions for contributing to the project. |
| 6 | + |
| 7 | +Getting Started |
| 8 | +--------------- |
| 9 | + |
| 10 | +Prerequisites |
| 11 | +~~~~~~~~~~~~~ |
| 12 | + |
| 13 | +- Python 3.10 or higher |
| 14 | +- `uv <https://docs.astral.sh/uv/>`_ (recommended) or pip |
| 15 | + |
| 16 | +Setting Up Your Development Environment |
| 17 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 18 | + |
| 19 | +1. Fork the repository on GitHub and clone your fork: |
| 20 | + |
| 21 | + .. code-block:: sh |
| 22 | +
|
| 23 | + git clone https://github.com/YOUR-USERNAME/docstrfmt.git |
| 24 | + cd docstrfmt |
| 25 | +
|
| 26 | +2. Install uv (if not already installed): |
| 27 | + |
| 28 | + .. code-block:: sh |
| 29 | +
|
| 30 | + # On macOS and Linux |
| 31 | + curl -LsSf https://astral.sh/uv/install.sh | sh |
| 32 | +
|
| 33 | + # On Windows |
| 34 | + powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" |
| 35 | +
|
| 36 | +3. Create a virtual environment and install dependencies: |
| 37 | + |
| 38 | + .. code-block:: sh |
| 39 | +
|
| 40 | + uv sync --group dev |
| 41 | +
|
| 42 | + .. note:: |
| 43 | + |
| 44 | + The ``dev`` dependency group includes all the dependencies needed for |
| 45 | + development: linting tools, testing tools, and coverage reporting. |
| 46 | + |
| 47 | +4. Install pre-commit hooks: |
| 48 | + |
| 49 | + .. code-block:: sh |
| 50 | +
|
| 51 | + uv run pre-commit install |
| 52 | +
|
| 53 | +Development Workflow |
| 54 | +-------------------- |
| 55 | + |
| 56 | +Running Tests |
| 57 | +~~~~~~~~~~~~~ |
| 58 | + |
| 59 | +Run the test suite using pytest: |
| 60 | + |
| 61 | +.. code-block:: sh |
| 62 | +
|
| 63 | + uv run pytest |
| 64 | +
|
| 65 | +Run tests with coverage: |
| 66 | + |
| 67 | +.. code-block:: sh |
| 68 | +
|
| 69 | + uv run coverage run --source docstrfmt --module pytest |
| 70 | + uv run coverage report -m |
| 71 | +
|
| 72 | +Run tests across all Python versions using tox: |
| 73 | + |
| 74 | +.. code-block:: sh |
| 75 | +
|
| 76 | + uv run tox |
| 77 | +
|
| 78 | +Run tests for a specific Python version: |
| 79 | + |
| 80 | +.. code-block:: sh |
| 81 | +
|
| 82 | + # For Python 3.10 |
| 83 | + uv run tox -e py310 |
| 84 | +
|
| 85 | +Running Linters |
| 86 | +~~~~~~~~~~~~~~~ |
| 87 | + |
| 88 | +The project uses pre-commit hooks to ensure code quality. Run all checks: |
| 89 | + |
| 90 | +.. code-block:: sh |
| 91 | +
|
| 92 | + uv run pre-commit run --all-files |
| 93 | +
|
| 94 | +You can also run pre-commit checks using tox: |
| 95 | + |
| 96 | +.. code-block:: sh |
| 97 | +
|
| 98 | + uv run tox -e pre-commit |
| 99 | +
|
| 100 | +Run style checks: |
| 101 | + |
| 102 | +.. code-block:: sh |
| 103 | +
|
| 104 | + uv run tox -e style |
| 105 | +
|
| 106 | +Run style checks and auto-fix issues: |
| 107 | + |
| 108 | +.. code-block:: sh |
| 109 | +
|
| 110 | + uv run tox -e style-fix |
| 111 | +
|
| 112 | +Format the docs with docstrfmt: |
| 113 | + |
| 114 | +.. code-block:: sh |
| 115 | +
|
| 116 | + uv run docstrfmt . |
| 117 | +
|
| 118 | +Running the Daemon |
| 119 | +~~~~~~~~~~~~~~~~~~ |
| 120 | + |
| 121 | +To test the daemon functionality, first install with the daemon extras: |
| 122 | + |
| 123 | +.. code-block:: sh |
| 124 | +
|
| 125 | + uv sync --group dev --extra d |
| 126 | +
|
| 127 | +Then start the daemon: |
| 128 | + |
| 129 | +.. code-block:: sh |
| 130 | +
|
| 131 | + uv run docstrfmtd |
| 132 | +
|
| 133 | +Code Style Guidelines |
| 134 | +--------------------- |
| 135 | + |
| 136 | +- Follow PEP 8 guidelines |
| 137 | +- Use type hints for function signatures |
| 138 | +- Write docstrings for all public modules, functions, classes, and methods |
| 139 | +- Keep line length to 88 characters (Black's default) |
| 140 | +- Use meaningful variable and function names |
| 141 | + |
| 142 | +Making Changes |
| 143 | +-------------- |
| 144 | + |
| 145 | +1. Create a new branch for your changes: |
| 146 | + |
| 147 | + .. code-block:: sh |
| 148 | +
|
| 149 | + git checkout -b feature/your-feature-name |
| 150 | +
|
| 151 | +2. Make your changes and ensure tests pass: |
| 152 | + |
| 153 | + .. code-block:: sh |
| 154 | +
|
| 155 | + uv run pytest |
| 156 | + uv run pre-commit run --all-files |
| 157 | +
|
| 158 | +3. Commit your changes with a descriptive commit message: |
| 159 | + |
| 160 | + .. code-block:: sh |
| 161 | +
|
| 162 | + git add . |
| 163 | + git commit -m "Add feature: description of your changes" |
| 164 | +
|
| 165 | +4. Push to your fork: |
| 166 | + |
| 167 | + .. code-block:: sh |
| 168 | +
|
| 169 | + git push origin feature/your-feature-name |
| 170 | +
|
| 171 | +5. Open a Pull Request on GitHub |
| 172 | + |
| 173 | +Pull Request Guidelines |
| 174 | +----------------------- |
| 175 | + |
| 176 | +- Provide a clear description of the changes |
| 177 | +- Reference any related issues |
| 178 | +- Ensure all tests pass and coverage remains at 100% |
| 179 | + |
| 180 | +Testing Guidelines |
| 181 | +------------------ |
| 182 | + |
| 183 | +- Write tests for all new features and bug fixes |
| 184 | +- Ensure all tests pass before submitting a PR |
| 185 | +- Maintain 100% test coverage |
| 186 | +- Use descriptive test names that explain what is being tested |
| 187 | + |
| 188 | +Adding New Features |
| 189 | +------------------- |
| 190 | + |
| 191 | +When adding new reStructuredText constructs or features: |
| 192 | + |
| 193 | +1. Add test files in ``tests/test_files/``. These files should contain examples of |
| 194 | + properly formatted constructs. |
| 195 | +2. Implement the feature in the appropriate module |
| 196 | +3. Add tests in ``tests/test_main.py`` |
| 197 | +4. Add an entry to CHANGES.rst |
0 commit comments