From 1848c59e1460d6eff2fc129fbc376b75bd98ec0a Mon Sep 17 00:00:00 2001 From: i582 <51853996+i582@users.noreply.github.com> Date: Fri, 18 Oct 2024 02:07:35 +0400 Subject: [PATCH] add tests for markdown markup in comments --- .../ide/docs/MoveDocumentationProviderTest.kt | 59 +++++++++++++++++-- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/src/test/kotlin/org/move/ide/docs/MoveDocumentationProviderTest.kt b/src/test/kotlin/org/move/ide/docs/MoveDocumentationProviderTest.kt index e7b625c79..f0549c892 100644 --- a/src/test/kotlin/org/move/ide/docs/MoveDocumentationProviderTest.kt +++ b/src/test/kotlin/org/move/ide/docs/MoveDocumentationProviderTest.kt @@ -14,8 +14,8 @@ class MvDocumentationProviderTest : MvDocumentationProviderTestCase() { """, expected = """
0x0::builtins
         native fun move_from<T: key>(addr: address): T
-

Removes `T` from address and returns it.

-

Aborts if address does not hold a `T`.

+

Removes T from address and returns it. + Aborts if address does not hold a T.

""") fun `test show doc comment for module`() = doTest(""" @@ -52,8 +52,7 @@ class MvDocumentationProviderTest : MvDocumentationProviderTestCase() { """, expected = """
0x1::M
         fun add(a: u8, b: u8): u8
-

Adds two numbers.

-

Returns their sum.

+

Adds two numbers.

Returns their sum.

""") fun `test show signature for function parameter`() = doTest(""" @@ -164,6 +163,58 @@ module 0x1::m { value parameter result: &mut T """) + fun `test markdown text styles`() = doTest(""" +/// This string contains some *bold* and **italic** words. +module 0x1::M {} + //^ + """, """ +
module 0x1::M
+

This string contains some bold and italic words.

+ """) + + fun `test markdown inline code`() = doTest(""" +/// Maybe some `inline` keyword +module 0x1::M {} + //^ + """, """ +
module 0x1::M
+

Maybe some inline keyword

+ """) + + fun `test markdown multiline code`() = doTest(""" +/// Move code: +/// ``` +/// module 0x1::M {} +/// ``` +module 0x1::M {} + //^ + """, """ +
module 0x1::M
+

Move code:

module 0x1::M {}
+
+
+ """) + + fun `test markdown list`() = doTest(""" +/// - The number of "items" in global storage. +/// - The number of bytes in global storage. +module 0x1::M {} + //^ + """, """ +
module 0x1::M
+
+ """) + + fun `test markdown numbered list`() = doTest(""" +/// 1. The number of "items" in global storage. +/// 2. The number of bytes in global storage. +module 0x1::M {} + //^ + """, """ +
module 0x1::M
+
  1. The number of "items" in global storage.
  2. The number of bytes in global storage.
+ """) + private fun doTest(@Language("Move") code: String, @Language("Html") expected: String?) = doTest(code, expected, block = MvDocumentationProvider::generateDoc) }