doc/commands: generate CmdEntityLink to JSON
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 1 May 2018 19:30:41 +0000 (15:30 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 2 May 2018 23:03:34 +0000 (19:03 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/doc/commands/commands_json.nit
src/doc/commands/tests/test_commands_json.nit
src/doc/commands/tests/test_commands_json.sav/test_cmd_link.res [new file with mode: 0644]

index a4457f1..bb04ad8 100644 (file)
@@ -73,6 +73,17 @@ redef class CmdComment
        end
 end
 
+redef class CmdEntityLink
+       redef fun to_json do
+               var obj = new JsonObject
+               var text = self.text
+               if text != null then obj["text"] = text
+               var title = self.title
+               if title != null then obj["title"] = title
+               return obj
+       end
+end
+
 redef class CmdEntityCode
        redef fun to_json do
                var obj = new JsonObject
index c7db27e..be2c235 100644 (file)
@@ -40,6 +40,12 @@ class TestCommandsJson
                print_json cmd.to_json
        end
 
+       fun test_cmd_link is test do
+               var cmd = new CmdEntityLink(test_view, mentity_name = "test_prog::Character")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
        # CmdInheritance
 
        fun test_cmd_parents is test do
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_link.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_link.res
new file mode 100644 (file)
index 0000000..c0dae8e
--- /dev/null
@@ -0,0 +1,4 @@
+{
+       "text": "Character",
+       "title": "Characters can be played by both the human or the machine."
+}