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_catalog
24 import templates
::json_model
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
90 var obj
= new JsonObject
92 if node
== null then return obj
94 var code
= render_code
(node
)
95 obj
["location"] = node
.location
96 obj
["code"] = code
.write_to_string
103 var obj
= new JsonObject
105 if output
!= null then
106 obj
["graph"] = output
.write_to_string
112 redef class CmdMetadata
113 redef fun to_json
do return metadata
118 redef class CmdCatalogStats
119 redef fun to_json
do return stats
122 redef class CmdCatalogTags
123 redef fun to_json
do return packages_count_by_tags
126 redef class CmdCatalogTag
128 var obj
= super.as(JsonObject)
134 redef class CmdCatalogPerson
135 redef fun to_json
do return person
138 redef class CmdCatalogMaintaining
140 var obj
= new JsonObject
141 obj
["person"] = person
142 obj
["results"] = results
151 redef class CmdCatalogContributing
153 var obj
= new JsonObject
154 obj
["person"] = person
155 obj
["results"] = results
166 redef class CmdIniDescription
168 var obj
= new JsonObject
174 redef class CmdIniGitUrl
176 var obj
= new JsonObject
182 redef class CmdIniCloneCommand
184 var obj
= new JsonObject
185 obj
["command"] = command
190 redef class CmdIniIssuesUrl
192 var obj
= new JsonObject
198 redef class CmdIniMaintainer
200 var obj
= new JsonObject
201 obj
["maintainer"] = maintainer
206 redef class CmdIniContributors
208 var obj
= new JsonObject
209 obj
["contributors"] = contributors
214 redef class CmdIniLicense
216 var obj
= new JsonObject
217 obj
["license"] = license
222 redef class CmdLicenseFile
224 var obj
= new JsonObject
230 redef class CmdLicenseFileContent
232 var obj
= super.as(JsonObject)
233 obj
["content"] = content
238 redef class CmdContribFile
240 var obj
= new JsonObject
246 redef class CmdContribFileContent
248 var obj
= super.as(JsonObject)
249 obj
["content"] = content
258 var obj
= new JsonObject
259 obj
["results"] = results
264 redef class CmdMainCompile
266 var obj
= new JsonObject
267 obj
["command"] = command
272 redef class CmdTesting
274 var obj
= new JsonObject
275 obj
["command"] = command
280 redef class CmdManSynopsis
282 var obj
= new JsonObject
283 obj
["synopsis"] = synopsis
288 redef class CmdManOptions
290 var obj
= new JsonObject
291 obj
["options"] = options