]> git.lizzy.rs Git - rust.git/commitdiff
fix: format assist doc for sourcegen_assists_docs
authorCôme ALLART <come.allart@etu.emse.fr>
Mon, 6 Dec 2021 18:04:44 +0000 (19:04 +0100)
committerCôme ALLART <come.allart@etu.emse.fr>
Mon, 6 Dec 2021 18:04:44 +0000 (19:04 +0100)
crates/ide_assists/src/handlers/generate_documentation_template.rs
crates/ide_assists/src/tests/generated.rs

index 3abdddbb8cb5573a65e0fcd511fd0847f998bb19..8500a4d254ca0691e5728f59af984ed2e318e248 100644 (file)
@@ -7,35 +7,34 @@
 
 use crate::assist_context::{AssistContext, Assists};
 
-/// Assist: generate_documentation_template
-///
-/// Adds a documentation template above a function definition / declaration
-///
-/// ```
-/// fn my_func(a: i32, b: i32) -> Result<(), std::io::Error> {
-///     unimplemented!()
-/// }
-/// ```
-/// ->
-/// ```
-/// /// .
-/// ///
-/// /// # Examples
-/// ///
-/// /// ```rust
-/// /// use my_crate::my_func;
-/// ///
-/// /// let result = my_func(a, b);
-/// /// assert_eq!(result, );
-/// /// ```
-/// ///
-/// /// # Errors
-/// ///
-/// /// This function will return an error if .
-/// fn my_func(a: i32, b: i32) -> Result<(), std::io::Error> {
-///     unimplemented!()
-/// }
-/// ```
+// Assist: generate_documentation_template
+//
+// Adds a documentation template above a function definition / declaration.
+//
+// ```
+// fn my_$0func(a: i32, b: i32) -> Result<(), std::io::Error> {
+//     unimplemented!()
+// }
+// ```
+// ->
+// ```
+// /// .
+// ///
+// /// # Examples
+// ///
+// /// ```
+// /// use test::my_func;
+// ///
+// /// assert_eq!(my_func(a, b), );
+// /// ```
+// ///
+// /// # Errors
+// ///
+// /// This function will return an error if .
+// fn my_func(a: i32, b: i32) -> Result<(), std::io::Error> {
+//     unimplemented!()
+// }
+// ```
 pub(crate) fn generate_documentation_template(
     acc: &mut Assists,
     ctx: &AssistContext,
index e30f98bcd1369b9f890a00fe04fa58936d1e4657..653e51c837257247b39899a8a382645c4812a2d6 100644 (file)
@@ -839,6 +839,36 @@ struct Point {
     )
 }
 
+#[test]
+fn doctest_generate_documentation_template() {
+    check_doc_test(
+        "generate_documentation_template",
+        r#####"
+fn my_$0func(a: i32, b: i32) -> Result<(), std::io::Error> {
+    unimplemented!()
+}
+"#####,
+        r#####"
+/// .
+///
+/// # Examples
+///
+/// ```
+/// use test::my_func;
+///
+/// assert_eq!(my_func(a, b), );
+/// ```
+///
+/// # Errors
+///
+/// This function will return an error if .
+fn my_func(a: i32, b: i32) -> Result<(), std::io::Error> {
+    unimplemented!()
+}
+"#####,
+    )
+}
+
 #[test]
 fn doctest_generate_enum_as_method() {
     check_doc_test(