|
1 | 1 | # Contributing to VueGen |
2 | 2 |
|
3 | 3 | [VueGen][vuegen-repo] is an open source project, and we welcome contributions of all |
4 | | -kinds via GitHub issues and pull requests: correct or improve our [documentation][vuegen-docs], report or fix bugs, propose changes, and implement new features. Please follow |
5 | | -these guidelines to make sure that your contribution is easily integrated into the project. |
| 4 | +kinds via **GitHub issues** and **pull requests**: correct or improve our |
| 5 | +[documentation][vuegen-docs], report or fix bugs, propose changes, and implement new |
| 6 | +features. Please follow these guidelines to make sure that your contribution is easily |
| 7 | +integrated into the project. |
6 | 8 |
|
7 | | -## 1. Contributor Agreement |
| 9 | +## Contributor Agreement |
8 | 10 |
|
9 | 11 | By contributing, you agree that we may redistribute your work under [our |
10 | | -license](LICENSE). In exchange, we will address your issues and/or assess |
| 12 | +license](LICENSE.md). In exchange, we will address your issues and/or assess |
11 | 13 | your change proposal as promptly as we can, and help you become a member of our |
12 | 14 | community. |
13 | 15 |
|
14 | | -## 2. What to Contribute |
| 16 | +## What to Contribute? |
15 | 17 |
|
16 | | -The easiest way to get started is by reporting an issue that needs to be fixed, |
17 | | -such as a bug in the code, unclear explanations, conceptual errors, or other details. |
18 | | -You can also contribute by proposing new features or modules, improving existing |
19 | | -functionality, or suggesting other ideas that might be useful. If youβre looking for |
20 | | -inspiration, please check the [list of open issues][issues] in this repository. |
| 18 | +The easiest way to get started is by **reporting an issue** that needs to be fixed, |
| 19 | +such as a bug in the code, unclear explanations, conceptual errors, or other details. |
| 20 | +If you are familiar with Python, Git,, and GitHub, you can **fix the bug** yourself |
| 21 | +and submit a **pull request (PR)** with your changes, as described below. |
| 22 | + |
| 23 | +You can also contribute by **fixing existing bugs** tagged with the `bug` and |
| 24 | +`help wanted` labels in the [list of open issues][issues] of the repository. There are |
| 25 | +**new features and imporvements** tagged with `enhancement` and `help wanted` as well, so |
| 26 | +feel free to start a discussion if you would like to work on one of those. If you come up with |
| 27 | +any **ideas for new features or improvements** that are not yet reported, we are also happy to hear about them. |
21 | 28 |
|
22 | 29 | Feedback from beginners is especially valuable, as experienced users may overlook how |
23 | 30 | challenging certain aspects of the software can be for newcomers. Therefore, we encourage |
24 | | -you to share any suggestions or observations you have about this project. |
| 31 | +you to share any suggestions or observations you have. |
25 | 32 |
|
26 | | -## 3. How to Contribute |
| 33 | +## How to Contribute? |
27 | 34 |
|
28 | 35 | Here are the ways you can submit your suggestions and contribute to the project: |
29 | 36 |
|
30 | 37 | ### 1. Reporting Issues or Suggesting Improvements |
31 | 38 |
|
32 | | -If you have a [GitHub][github] account (or are willing to [open one][github-join]) but are unfamiliar with Git, you can report bugs or suggest improvements by [creating an issue][new-issue]. This GitHub feature allows for discussion threads on reported issues and proposed enhancements. |
| 39 | +If you have a [GitHub][github] account (or are willing to [open one][github-join]) but are unfamiliar with |
| 40 | +Git, you can report bugs or suggest improvements by [creating an issue][new-issue]. This GitHub feature allows |
| 41 | +for discussion threads on reported issues and proposed enhancements. |
| 42 | + |
| 43 | +When reporting an issue, please provide as much relevant information as possible, including: |
| 44 | + |
| 45 | +* A clear and descriptive title |
| 46 | +* A detailed description of the problem or suggestion |
| 47 | +* Steps to reproduce the issue (if applicable) |
| 48 | +* Any relevant screenshots or error messages |
| 49 | +* Your operating system, software version, and additonal details about your local setup that might be helpful in troubleshooting |
| 50 | + |
| 51 | +> [!TIP] |
| 52 | +> This guide from the [GitHub Docs][github-docs] provides useful tips on [how to write an issue][issue-github-guide]. |
33 | 53 |
|
34 | 54 | ### 2. Submitting Changes via Pull Requests |
35 | 55 |
|
36 | | -If you are comfortable using Git and would like to add or modify a functionality, you can submit a **pull request (PR)**. Instructions on how to contribute this way are provided in the next section. |
| 56 | +If you are comfortable using Git/GitHub and would like to add or modify a functionality, you can submit a **PR**. |
| 57 | +You may want to look at [How to Contribute to an Open Source Project on GitHub][how-contribute]. |
| 58 | +In brief, we use [GitHub flow][github-flow] to manage changes: |
| 59 | + |
| 60 | +> [!TIP] |
| 61 | +> Consider using an IDE (e.g., [VSCode][vscode]) or a GUI client (e.g., [GitHub Desktop][github-desktop]) to help |
| 62 | +> you with some of the common steps described below. |
| 63 | +
|
| 64 | +1. Fork the [vuegen][vuegen-repo] repo on GitHub. |
| 65 | +2. Clone your fork locally. Replace `yourusername` with your GitHub username. |
| 66 | + |
| 67 | + ```bash |
| 68 | + git clone https://github.com/yourusername/vuegen.git |
| 69 | + ``` |
| 70 | + |
| 71 | +3. Install your local copy into a virtual environment. Assuming you have Python available |
| 72 | + on your system, this can be done using `venv`. Alternatives are `conda`, `uv`, or `poetry` |
| 73 | + to create and manage virtual environments. |
| 74 | + |
| 75 | + ```bash |
| 76 | + cd vuegen/ |
| 77 | + python -m venv .env |
| 78 | + source .env/bin/activate |
| 79 | + pip install -e .[dev] |
| 80 | + ``` |
| 81 | + |
| 82 | +4. Create a new branch in your desktop copy of this repository for each significant change. |
37 | 83 |
|
38 | | -### 3. Providing Feedback via Email |
| 84 | + ```bash |
| 85 | + git checkout -b name-of-your-new-branch |
| 86 | + ``` |
39 | 87 |
|
40 | | -If you donβt have a GitHub account and are unfamiliar with Git, you can send feedback via email to [asaru@dtu.dk][contact]. However, using GitHub is preferred, as it allows us to respond more quickly and track discussions openly. |
| 88 | +5. When you're done making changes, check that your changes are formatted and pass `black` and |
| 89 | + `ruff` checks (some changes ruff can automatically fix for you, if you pass the `--fix` flag). |
| 90 | + Also, run the `tests` to make sure everything is working as expected: |
41 | 91 |
|
42 | | -> [!NOTE] |
43 | | -> The documentation for [Git][git-docs] and [GitHub][github-docs] are easy to follow, and you can learn the basics using their official guides. |
| 92 | + ```bash |
| 93 | + black . |
| 94 | + ruff check src |
| 95 | + pytest . |
| 96 | + ``` |
44 | 97 |
|
45 | | -## 4. Creating a Pull Request |
| 98 | +6. Commit the changea in that branch. |
46 | 99 |
|
47 | | -If you choose to contribute via GitHub, you may want to look at [How to Contribute to an Open Source Project on GitHub][how-contribute]. In brief, we use [GitHub flow][github-flow] to manage changes: |
| 100 | + ```bash |
| 101 | + git add . |
| 102 | + git commit -m "Your detailed description of your changes." |
| 103 | + ``` |
48 | 104 |
|
49 | | -1. Create a new branch in your desktop copy of this repository for each significant change. |
50 | | -2. Commit the change in that branch. |
51 | | -3. Push that branch to your fork of this repository on GitHub. |
52 | | -4. Submit a pull request from that branch to the [upstream repository][vuegen-repo]. |
53 | | -5. If you receive feedback, make changes on your desktop and push to your branch on GitHub: the |
| 105 | +7. Push that branch to your fork of this repository on GitHub. |
| 106 | + |
| 107 | + ```bash |
| 108 | + git push origin name-of-your-new-branch |
| 109 | + ``` |
| 110 | + |
| 111 | +8. Submit a pull request from that branch to the [upstream repository][vuegen-repo] via GitHub. |
| 112 | + See the **PR General Guidelines** below for more details. |
| 113 | +9. If you receive feedback, make changes on your desktop and push to your branch on GitHub: the |
54 | 114 | pull request will update automatically. |
55 | 115 |
|
56 | | -## 5. Credits |
| 116 | +> [!TIP] |
| 117 | +> The documentation for [Git][git-docs] and [GitHub][github-docs] are easy to follow, and you can learn the |
| 118 | +> basics using their official guides. |
| 119 | +
|
| 120 | +#### PR General Guidelines |
| 121 | + |
| 122 | +We have a general [PR template][general-pr-template] that is loaded autmatically when you open |
| 123 | +a new PR. Before you submit a PR, check that it meets these guidelines: |
| 124 | + |
| 125 | +1. The pull request should include tests. |
| 126 | +2. If the pull request adds functionality, the docs should be updated. Put |
| 127 | + your new functionality into a function with a docstring. |
| 128 | +3. The pull request should pass the workflows on GitHub. |
| 129 | + |
| 130 | +## Code & Documentation Standards |
| 131 | + |
| 132 | +To maintain consistency across the codebase, please adhere to the following standards when contributing: |
| 133 | + |
| 134 | +* **Docstrings:** Follow the [NumPy docstring style][numpy-docstring-guide]. Include examples where relevant. |
| 135 | +* **Type Hints:** Use Python type hints for function signatures and variable annotations (**PEP 484**). |
| 136 | +* **Code Formatting:** Use `black` for code formatting and `ruff` for linting (as mentioned in the PR guidelines). |
| 137 | +* **Naming Conventions:** Follow **PEP8** for naming (e.g., snake_case for variables/functions, CamelCase for classes). |
| 138 | + |
| 139 | +Here is an example of a simple function with a proper docstring and type hints: |
| 140 | + |
| 141 | +```python |
| 142 | +def calculate_average(values: List[float]) -> float: |
| 143 | + """ |
| 144 | + Calculate the average of a list of numerical values. |
57 | 145 |
|
58 | | -This contribution guide was modified under the [Creative Commons Attribution 4.0 International License][ccby] from the [Software Carpentry guides][soft-cp-guides]. |
| 146 | + Parameters |
| 147 | + ---------- |
| 148 | + values : List[float] |
| 149 | + List of numerical values to average. |
| 150 | +
|
| 151 | + Returns |
| 152 | + ------- |
| 153 | + float |
| 154 | + The arithmetic mean of the input values. |
| 155 | +
|
| 156 | + Examples |
| 157 | + -------- |
| 158 | + >>> calculate_average([1.0, 2.0, 3.0, 4.0]) |
| 159 | + 2.5 |
| 160 | + """ |
| 161 | + return sum(values) / len(values) |
| 162 | +``` |
| 163 | + |
| 164 | +## Test Guidelines |
| 165 | + |
| 166 | +We encourage comprehensive testing to maintain code quality, so all contributions should include |
| 167 | +appropriate tests that verify functionality. We use `pytest` as our testing framework. Here are some considerations: |
| 168 | + |
| 169 | +* **Structure:** Place tests in the tests/ directory, mirroring the source structure. |
| 170 | +* **Coverage:** Aim for high test coverage, especially for new features or bug fixes. Try to cover typical use cases as well as edge cases. |
| 171 | +* **Naming:** Use descriptive test function names that indicate what is being tested. |
| 172 | +* **Docstrings:** Include docstrings in your test functions to explain their purpose, following the previous docstring guidelines. |
| 173 | +* **Isolation:** Each test should be independent and not rely on other tests. |
| 174 | +* **Local Execution:** Ensure that tests can be run locally using `pytest` before submitting a PR. |
| 175 | + |
| 176 | +Here is an example of a test script for the `calculate_average` function: |
| 177 | + |
| 178 | +```python |
| 179 | +import pytest |
| 180 | +from vuegen.utils import calculate_average |
| 181 | + |
| 182 | +def test_calculate_average_basic(): |
| 183 | + """Test basic average calculation with positive numbers.""" |
| 184 | + result = calculate_average([1.0, 2.0, 3.0, 4.0]) |
| 185 | + assert result == 2.5 |
| 186 | + |
| 187 | +def test_calculate_average_single_value(): |
| 188 | + """Test average calculation with a single value.""" |
| 189 | + result = calculate_average([5.0]) |
| 190 | + assert result == 5.0 |
| 191 | + |
| 192 | +def test_calculate_average_empty_list(): |
| 193 | + """Test average calculation with empty list raises appropriate error.""" |
| 194 | + with pytest.raises(ZeroDivisionError): |
| 195 | + calculate_average([]) |
| 196 | +``` |
| 197 | + |
| 198 | +Run the following command in the root directory to execute the tests locally: |
| 199 | + |
| 200 | +```bash |
| 201 | +pytest . |
| 202 | +``` |
| 203 | + |
| 204 | +It's possible to run specific test files or functions by providing their paths. |
| 205 | +See the [pytest documentation][pytest-docs] for more details. |
| 206 | + |
| 207 | +## Deployment |
| 208 | + |
| 209 | +We created a [CI/CD worflow][cicd-workflow] using **GitHub Actions** to automatically deploy the Python package to |
| 210 | +[PyP][vuegen-pypi] when a new release is created. To create a new release, make sure all changed are merged into the `main` branch, |
| 211 | +then go to the [Releases section][releases-vuegen] of the GitHub repository and click on **Draft a new release**. Fill in the |
| 212 | +release title and description, then click on **Publish release**. This will trigger the GitHub Actions workflow to build and deploy the package to PyPI. |
| 213 | + |
| 214 | +Also, we have a GitHub Action that automatically deploys the documentation to [Read the Docs][vuegen-docs] in |
| 215 | +every push to a branch or when a PR is merged into `main`. |
| 216 | + |
| 217 | +## Credits |
| 218 | + |
| 219 | +This contribution guide was modified under the [Creative Commons Attribution 4.0 International License][ccby] from the [Software Carpentry guides][soft-cp-guides], [vuecore][vuecore-repo], and |
| 220 | +[acore][acore-repo] projects. |
59 | 221 |
|
60 | 222 | [vuegen-repo]: https://github.com/Multiomics-Analytics-Group/vuegen |
61 | 223 | [vuegen-docs]: https://vuegen.readthedocs.io/ |
62 | 224 | [issues]: https://github.com/Multiomics-Analytics-Group/vuegen/issues |
63 | 225 | [new-issue]: https://github.com/Multiomics-Analytics-Group/vuegen/issues/new |
64 | 226 | [github]: https://github.com |
65 | 227 | [github-join]: https://github.com/join |
66 | | -[contact]: mailto:asaru@dtu.dk |
67 | 228 | [git-docs]: https://git-scm.com/doc |
68 | 229 | [github-docs]: https://guides.github.com/ |
| 230 | +[issue-github-guide]: https://docs.github.com/en/issues/tracking-your-work-with-issues/learning-about-issues/quickstart |
69 | 231 | [how-contribute]: https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github |
70 | 232 | [github-flow]: https://guides.github.com/introduction/flow/ |
| 233 | +[vscode]: https://code.visualstudio.com/ |
| 234 | +[github-desktop]: https://github.com/apps/desktop |
| 235 | +[general-pr-template]: https://github.com/Multiomics-Analytics-Group/vuegen/blob/main/.github/PULL_REQUEST_TEMPLATE.md |
| 236 | +[numpy-docstring-guide]: https://numpydoc.readthedocs.io/en/latest/format.html |
| 237 | +[pytest-docs]: https://docs.pytest.org/en/stable |
| 238 | +[cicd-workflow]: https://github.com/Multiomics-Analytics-Group/vuegen/blob/main/.github/workflows/cdci.yml |
| 239 | +[vuegen-pypi]: https://pypi.org/project/vuegen/ |
| 240 | +[releases-vuegen]: https://github.com/Multiomics-Analytics-Group/vuegen/releases |
71 | 241 | [soft-cp-guides]: https://software-carpentry.org/lessons/ |
72 | 242 | [ccby]: https://creativecommons.org/licenses/by/4.0/ |
| 243 | +[vuecore-repo]: https://github.com/Multiomics-Analytics-Group/vuecore |
| 244 | +[acore-repo]: https://github.com/Multiomics-Analytics-Group/acore |
| 245 | + |
0 commit comments