eb40af4402d839918d85dfeb7fc0bebb20e2b486
1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Translate command results to json
18 import commands
::commands_model
19 import commands
::commands_graph
20 import commands
::commands_usage
21 import commands
::commands_catalog
23 import templates
::templates_json
24 import catalog
::catalog_json
26 redef class DocCommand
27 # Return a JSON Serializable representation of `self` results
28 fun to_json
: nullable Serializable is abstract
33 redef class CmdMessage
34 # Return a JSON Serializable representation of `self`
35 fun to_json
: nullable Serializable do
36 var obj
= new JsonObject
37 obj
["status"] = class_name
44 redef fun to_json
do return mentity
49 var obj
= new JsonObject
50 obj
["results"] = results
59 redef class CmdEntityList
60 redef fun to_json
do return super
65 redef class CmdComment
67 var obj
= new JsonObject
68 var render
= self.render_comment
69 if render
!= null then
70 obj
["documentation"] = render
.write_to_string
78 var obj
= new JsonObject
81 obj
["location"] = node
.location
84 if output
!= null then
85 obj
["code"] = output
.write_to_string
93 var obj
= new JsonObject
95 if output
!= null then
96 obj
["graph"] = output
.write_to_string
102 redef class CmdMetadata
103 redef fun to_json
do return metadata
108 redef class CmdCatalogStats
109 redef fun to_json
do return stats
112 redef class CmdCatalogTags
113 redef fun to_json
do return packages_count_by_tags
116 redef class CmdCatalogTag
118 var obj
= super.as(JsonObject)
124 redef class CmdCatalogPerson
125 redef fun to_json
do return person
128 redef class CmdCatalogMaintaining
130 var obj
= new JsonObject
131 obj
["person"] = person
132 obj
["results"] = results
141 redef class CmdCatalogContributing
143 var obj
= new JsonObject
144 obj
["person"] = person
145 obj
["results"] = results