From d68f03712cf90242073655bf6656dc16b98555ca Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Tue, 1 May 2018 15:30:41 -0400 Subject: [PATCH] doc/commands: generate CmdEntityLink to JSON Signed-off-by: Alexandre Terrasa --- src/doc/commands/commands_json.nit | 11 +++++++++++ src/doc/commands/tests/test_commands_json.nit | 6 ++++++ .../tests/test_commands_json.sav/test_cmd_link.res | 4 ++++ 3 files changed, 21 insertions(+) create mode 100644 src/doc/commands/tests/test_commands_json.sav/test_cmd_link.res diff --git a/src/doc/commands/commands_json.nit b/src/doc/commands/commands_json.nit index a4457f1..bb04ad8 100644 --- a/src/doc/commands/commands_json.nit +++ b/src/doc/commands/commands_json.nit @@ -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 diff --git a/src/doc/commands/tests/test_commands_json.nit b/src/doc/commands/tests/test_commands_json.nit index c7db27e..be2c235 100644 --- a/src/doc/commands/tests/test_commands_json.nit +++ b/src/doc/commands/tests/test_commands_json.nit @@ -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 index 0000000..c0dae8e --- /dev/null +++ b/src/doc/commands/tests/test_commands_json.sav/test_cmd_link.res @@ -0,0 +1,4 @@ +{ + "text": "Character", + "title": "Characters can be played by both the human or the machine." +} -- 1.7.9.5