|
1 | | -## Contributing to Rustlings |
| 1 | +# Contributing to Rustlings |
2 | 2 |
|
3 | | -First off, thanks for taking the time to contribute!! ❤️ |
| 3 | +First off, thanks for taking the time to contribute! ❤️ |
4 | 4 |
|
5 | | -### Quick Reference |
| 5 | +## Quick Reference |
6 | 6 |
|
7 | | -I want to... |
| 7 | +I want to … |
8 | 8 |
|
9 | | -_add an exercise! ➡️ [read this](#addex) and then [open a Pull Request](#prs)_ |
| 9 | +- _report a bug!_ ➡️ [open an issue](#issues) |
| 10 | +- _fix a bug!_ ➡️ [open a pull request](#pull-requests) |
| 11 | +- _implement a new feature!_ ➡️ [open an issue to discuss it first, then a pull request](#issues) |
| 12 | +- _add an exercise!_ ➡️ [read this](#adding-an-exercise) |
| 13 | +- _update an outdated exercise!_ ➡️ [open a pull request](#pull-requests) |
10 | 14 |
|
11 | | -_update an outdated exercise! ➡️ [open a Pull Request](#prs)_ |
12 | | - |
13 | | -_report a bug! ➡️ [open an Issue](#issues)_ |
14 | | - |
15 | | -_fix a bug! ➡️ [open a Pull Request](#prs)_ |
16 | | - |
17 | | -_implement a new feature! ➡️ [open an Issue to discuss it first, then a Pull Request](#issues)_ |
18 | | - |
19 | | -<a name="#src"></a> |
20 | | -### Working on the source code |
21 | | - |
22 | | -`rustlings` is basically a glorified `rustc` wrapper. Therefore the source code |
23 | | -isn't really that complicated since the bulk of the work is done by `rustc`. |
24 | | - |
25 | | -<a name="addex"></a> |
26 | | -### Adding an exercise |
27 | | - |
28 | | -The first step is to add the exercise! Name the file `exercises/yourTopic/yourTopicN.rs`, make sure to |
29 | | -put in some helpful links, and link to sections of the book in `exercises/yourTopic/README.md`. |
30 | | - |
31 | | -Next make sure it runs with `rustlings`. The exercise metadata is stored in `info.toml`, under the `exercises` array. The order of the `exercises` array determines the order the exercises are run by `rustlings verify` and `rustlings watch`. |
32 | | - |
33 | | -Add the metadata for your exercise in the correct order in the `exercises` array. If you are unsure of the correct ordering, add it at the bottom and ask in your pull request. The exercise metadata should contain the following: |
34 | | -```diff |
35 | | - ... |
36 | | -+ [[exercises]] |
37 | | -+ name = "yourTopicN" |
38 | | -+ path = "exercises/yourTopic/yourTopicN.rs" |
39 | | -+ mode = "compile" |
40 | | -+ hint = """ |
41 | | -+ Some kind of useful hint for your exercise.""" |
42 | | - ... |
43 | | -``` |
44 | | - |
45 | | -The `mode` attribute decides whether Rustlings will only compile your exercise, or compile and test it. If you have tests to verify in your exercise, choose `test`, otherwise `compile`. If you're working on a Clippy exercise, use `mode = "clippy"`. |
46 | | - |
47 | | -That's all! Feel free to put up a pull request. |
48 | | - |
49 | | -<a name="issues"></a> |
50 | | -### Issues |
| 15 | +## Issues |
51 | 16 |
|
52 | 17 | You can open an issue [here](https://github.com/rust-lang/rustlings/issues/new). |
53 | 18 | If you're reporting a bug, please include the output of the following commands: |
54 | 19 |
|
55 | | -- `rustc --version` |
| 20 | +- `cargo --version` |
56 | 21 | - `rustlings --version` |
57 | 22 | - `ls -la` |
58 | 23 | - Your OS name and version |
59 | 24 |
|
60 | | -<a name="prs"></a> |
61 | | -### Pull Requests |
62 | | - |
63 | | -Opening a pull request is as easy as forking the repository and committing your |
64 | | -changes. There's a couple of things to watch out for: |
65 | | - |
66 | | -#### Write correct commit messages |
67 | | - |
68 | | -We follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) |
69 | | -specification. |
70 | | -This means that you have to format your commit messages in a specific way. Say |
71 | | -you're working on adding a new exercise called `foobar1.rs`. You could write |
72 | | -the following commit message: |
73 | | - |
74 | | -``` |
75 | | -feat: add foobar1.rs exercise |
76 | | -``` |
| 25 | +## Pull Requests |
77 | 26 |
|
78 | | -If you're just fixing a bug, please use the `fix` type: |
| 27 | +You are welcome to open a pull request, but unless it is small and trivial, **please open an issue to discuss your idea first** 🙏🏼 |
79 | 28 |
|
80 | | -``` |
81 | | -fix(verify): make sure verify doesn't self-destruct |
82 | | -``` |
| 29 | +Opening a pull request is as easy as forking the repository and committing your changes. |
| 30 | +If you need any help with it or face any Git related problems, don't hesitate to ask for help 🤗 |
83 | 31 |
|
84 | | -The scope within the brackets is optional, but should be any of these: |
| 32 | +It may take time to review your pull request. |
| 33 | +Please be patient 😇 |
85 | 34 |
|
86 | | -- `installation` (for the installation script) |
87 | | -- `cli` (for general CLI changes) |
88 | | -- `verify` (for the verification source file) |
89 | | -- `watch` (for the watch functionality source) |
90 | | -- `run` (for the run functionality source) |
91 | | -- `EXERCISENAME` (if you're changing a specific exercise, or set of exercises, |
92 | | - substitute them here) |
| 35 | +When updating an exercise, check if its solution needs to be updated. |
93 | 36 |
|
94 | | -When the commit also happens to close an existing issue, link it in the message |
95 | | -body: |
| 37 | +## Adding An Exercise |
96 | 38 |
|
97 | | -``` |
98 | | -fix: update foobar |
| 39 | +- Name the file `exercises/yourTopic/yourTopicN.rs`. |
| 40 | +- Make sure to put in some helpful links, and link to sections of The Book in `exercises/yourTopic/README.md`. |
| 41 | +- In the exercise, add a `// TODO: …` comment where user changes are required. |
| 42 | +- Add a solution at `solutions/yourTopic/yourTopicN.rs` with comments explaining it. |
| 43 | +- Add the [metadata for your exercise](#exercise-metadata) in the `rustlings-macros/info.toml` file. |
| 44 | +- Make sure your exercise runs with `rustlings run yourTopicN`. |
| 45 | +- [Open a pull request](#pull-requests). |
99 | 46 |
|
100 | | -closes #101029908 |
101 | | -``` |
| 47 | +### Exercise Metadata |
102 | 48 |
|
103 | | -If you're doing simple changes, like updating a book link, use `chore`: |
| 49 | +The exercise metadata should contain the following: |
104 | 50 |
|
| 51 | +```toml |
| 52 | +[[exercises]] |
| 53 | +name = "yourTopicN" |
| 54 | +dir = "yourTopic" |
| 55 | +hint = """ |
| 56 | +A useful (multi-line) hint for your exercise. |
| 57 | +Include links to a section in The Book or a documentation page.""" |
105 | 58 | ``` |
106 | | -chore: update exercise1.rs book link |
107 | | -``` |
108 | | - |
109 | | -If you're updating documentation, use `docs`: |
110 | | - |
111 | | -``` |
112 | | -docs: add more information to Readme |
113 | | -``` |
114 | | - |
115 | | -If, and only if, you're absolutely sure you want to make a breaking change |
116 | | -(please discuss this beforehand!), add an exclamation mark to the type and |
117 | | -explain the breaking change in the message body: |
118 | | - |
119 | | -``` |
120 | | -fix!: completely change verification |
121 | | -
|
122 | | -BREAKING CHANGE: This has to be done because lorem ipsum dolor |
123 | | -``` |
124 | | - |
125 | | -#### Pull Request Workflow |
126 | 59 |
|
127 | | -Once you open a Pull Request, it may be reviewed or labeled (or both) until |
128 | | -the maintainers accept your change. Please be patient, it may take some time |
129 | | -for this to happen! |
| 60 | +If your exercise doesn't contain any test, add `test = false` to the exercise metadata. |
| 61 | +But adding tests is recommended. |
0 commit comments