Skip to content

Commit 135c9e2

Browse files
7708: Fixed many documentaion example issues.
1 parent 69a6e4c commit 135c9e2

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

crates/ide_assists/src/handlers/generate_default_from_new.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,27 @@ use test_utils::mark;
1010

1111
// Assist: generate_default_from_new
1212
//
13-
// Generates default implementation from new method
13+
// Generates default implementation from new method.
1414
//
1515
// ```
1616
// struct Example { _inner: () }
1717
//
1818
// impl Example {
19-
// pu|b fn new() -> Self {
19+
// pub fn n$0ew() -> Self {
2020
// Self { _inner: () }
2121
// }
2222
// }
2323
// ```
2424
// ->
2525
// ```
2626
// struct Example { _inner: () }
27-
27+
//
2828
// impl Example {
2929
// pub fn new() -> Self {
3030
// Self { _inner: () }
3131
// }
3232
// }
33-
33+
//
3434
// impl Default for Example {
3535
// fn default() -> Self {
3636
// Self::new()
@@ -62,7 +62,7 @@ pub(crate) fn generate_default_from_new(acc: &mut Assists, ctx: &AssistContext)
6262
"Generate a Default impl from a new fn",
6363
impl_obj.syntax().text_range(),
6464
move |builder| {
65-
// TODO: indentation logic can also go here.
65+
// FIXME: indentation logic can also go here.
6666
// let new_indent = IndentLevel::from_node(&insert_after);
6767
let insert_location = impl_obj.syntax().text_range().end();
6868
builder.insert(insert_location, default_fn_syntax);
@@ -75,7 +75,7 @@ fn scope_for_fn_insertion_node(node: &SyntaxNode) -> Option<SyntaxNode> {
7575
}
7676

7777
fn default_fn_node_for_new(struct_name: SyntaxText) -> String {
78-
// TODO: Update the implementation to consider the code indentation.
78+
// FIXME: Update the implementation to consider the code indentation.
7979
format!(
8080
r#"
8181

crates/ide_assists/src/tests/generated.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,37 @@ impl Default for Version {
439439
)
440440
}
441441

442+
#[test]
443+
fn doctest_generate_default_from_new() {
444+
check_doc_test(
445+
"generate_default_from_new",
446+
r#####"
447+
struct Example { _inner: () }
448+
449+
impl Example {
450+
pub fn n$0ew() -> Self {
451+
Self { _inner: () }
452+
}
453+
}
454+
"#####,
455+
r#####"
456+
struct Example { _inner: () }
457+
458+
impl Example {
459+
pub fn new() -> Self {
460+
Self { _inner: () }
461+
}
462+
}
463+
464+
impl Default for Example {
465+
fn default() -> Self {
466+
Self::new()
467+
}
468+
}
469+
"#####,
470+
)
471+
}
472+
442473
#[test]
443474
fn doctest_generate_derive() {
444475
check_doc_test(

0 commit comments

Comments
 (0)