82571cc9ec9e7e65e3b82a4ec1ebbefc02bc785f
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
22 import commands
::commands_ini
24 import templates
::templates_json
25 import catalog
::catalog_json
27 redef class DocCommand
28 # Return a JSON Serializable representation of `self` results
29 fun to_json
: nullable Serializable is abstract
34 redef class CmdMessage
35 # Return a JSON Serializable representation of `self`
36 fun to_json
: nullable Serializable do
37 var obj
= new JsonObject
38 obj
["status"] = class_name
45 redef fun to_json
do return mentity
50 var obj
= new JsonObject
51 obj
["results"] = results
60 redef class CmdEntityList
61 redef fun to_json
do return super
66 redef class CmdComment
68 var obj
= new JsonObject
69 var render
= self.render_comment
70 if render
!= null then
71 obj
["documentation"] = render
.write_to_string
77 redef class CmdEntityLink
79 var obj
= new JsonObject
81 if text
!= null then obj
["text"] = text
82 var title
= self.title
83 if title
!= null then obj
["title"] = title
88 redef class CmdEntityCode
90 var obj
= new JsonObject
93 obj
["location"] = node
.location
95 var output
= render_code
(node
)
96 if output
!= null then
97 obj
["code"] = output
.write_to_string
105 var obj
= new JsonObject
107 if output
!= null then
108 obj
["graph"] = output
.write_to_string
114 redef class CmdMetadata
115 redef fun to_json
do return metadata
120 redef class CmdCatalogStats
121 redef fun to_json
do return stats
124 redef class CmdCatalogTags
125 redef fun to_json
do return packages_count_by_tags
128 redef class CmdCatalogTag
130 var obj
= super.as(JsonObject)
136 redef class CmdCatalogPerson
137 redef fun to_json
do return person
140 redef class CmdCatalogMaintaining
142 var obj
= new JsonObject
143 obj
["person"] = person
144 obj
["results"] = results
153 redef class CmdCatalogContributing
155 var obj
= new JsonObject
156 obj
["person"] = person
157 obj
["results"] = results
168 redef class CmdIniDescription
170 var obj
= new JsonObject
176 redef class CmdIniGitUrl
178 var obj
= new JsonObject
184 redef class CmdIniCloneCommand
186 var obj
= new JsonObject
187 obj
["command"] = command
192 redef class CmdIniIssuesUrl
194 var obj
= new JsonObject
200 redef class CmdIniMaintainer
202 var obj
= new JsonObject
203 obj
["maintainer"] = maintainer
208 redef class CmdIniContributors
210 var obj
= new JsonObject
211 obj
["contributors"] = contributors
216 redef class CmdIniLicense
218 var obj
= new JsonObject
219 obj
["license"] = license
224 redef class CmdLicenseFile
226 var obj
= new JsonObject
232 redef class CmdLicenseFileContent
234 var obj
= super.as(JsonObject)
235 obj
["content"] = content
240 redef class CmdContribFile
242 var obj
= new JsonObject
248 redef class CmdContribFileContent
250 var obj
= super.as(JsonObject)
251 obj
["content"] = content