Skip to content

Commit 6d4a9ad

Browse files
BD103rparrettNthTensoralice-i-cecile
authored
Make some changes to the migration guide recommendations (#18794)
# Objective - I've worked on the migration guide in the past, so I've written down some of the conventions and styles I've used. ## Solution Please read through the descriptions of each commit, which justify the change! In summary: - Remove headings from migration guide template by moving style guide to `migration_guides.md` - Use parentheses to signal method and function names (`my_func()` instead of `my_func`) - Change the guidelines on using bullet points so they're not used for every single migration guide. - Remove suggestion to use diff blocks, as they don't syntax-highlight Rust code. --------- Co-authored-by: Rob Parrett <[email protected]> Co-authored-by: Miles Silberling-Cook <[email protected]> Co-authored-by: Alice Cecile <[email protected]>
1 parent 25a8b9f commit 6d4a9ad

File tree

2 files changed

+47
-39
lines changed

2 files changed

+47
-39
lines changed

release-content/migration_guides.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,48 @@ However, it's not always possible to use this attribute, and Bevy does not consi
5555
#[deprecated(since = "0.17.0", note = "This message will appear in the deprecation warning.")]
5656
struct MyStruct;
5757
```
58+
59+
## Style Guide
60+
61+
Keep it short and sweet:
62+
63+
- What, then why, then how to migrate.
64+
- Some helpful standardized phrases:
65+
- `OldType` is now `NewType`. Replace all references and imports.
66+
- The `Struct::method` method now requires an additional `magnitude: f32` argument.
67+
- `Enum` has a new variant, `Enum::NewVariant`, which must be handled during `match` statements.
68+
- The `Type::method` method has been removed. Use `Type::other_method` instead.
69+
- The `crate::old_module` module is now `crate::new_module`. Update your imports.
70+
- `function` now returns `Option<String>` instead of `String`.
71+
- Make sure it's searchable by directly naming the types and methods involved.
72+
- Use backticks for types, methods, and modules (e.g. `Vec<T>` or `core::mem::swap`).
73+
- Use bullet points when listing affected types / functions of a breaking change, or when the listing several complex steps for migrating. Avoid bullets for simple migrations, however.
74+
- Avoid headings. If you must, use only level-two (`##`) headings.
75+
- It's often useful to give a code example explaining what a migration may look like.
76+
77+
```rust
78+
// 0.15
79+
fn my_system(world: &mut World) {
80+
world.old_method();
81+
}
82+
83+
// 0.16
84+
fn my_system(world: &mut World) {
85+
// Use `new_method()` instead.
86+
world.new_method();
87+
}
88+
```
89+
90+
Often you will want to give two examples of the same piece of code, one for the old version and one for the new. You can designate which is which using comments, such as `// 0.15` and `// 0.16`. Avoid code diffs if possible, as they do not syntax highlight Rust code.
91+
92+
- Make sure to reference the currently published version of a crate when writing a migration guide.
93+
See [docs.rs](https://docs.rs/) for a quick reference to the existing public API.
94+
- When moving items to a new module or crate, consider a simple table listing
95+
the moved items and the before and after paths.
96+
For example, "`Foo` has been moved from `bar::foo` to `baz`" could be written:
97+
98+
**Relocations**
99+
100+
|Item|0.15 Path|0.16 Path|
101+
|-|-|-|
102+
|`Foo`|`bar::foo`|`baz`|

release-content/migration_guides_template.md

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,10 @@ pull_requests: [14791, 15458, 15269]
55

66
Copy the contents of this file into a new file in `./migration-guides`, update the metadata, and add migration guide content here.
77

8-
## Goals
9-
10-
Aim to communicate:
8+
Remember, your aim is to communicate:
119

1210
- What has changed since the last release?
1311
- Why did we make this breaking change?
1412
- How can users migrate their existing code?
1513

16-
## Style Guide
17-
18-
Keep it short and sweet:
19-
20-
- What, then why, then how to migrate.
21-
- Some helpful standardized phrases:
22-
- `OldType` is now `NewType`. Replace all references and imports.
23-
- The `Struct::method()` method now requires an additional `magnitude: f32` argument.
24-
- `Enum` has a new variant, `Enum::NewVariant`, which must be handled during `match` statements.
25-
- The `Type::method` method has been removed. Use `Type::other_method` instead.
26-
- The `crate::old_module` module is now `crate::new_module`. Update your imports.
27-
- `function` now returns `Option<String>`, instead of `String`.
28-
- Make sure it's searchable by directly naming the types and methods involved.
29-
- Use backticks for types, methods and modules (e.g. `Vec<T>` or `core::mem::swap`).
30-
- Use bullet points to explain complex changes.
31-
- Avoid headings. If you must, use only level-two headings.
32-
- Diff codeblocks can be useful for succinctly communicating changes.
33-
34-
```diff
35-
fn my_system(world: &mut World) {
36-
+ world.new_method();
37-
- world.old_method();
38-
}
39-
```
40-
41-
- Make sure to reference the currently published version of a crate when writing a migration guide.
42-
See [docs.rs](https://docs.rs/) for a quick reference to the existing public API.
43-
- When moving items to a new module or crate, consider a simple table listing
44-
the moved items and the before and after paths.
45-
For example, _`Foo` has been moved from `bar::foo` to `baz`_ could be written:
46-
47-
**Relocations**
48-
49-
| Item | Old Path | New Path |
50-
| ---------------------------- | ------------------------------ | ------------------------------ |
51-
| `Foo` | `bar::foo` | `baz` |
14+
For more specifics about style and content, see the [instructions](./migration_guides.md).

0 commit comments

Comments
 (0)