doc/commands: introduce commands results to json translation
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 24 Oct 2017 20:16:56 +0000 (16:16 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Thu, 23 Nov 2017 16:08:41 +0000 (11:08 -0500)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

16 files changed:
src/doc/commands/commands_json.nit [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.nit [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_ancestors.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_call.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_children.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_comment.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_descendants.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_entity.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_features.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_lin.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_mentities.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_new.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_param.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_parents.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_return.res [new file with mode: 0644]
src/doc/commands/tests/test_commands_json.sav/test_cmd_search.res [new file with mode: 0644]

diff --git a/src/doc/commands/commands_json.nit b/src/doc/commands/commands_json.nit
new file mode 100644 (file)
index 0000000..05fcf95
--- /dev/null
@@ -0,0 +1,153 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Translate command results to json
+module commands_json
+
+import commands::commands_model
+import commands::commands_graph
+import commands::commands_usage
+import commands::commands_catalog
+
+import model::model_json
+import catalog::catalog_json
+import doc::doc_down
+
+redef class DocCommand
+       # Return a JSON Serializable representation of `self` results
+       fun to_json: nullable Serializable is abstract
+end
+
+# Message handling
+
+redef class CmdMessage
+       # Return a JSON Serializable representation of `self`
+       fun to_json: nullable Serializable do
+               var obj = new JsonObject
+               obj["status"] = class_name
+               obj["message"] = to_s
+               return obj
+       end
+end
+
+redef class CmdEntity
+       redef fun to_json do return mentity
+end
+
+redef class CmdList
+       redef fun to_json do
+               var obj = new JsonObject
+               obj["results"] = results
+               obj["page"] = page
+               obj["count"] = count
+               obj["limit"] = limit
+               obj["max"] = max
+               return obj
+       end
+end
+
+redef class CmdEntityList
+       redef fun to_json do return super
+end
+
+# Model commands
+
+redef class CmdComment
+       redef fun to_json do
+               var obj = new JsonObject
+               var render = self.render
+               if render != null then
+                       obj["documentation"] = render.write_to_string
+               end
+               return obj
+       end
+end
+
+redef class CmdCode
+       redef fun to_json do
+               var obj = new JsonObject
+               var node = self.node
+               if node != null then
+                       obj["location"] = node.location
+               end
+               var output = render
+               if output != null then
+                       obj["code"] = output.write_to_string
+               end
+               return obj
+       end
+end
+
+redef class CmdGraph
+       redef fun to_json do
+               var obj = new JsonObject
+               var output = render
+               if output != null then
+                       obj["graph"] = output.write_to_string
+               end
+               return obj
+       end
+end
+
+redef class CmdMetadata
+       redef fun to_json do return metadata
+end
+
+# CmdCatalog
+
+redef class CmdCatalogStats
+       redef fun to_json do return stats
+end
+
+redef class CmdCatalogTags
+       redef fun to_json do return packages_count_by_tags
+end
+
+redef class CmdCatalogTag
+       redef fun to_json do
+               var obj = super.as(JsonObject)
+               obj["tag"] = tag
+               return obj
+       end
+end
+
+redef class CmdCatalogPerson
+       redef fun to_json do return person
+end
+
+redef class CmdCatalogMaintaining
+       redef fun to_json do
+               var obj = new JsonObject
+               obj["person"] = person
+               obj["results"] = results
+               obj["page"] = page
+               obj["count"] = count
+               obj["limit"] = limit
+               obj["max"] = max
+               return obj
+       end
+end
+
+redef class CmdCatalogContributing
+       redef fun to_json do
+               var obj = new JsonObject
+               obj["person"] = person
+               obj["results"] = results
+               obj["page"] = page
+               obj["count"] = count
+               obj["limit"] = limit
+               obj["max"] = max
+               return obj
+       end
+end
diff --git a/src/doc/commands/tests/test_commands_json.nit b/src/doc/commands/tests/test_commands_json.nit
new file mode 100644 (file)
index 0000000..c7db27e
--- /dev/null
@@ -0,0 +1,142 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module test_commands_json is test
+
+import test_commands
+import doc::commands::commands_json
+
+class TestCommandsJson
+       super TestCommands
+       test
+
+       fun print_json(json: nullable Serializable) do
+               if json == null then return
+               print json.serialize_to_json(pretty = true, plain = true)
+       end
+
+       # CmdEntity
+
+       fun test_cmd_entity is test do
+               var cmd = new CmdEntity(test_view, mentity_name = "test_prog::Character")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_comment is test do
+               var cmd = new CmdComment(test_view, mentity_name = "test_prog::Character")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       # CmdInheritance
+
+       fun test_cmd_parents is test do
+               var cmd = new CmdParents(test_view, mentity_name = "test_prog::Warrior")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_ancestors is test do
+               var cmd = new CmdAncestors(test_view, mentity_name = "test_prog::Warrior", parents = false)
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_children is test do
+               var cmd = new CmdChildren(test_view, mentity_name = "test_prog::Career")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_descendants is test do
+               var cmd = new CmdDescendants(test_view, mentity_name = "test_prog::Career")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       # CmdSearch
+
+       fun test_cmd_search is test do
+               var cmd = new CmdSearch(test_view, query = "Carer", limit = 10)
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       # CmdFeatures
+
+       fun test_cmd_features is test do
+               var cmd = new CmdFeatures(test_view, mentity_name = "test_prog::Career")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       # CmdLinearization
+
+       fun test_cmd_lin is test do
+               var cmd = new CmdLinearization(test_view, mentity_name = "init")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       # CmdModel
+
+       fun test_cmd_mentities is test do
+               var cmd = new CmdModelEntities(test_view, kind = "modules")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       # CmdUsage
+
+       fun test_cmd_new is test do
+               var cmd = new CmdNew(test_view, test_builder, mentity_name = "test_prog::Character")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_call is test do
+               var cmd = new CmdCall(test_view, test_builder, mentity_name = "strength_bonus")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_return is test do
+               var cmd = new CmdReturn(test_view, mentity_name = "test_prog::Character")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+
+       fun test_cmd_param is test do
+               var cmd = new CmdParam(test_view, mentity_name = "test_prog::Character")
+               cmd.init_command
+               print_json cmd.to_json
+       end
+end
+
+redef class nitc::Location
+       serialize
+
+       # Avoid diff on location absolute path
+       redef fun core_serialize_to(v) do
+               v.serialize_attribute("column_end", column_end)
+               v.serialize_attribute("column_start", column_start)
+               v.serialize_attribute("line_end", line_end)
+               v.serialize_attribute("line_start", line_start)
+               var file = self.file
+               if file != null then
+                       v.serialize_attribute("file", "test_location")
+               end
+       end
+end
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ancestors.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_ancestors.res
new file mode 100644 (file)
index 0000000..fcf2f01
--- /dev/null
@@ -0,0 +1,31 @@
+{
+       "results": [{
+               "name": "Object",
+               "class_name": "MClass",
+               "full_name": "test_prog::Object",
+               "mdoc": {
+                       "content": "Root of everything.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 21,
+                               "line_start": 20,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["interface"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 30,
+                       "line_start": 20,
+                       "file": "test_location"
+               },
+               "mparameters": []
+       }],
+       "page": null,
+       "count": null,
+       "limit": null,
+       "max": null
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_call.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_call.res
new file mode 100644 (file)
index 0000000..9dbc03c
--- /dev/null
@@ -0,0 +1,60 @@
+{
+       "results": [{
+               "name": "init",
+               "class_name": "MMethodDef",
+               "full_name": "test_prog$Character$Object::init",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["redef", "init"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 68,
+                       "line_start": 21,
+                       "file": "test_location"
+               },
+               "is_intro": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "total_strengh",
+               "class_name": "MMethodDef",
+               "full_name": "test_prog$Character$total_strengh",
+               "mdoc": {
+                       "content": "The actual strength of the character.\n\nReturns `race.base_strength + career.strength_bonus` or just `race.base_strength` is unemployed.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 2,
+                               "line_end": 42,
+                               "line_start": 39,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["fun"],
+               "location": {
+                       "column_end": 4,
+                       "column_start": 2,
+                       "line_end": 45,
+                       "line_start": 39,
+                       "file": "test_location"
+               },
+               "is_intro": true,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": {
+                               "full_name": "test_prog::Int"
+                       },
+                       "vararg_rank": -1
+               }
+       }],
+       "page": null,
+       "count": null,
+       "limit": null,
+       "max": null
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_children.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_children.res
new file mode 100644 (file)
index 0000000..6106b9b
--- /dev/null
@@ -0,0 +1,79 @@
+{
+       "results": [{
+               "name": "Alcoholic",
+               "class_name": "MClass",
+               "full_name": "test_prog::Alcoholic",
+               "mdoc": {
+                       "content": "Alcoholics are good to nothing escept taking punches.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 61,
+                               "line_start": 60,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["class"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 69,
+                       "line_start": 60,
+                       "file": "test_location"
+               },
+               "mparameters": []
+       }, {
+               "name": "Magician",
+               "class_name": "MClass",
+               "full_name": "test_prog::Magician",
+               "mdoc": {
+                       "content": "Magicians know magic and how to use it.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 50,
+                               "line_start": 49,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["class"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 58,
+                       "line_start": 49,
+                       "file": "test_location"
+               },
+               "mparameters": []
+       }, {
+               "name": "Warrior",
+               "class_name": "MClass",
+               "full_name": "test_prog::Warrior",
+               "mdoc": {
+                       "content": "Warriors are good for fighting.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 39,
+                               "line_start": 38,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["class"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 47,
+                       "line_start": 38,
+                       "file": "test_location"
+               },
+               "mparameters": []
+       }],
+       "page": null,
+       "count": null,
+       "limit": null,
+       "max": null
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_comment.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_comment.res
new file mode 100644 (file)
index 0000000..5f4128d
--- /dev/null
@@ -0,0 +1,3 @@
+{
+       "documentation": "Characters can be played by both the human or the machine."
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_descendants.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_descendants.res
new file mode 100644 (file)
index 0000000..6106b9b
--- /dev/null
@@ -0,0 +1,79 @@
+{
+       "results": [{
+               "name": "Alcoholic",
+               "class_name": "MClass",
+               "full_name": "test_prog::Alcoholic",
+               "mdoc": {
+                       "content": "Alcoholics are good to nothing escept taking punches.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 61,
+                               "line_start": 60,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["class"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 69,
+                       "line_start": 60,
+                       "file": "test_location"
+               },
+               "mparameters": []
+       }, {
+               "name": "Magician",
+               "class_name": "MClass",
+               "full_name": "test_prog::Magician",
+               "mdoc": {
+                       "content": "Magicians know magic and how to use it.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 50,
+                               "line_start": 49,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["class"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 58,
+                       "line_start": 49,
+                       "file": "test_location"
+               },
+               "mparameters": []
+       }, {
+               "name": "Warrior",
+               "class_name": "MClass",
+               "full_name": "test_prog::Warrior",
+               "mdoc": {
+                       "content": "Warriors are good for fighting.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 39,
+                               "line_start": 38,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["class"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 47,
+                       "line_start": 38,
+                       "file": "test_location"
+               },
+               "mparameters": []
+       }],
+       "page": null,
+       "count": null,
+       "limit": null,
+       "max": null
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_entity.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_entity.res
new file mode 100644 (file)
index 0000000..63035b5
--- /dev/null
@@ -0,0 +1,25 @@
+{
+       "name": "Character",
+       "class_name": "MClass",
+       "full_name": "test_prog::Character",
+       "mdoc": {
+               "content": "Characters can be played by both the human or the machine.",
+               "location": {
+                       "column_end": 0,
+                       "column_start": 1,
+                       "line_end": 22,
+                       "line_start": 21,
+                       "file": "test_location"
+               }
+       },
+       "visibility": "public",
+       "modifiers": ["class"],
+       "location": {
+               "column_end": 3,
+               "column_start": 1,
+               "line_end": 68,
+               "line_start": 21,
+               "file": "test_location"
+       },
+       "mparameters": []
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_features.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_features.res
new file mode 100644 (file)
index 0000000..402b350
--- /dev/null
@@ -0,0 +1,229 @@
+{
+       "results": [{
+               "name": "_endurance_bonus",
+               "class_name": "MAttribute",
+               "full_name": "test_prog::careers::Career::_endurance_bonus",
+               "mdoc": null,
+               "visibility": "private",
+               "modifiers": ["private", "var"],
+               "location": {
+                       "column_end": 25,
+                       "column_start": 2,
+                       "line_end": 32,
+                       "line_start": 32,
+                       "file": "test_location"
+               },
+               "static_mtype": {
+                       "full_name": "test_prog::Int"
+               }
+       }, {
+               "name": "_intelligence_bonus",
+               "class_name": "MAttribute",
+               "full_name": "test_prog::careers::Career::_intelligence_bonus",
+               "mdoc": null,
+               "visibility": "private",
+               "modifiers": ["private", "var"],
+               "location": {
+                       "column_end": 28,
+                       "column_start": 2,
+                       "line_end": 33,
+                       "line_start": 33,
+                       "file": "test_location"
+               },
+               "static_mtype": {
+                       "full_name": "test_prog::Int"
+               }
+       }, {
+               "name": "_strength_bonus",
+               "class_name": "MAttribute",
+               "full_name": "test_prog::careers::Career::_strength_bonus",
+               "mdoc": null,
+               "visibility": "private",
+               "modifiers": ["private", "var"],
+               "location": {
+                       "column_end": 24,
+                       "column_start": 2,
+                       "line_end": 31,
+                       "line_start": 31,
+                       "file": "test_location"
+               },
+               "static_mtype": {
+                       "full_name": "test_prog::Int"
+               }
+       }, {
+               "name": "endurance_bonus",
+               "class_name": "MMethod",
+               "full_name": "test_prog::Career::endurance_bonus",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["fun"],
+               "location": {
+                       "column_end": 25,
+                       "column_start": 2,
+                       "line_end": 32,
+                       "line_start": 32,
+                       "file": "test_location"
+               },
+               "is_init": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": {
+                               "full_name": "test_prog::Int"
+                       },
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "endurance_bonus=",
+               "class_name": "MMethod",
+               "full_name": "test_prog::Career::endurance_bonus=",
+               "mdoc": null,
+               "visibility": "protected",
+               "modifiers": ["protected", "fun"],
+               "location": {
+                       "column_end": 25,
+                       "column_start": 2,
+                       "line_end": 32,
+                       "line_start": 32,
+                       "file": "test_location"
+               },
+               "is_init": false,
+               "msignature": {
+                       "arity": 1,
+                       "mparams": [{
+                               "is_vararg": false,
+                               "name": "endurance_bonus",
+                               "mtype": {
+                                       "full_name": "test_prog::Int"
+                               }
+                       }],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "init",
+               "class_name": "MMethodDef",
+               "full_name": "test_prog$Career$Object::init",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["redef", "init"],
+               "location": {
+                       "column_end": 12,
+                       "column_start": 2,
+                       "line_end": 35,
+                       "line_start": 35,
+                       "file": "test_location"
+               },
+               "is_intro": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "intelligence_bonus",
+               "class_name": "MMethod",
+               "full_name": "test_prog::Career::intelligence_bonus",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["fun"],
+               "location": {
+                       "column_end": 28,
+                       "column_start": 2,
+                       "line_end": 33,
+                       "line_start": 33,
+                       "file": "test_location"
+               },
+               "is_init": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": {
+                               "full_name": "test_prog::Int"
+                       },
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "intelligence_bonus=",
+               "class_name": "MMethod",
+               "full_name": "test_prog::Career::intelligence_bonus=",
+               "mdoc": null,
+               "visibility": "protected",
+               "modifiers": ["protected", "fun"],
+               "location": {
+                       "column_end": 28,
+                       "column_start": 2,
+                       "line_end": 33,
+                       "line_start": 33,
+                       "file": "test_location"
+               },
+               "is_init": false,
+               "msignature": {
+                       "arity": 1,
+                       "mparams": [{
+                               "is_vararg": false,
+                               "name": "intelligence_bonus",
+                               "mtype": {
+                                       "full_name": "test_prog::Int"
+                               }
+                       }],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "strength_bonus",
+               "class_name": "MMethod",
+               "full_name": "test_prog::Career::strength_bonus",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["fun"],
+               "location": {
+                       "column_end": 24,
+                       "column_start": 2,
+                       "line_end": 31,
+                       "line_start": 31,
+                       "file": "test_location"
+               },
+               "is_init": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": {
+                               "full_name": "test_prog::Int"
+                       },
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "strength_bonus=",
+               "class_name": "MMethod",
+               "full_name": "test_prog::Career::strength_bonus=",
+               "mdoc": null,
+               "visibility": "protected",
+               "modifiers": ["protected", "fun"],
+               "location": {
+                       "column_end": 24,
+                       "column_start": 2,
+                       "line_end": 31,
+                       "line_start": 31,
+                       "file": "test_location"
+               },
+               "is_init": false,
+               "msignature": {
+                       "arity": 1,
+                       "mparams": [{
+                               "is_vararg": false,
+                               "name": "strength_bonus",
+                               "mtype": {
+                                       "full_name": "test_prog::Int"
+                               }
+                       }],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }],
+       "page": null,
+       "count": null,
+       "limit": null,
+       "max": null
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_lin.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_lin.res
new file mode 100644 (file)
index 0000000..ae8f477
--- /dev/null
@@ -0,0 +1,217 @@
+{
+       "results": [{
+               "name": "init",
+               "class_name": "MMethodDef",
+               "full_name": "test_prog$Object$init",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["init"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 30,
+                       "line_start": 20,
+                       "file": "test_location"
+               },
+               "is_intro": true,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "init",
+               "class_name": "MMethodDef",
+               "full_name": "test_prog$Race$Object::init",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["redef", "init"],
+               "location": {
+                       "column_end": 12,
+                       "column_start": 2,
+                       "line_end": 44,
+                       "line_start": 44,
+                       "file": "test_location"
+               },
+               "is_intro": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "init",
+               "class_name": "MMethodDef",
+               "full_name": "test_prog$Career$Object::init",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["redef", "init"],
+               "location": {
+                       "column_end": 12,
+                       "column_start": 2,
+                       "line_end": 35,
+                       "line_start": 35,
+                       "file": "test_location"
+               },
+               "is_intro": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "init",
+               "class_name": "MMethodDef",
+               "full_name": "test_prog$Human$Object::init",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["redef", "init"],
+               "location": {
+                       "column_end": 4,
+                       "column_start": 2,
+                       "line_end": 55,
+                       "line_start": 51,
+                       "file": "test_location"
+               },
+               "is_intro": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "init",
+               "class_name": "MMethodDef",
+               "full_name": "test_prog$Elf$Object::init",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["redef", "init"],
+               "location": {
+                       "column_end": 4,
+                       "column_start": 2,
+                       "line_end": 77,
+                       "line_start": 73,
+                       "file": "test_location"
+               },
+               "is_intro": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "init",
+               "class_name": "MMethodDef",
+               "full_name": "test_prog$Warrior$Object::init",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["redef", "init"],
+               "location": {
+                       "column_end": 4,
+                       "column_start": 2,
+                       "line_end": 46,
+                       "line_start": 42,
+                       "file": "test_location"
+               },
+               "is_intro": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "init",
+               "class_name": "MMethodDef",
+               "full_name": "test_prog$Magician$Object::init",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["redef", "init"],
+               "location": {
+                       "column_end": 4,
+                       "column_start": 2,
+                       "line_end": 57,
+                       "line_start": 53,
+                       "file": "test_location"
+               },
+               "is_intro": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "init",
+               "class_name": "MMethodDef",
+               "full_name": "test_prog$Alcoholic$Object::init",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["redef", "init"],
+               "location": {
+                       "column_end": 4,
+                       "column_start": 2,
+                       "line_end": 68,
+                       "line_start": 64,
+                       "file": "test_location"
+               },
+               "is_intro": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "init",
+               "class_name": "MMethodDef",
+               "full_name": "test_prog$Character$Object::init",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["redef", "init"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 68,
+                       "line_start": 21,
+                       "file": "test_location"
+               },
+               "is_intro": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "init",
+               "class_name": "MMethodDef",
+               "full_name": "test_prog$Dwarf$Object::init",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["redef", "init"],
+               "location": {
+                       "column_end": 4,
+                       "column_start": 2,
+                       "line_end": 66,
+                       "line_start": 62,
+                       "file": "test_location"
+               },
+               "is_intro": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": null,
+                       "vararg_rank": -1
+               }
+       }],
+       "page": null,
+       "count": null,
+       "limit": null,
+       "max": null
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_mentities.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_mentities.res
new file mode 100644 (file)
index 0000000..6a09f6b
--- /dev/null
@@ -0,0 +1,205 @@
+{
+       "results": [{
+               "name": "careers",
+               "class_name": "MModule",
+               "full_name": "test_prog::careers",
+               "mdoc": {
+                       "content": "Careers of the game.\n\nAll characters can have a `Career`.\nA character can also quit its current career and start a new one.\n\nAvailable careers:\n\n * `Warrior`\n * `Magician`\n * `Alcoholic`",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 25,
+                               "line_start": 15,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["module"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 69,
+                       "line_start": 15,
+                       "file": "test_location"
+               }
+       }, {
+               "name": "character",
+               "class_name": "MModule",
+               "full_name": "test_prog::character",
+               "mdoc": {
+                       "content": "Characters are playable entity in the world.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 16,
+                               "line_start": 15,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["module"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 68,
+                       "line_start": 15,
+                       "file": "test_location"
+               }
+       }, {
+               "name": "combat",
+               "class_name": "MModule",
+               "full_name": "test_prog::combat",
+               "mdoc": {
+                       "content": "COmbat interactions between characters.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 16,
+                               "line_start": 15,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["module"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 67,
+                       "line_start": 15,
+                       "file": "test_location"
+               }
+       }, {
+               "name": "excluded",
+               "class_name": "MModule",
+               "full_name": "excluded::excluded",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["module"],
+               "location": {
+                       "column_end": 0,
+                       "column_start": 0,
+                       "line_end": 0,
+                       "line_start": 0,
+                       "file": "test_location"
+               }
+       }, {
+               "name": "game",
+               "class_name": "MModule",
+               "full_name": "test_prog::game",
+               "mdoc": {
+                       "content": "A game abstraction for RPG.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 16,
+                               "line_start": 15,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["module"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 45,
+                       "line_start": 15,
+                       "file": "test_location"
+               }
+       }, {
+               "name": "platform",
+               "class_name": "MModule",
+               "full_name": "test_prog::platform",
+               "mdoc": {
+                       "content": "Declares base types allowed on the platform.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 16,
+                               "line_start": 15,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["module"],
+               "location": {
+                       "column_end": 17,
+                       "column_start": 1,
+                       "line_end": 59,
+                       "line_start": 15,
+                       "file": "test_location"
+               }
+       }, {
+               "name": "races",
+               "class_name": "MModule",
+               "full_name": "test_prog::races",
+               "mdoc": {
+                       "content": "Races of the game.\n\nAll characters belong to a `Race`.\n\nAvailable races:\n\n * `Human`\n * `Dwarf`\n * `Elf`",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 24,
+                               "line_start": 15,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["module"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 78,
+                       "line_start": 15,
+                       "file": "test_location"
+               }
+       }, {
+               "name": "rpg",
+               "class_name": "MModule",
+               "full_name": "test_prog::rpg",
+               "mdoc": {
+                       "content": "A worlg RPG abstraction.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 16,
+                               "line_start": 15,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["module"],
+               "location": {
+                       "column_end": 13,
+                       "column_start": 1,
+                       "line_end": 21,
+                       "line_start": 15,
+                       "file": "test_location"
+               }
+       }, {
+               "name": "test_prog",
+               "class_name": "MModule",
+               "full_name": "test_prog::test_prog",
+               "mdoc": {
+                       "content": "A test program with a fake model to check model tools.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 16,
+                               "line_start": 15,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["module"],
+               "location": {
+                       "column_end": 13,
+                       "column_start": 1,
+                       "line_end": 26,
+                       "line_start": 15,
+                       "file": "test_location"
+               }
+       }],
+       "page": null,
+       "count": null,
+       "limit": null,
+       "max": null
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_new.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_new.res
new file mode 100644 (file)
index 0000000..99893dd
--- /dev/null
@@ -0,0 +1,7 @@
+{
+       "results": [],
+       "page": null,
+       "count": null,
+       "limit": null,
+       "max": null
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_param.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_param.res
new file mode 100644 (file)
index 0000000..99893dd
--- /dev/null
@@ -0,0 +1,7 @@
+{
+       "results": [],
+       "page": null,
+       "count": null,
+       "limit": null,
+       "max": null
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_parents.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_parents.res
new file mode 100644 (file)
index 0000000..a746bec
--- /dev/null
@@ -0,0 +1,31 @@
+{
+       "results": [{
+               "name": "Career",
+               "class_name": "MClass",
+               "full_name": "test_prog::Career",
+               "mdoc": {
+                       "content": "A `Career` gives a characteristic bonus or malus to the character.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 30,
+                               "line_start": 29,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["abstract class"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 36,
+                       "line_start": 29,
+                       "file": "test_location"
+               },
+               "mparameters": []
+       }],
+       "page": null,
+       "count": null,
+       "limit": null,
+       "max": null
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_return.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_return.res
new file mode 100644 (file)
index 0000000..99893dd
--- /dev/null
@@ -0,0 +1,7 @@
+{
+       "results": [],
+       "page": null,
+       "count": null,
+       "limit": null,
+       "max": null
+}
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_search.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_search.res
new file mode 100644 (file)
index 0000000..95bf855
--- /dev/null
@@ -0,0 +1,241 @@
+{
+       "results": [{
+               "name": "Career",
+               "class_name": "MClass",
+               "full_name": "test_prog::Career",
+               "mdoc": {
+                       "content": "A `Career` gives a characteristic bonus or malus to the character.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 30,
+                               "line_start": 29,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["abstract class"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 36,
+                       "line_start": 29,
+                       "file": "test_location"
+               },
+               "mparameters": []
+       }, {
+               "name": "career",
+               "class_name": "MMethod",
+               "full_name": "test_prog::Character::career",
+               "mdoc": {
+                       "content": "The current `Career` of the character.\nReturns `null` if character is unemployed.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 2,
+                               "line_end": 29,
+                               "line_start": 27,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["fun"],
+               "location": {
+                       "column_end": 47,
+                       "column_start": 2,
+                       "line_end": 29,
+                       "line_start": 27,
+                       "file": "test_location"
+               },
+               "is_init": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": {
+                               "full_name": "nullable test_prog::Career"
+                       },
+                       "vararg_rank": -1
+               }
+       }, {
+               "name": "game",
+               "class_name": "MGroup",
+               "full_name": "test_prog>game>",
+               "mdoc": {
+                       "content": "Gaming group",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 0,
+                               "line_end": 1,
+                               "line_start": 1,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["group"],
+               "location": {
+                       "column_end": 0,
+                       "column_start": 0,
+                       "line_end": 0,
+                       "line_start": 0,
+                       "file": "test_location"
+               }
+       }, {
+               "name": "game",
+               "class_name": "MModule",
+               "full_name": "test_prog::game",
+               "mdoc": {
+                       "content": "A game abstraction for RPG.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 16,
+                               "line_start": 15,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["module"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 45,
+                       "line_start": 15,
+                       "file": "test_location"
+               }
+       }, {
+               "name": "races",
+               "class_name": "MModule",
+               "full_name": "test_prog::races",
+               "mdoc": {
+                       "content": "Races of the game.\n\nAll characters belong to a `Race`.\n\nAvailable races:\n\n * `Human`\n * `Dwarf`\n * `Elf`",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 24,
+                               "line_start": 15,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["module"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 78,
+                       "line_start": 15,
+                       "file": "test_location"
+               }
+       }, {
+               "name": "careers",
+               "class_name": "MModule",
+               "full_name": "test_prog::careers",
+               "mdoc": {
+                       "content": "Careers of the game.\n\nAll characters can have a `Career`.\nA character can also quit its current career and start a new one.\n\nAvailable careers:\n\n * `Warrior`\n * `Magician`\n * `Alcoholic`",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 25,
+                               "line_start": 15,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["module"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 69,
+                       "line_start": 15,
+                       "file": "test_location"
+               }
+       }, {
+               "name": "Game",
+               "class_name": "MClass",
+               "full_name": "test_prog::Game",
+               "mdoc": {
+                       "content": "This is the interface you have to implement to use ure gaming platform.\n\nsee http://our.platform.com",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 23,
+                               "line_start": 20,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["interface"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 45,
+                       "line_start": 20,
+                       "file": "test_location"
+               },
+               "mparameters": []
+       }, {
+               "name": "Race",
+               "class_name": "MClass",
+               "full_name": "test_prog::Race",
+               "mdoc": {
+                       "content": "Race determines basic characteristics and what the character will be able to do in life.\n\nThese are base characteristics, they cannot be changed\nbut you can add new ones if needed using refinement.\nObjects and spells cannot change those characteristics.",
+                       "location": {
+                               "column_end": 0,
+                               "column_start": 1,
+                               "line_end": 33,
+                               "line_start": 28,
+                               "file": "test_location"
+                       }
+               },
+               "visibility": "public",
+               "modifiers": ["abstract class"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 45,
+                       "line_start": 28,
+                       "file": "test_location"
+               },
+               "mparameters": []
+       }, {
+               "name": "Starter",
+               "class_name": "MClass",
+               "full_name": "test_prog::Starter",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["class"],
+               "location": {
+                       "column_end": 3,
+                       "column_start": 1,
+                       "line_end": 23,
+                       "line_start": 21,
+                       "file": "test_location"
+               },
+               "mparameters": []
+       }, {
+               "name": "age",
+               "class_name": "MMethod",
+               "full_name": "test_prog::Character::age",
+               "mdoc": null,
+               "visibility": "public",
+               "modifiers": ["fun"],
+               "location": {
+                       "column_end": 13,
+                       "column_start": 2,
+                       "line_end": 36,
+                       "line_start": 36,
+                       "file": "test_location"
+               },
+               "is_init": false,
+               "msignature": {
+                       "arity": 0,
+                       "mparams": [],
+                       "return_mtype": {
+                               "full_name": "test_prog::Int"
+                       },
+                       "vararg_rank": -1
+               }
+       }],
+       "page": 1,
+       "count": 106,
+       "limit": 10,
+       "max": 10
+}