aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_assists/src/assists/change_visibility.rs2
-rw-r--r--crates/ra_assists/src/doc_tests/generated.rs2
-rw-r--r--docs/user/assists.md29
-rw-r--r--xtask/src/codegen/gen_assists_docs.rs8
4 files changed, 24 insertions, 17 deletions
diff --git a/crates/ra_assists/src/assists/change_visibility.rs b/crates/ra_assists/src/assists/change_visibility.rs
index 88118cdf7..bed343677 100644
--- a/crates/ra_assists/src/assists/change_visibility.rs
+++ b/crates/ra_assists/src/assists/change_visibility.rs
@@ -16,7 +16,7 @@ use crate::{Assist, AssistCtx, AssistId};
16// Adds or changes existing visibility specifier. 16// Adds or changes existing visibility specifier.
17// 17//
18// ``` 18// ```
19// fn<|> frobnicate() {} 19// <|>fn frobnicate() {}
20// ``` 20// ```
21// -> 21// ->
22// ``` 22// ```
diff --git a/crates/ra_assists/src/doc_tests/generated.rs b/crates/ra_assists/src/doc_tests/generated.rs
index 493bd94d0..b96d5772e 100644
--- a/crates/ra_assists/src/doc_tests/generated.rs
+++ b/crates/ra_assists/src/doc_tests/generated.rs
@@ -146,7 +146,7 @@ fn doctest_change_visibility() {
146 check( 146 check(
147 "change_visibility", 147 "change_visibility",
148 r#####" 148 r#####"
149fn<|> frobnicate() {} 149<|>fn frobnicate() {}
150"#####, 150"#####,
151 r#####" 151 r#####"
152pub(crate) fn frobnicate() {} 152pub(crate) fn frobnicate() {}
diff --git a/docs/user/assists.md b/docs/user/assists.md
index 182f07e98..ee1cfa142 100644
--- a/docs/user/assists.md
+++ b/docs/user/assists.md
@@ -1,5 +1,8 @@
1# Assists 1# Assists
2 2
3Cursor position or selection is signified by `┃` character.
4
5
3## `add_derive` 6## `add_derive`
4 7
5Adds a new `#[derive()]` clause to a struct or enum. 8Adds a new `#[derive()]` clause to a struct or enum.
@@ -8,7 +11,7 @@ Adds a new `#[derive()]` clause to a struct or enum.
8// BEFORE 11// BEFORE
9struct Point { 12struct Point {
10 x: u32, 13 x: u32,
11 y: u32,<|> 14 y: u32,
12} 15}
13 16
14// AFTER 17// AFTER
@@ -26,7 +29,7 @@ Specify type for a let binding.
26```rust 29```rust
27// BEFORE 30// BEFORE
28fn main() { 31fn main() {
29 let x<|> = 92; 32 let x = 92;
30} 33}
31 34
32// AFTER 35// AFTER
@@ -42,7 +45,7 @@ Adds a new inherent impl for a type.
42```rust 45```rust
43// BEFORE 46// BEFORE
44struct Ctx<T: Clone> { 47struct Ctx<T: Clone> {
45 data: T,<|> 48 data: T,
46} 49}
47 50
48// AFTER 51// AFTER
@@ -69,7 +72,7 @@ trait T {
69 72
70impl T for () { 73impl T for () {
71 Type X = (); 74 Type X = ();
72 fn foo(&self) {}<|> 75 fn foo(&self) {}
73 76
74} 77}
75 78
@@ -100,7 +103,7 @@ trait T {
100 fn bar(&self) {} 103 fn bar(&self) {}
101} 104}
102 105
103impl T for () {<|> 106impl T for () {
104 107
105} 108}
106 109
@@ -128,7 +131,7 @@ This means something of the form `!x` or `x != y`.
128```rust 131```rust
129// BEFORE 132// BEFORE
130fn main() { 133fn main() {
131 if x != 4 ||<|> !y {} 134 if x != 4 || !y {}
132} 135}
133 136
134// AFTER 137// AFTER
@@ -143,7 +146,7 @@ Adds or changes existing visibility specifier.
143 146
144```rust 147```rust
145// BEFORE 148// BEFORE
146fn<|> frobnicate() {} 149fn frobnicate() {}
147 150
148// AFTER 151// AFTER
149pub(crate) fn frobnicate() {} 152pub(crate) fn frobnicate() {}
@@ -156,7 +159,7 @@ Replace a large conditional with a guarded return.
156```rust 159```rust
157// BEFORE 160// BEFORE
158fn main() { 161fn main() {
159 <|>if cond { 162 if cond {
160 foo(); 163 foo();
161 bar(); 164 bar();
162 } 165 }
@@ -182,7 +185,7 @@ enum Action { Move { distance: u32 }, Stop }
182 185
183fn handle(action: Action) { 186fn handle(action: Action) {
184 match action { 187 match action {
185 <|> 188
186 } 189 }
187} 190}
188 191
@@ -204,7 +207,7 @@ Flips operands of a binary expression.
204```rust 207```rust
205// BEFORE 208// BEFORE
206fn main() { 209fn main() {
207 let _ = 90 +<|> 2; 210 let _ = 90 + 2;
208} 211}
209 212
210// AFTER 213// AFTER
@@ -220,7 +223,7 @@ Flips two comma-separated items.
220```rust 223```rust
221// BEFORE 224// BEFORE
222fn main() { 225fn main() {
223 ((1, 2),<|> (3, 4)); 226 ((1, 2), (3, 4));
224} 227}
225 228
226// AFTER 229// AFTER
@@ -236,7 +239,7 @@ Inlines local variable.
236```rust 239```rust
237// BEFORE 240// BEFORE
238fn main() { 241fn main() {
239 let x<|> = 1 + 2; 242 let x = 1 + 2;
240 x * 4; 243 x * 4;
241} 244}
242 245
@@ -253,7 +256,7 @@ Extracts subexpression into a variable.
253```rust 256```rust
254// BEFORE 257// BEFORE
255fn main() { 258fn main() {
256 <|>(1 + 2)<|> * 4; 259 (1 + 2) * 4;
257} 260}
258 261
259// AFTER 262// AFTER
diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs
index 8dca2ed06..0c4cf2152 100644
--- a/xtask/src/codegen/gen_assists_docs.rs
+++ b/xtask/src/codegen/gen_assists_docs.rs
@@ -107,9 +107,13 @@ r#####"
107} 107}
108 108
109fn generate_docs(assists: &[Assist], mode: Mode) -> Result<()> { 109fn generate_docs(assists: &[Assist], mode: Mode) -> Result<()> {
110 let mut buf = String::from("# Assists\n"); 110 let mut buf = String::from(
111 "# Assists\n\nCursor position or selection is signified by `┃` character.\n\n",
112 );
111 113
112 for assist in assists { 114 for assist in assists {
115 let before = assist.before.replace("<|>", "┃"); // Unicode pseudo-graphics bar
116 let after = assist.after.replace("<|>", "┃");
113 let docs = format!( 117 let docs = format!(
114 " 118 "
115## `{}` 119## `{}`
@@ -124,7 +128,7 @@ fn generate_docs(assists: &[Assist], mode: Mode) -> Result<()> {
124{} 128{}
125``` 129```
126", 130",
127 assist.id, assist.doc, assist.before, assist.after 131 assist.id, assist.doc, before, after
128 ); 132 );
129 buf.push_str(&docs); 133 buf.push_str(&docs);
130 } 134 }