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 # Render commands results as HTML
18 import commands
::commands_graph
19 import commands
::commands_usage
21 import templates
::templates_html
25 redef class DocCommand
27 # Render results as a HTML string
28 fun to_html
: Writable do return "<p class='text-danger'>Not yet implemented</p>"
31 redef class CmdMessage
33 # Render the message as a HTML string
34 fun to_html
: Writable is abstract
38 redef fun to_html
do return "<p class='text-danger'>Error: {to_s}</p>"
41 redef class CmdWarning
42 redef fun to_html
do return "<p class='text-warning'>Warning: {to_s}</p>"
49 var mentity
= self.mentity
50 if mentity
== null then return ""
51 return mentity
.html_link
55 redef class CmdEntities
57 var mentities
= self.results
58 if mentities
== null then return ""
60 var tpl
= new Template
62 for mentity
in mentities
do
63 var mdoc
= mentity
.mdoc_or_fallback
65 tpl
.add mentity
.html_link
68 tpl
.add mdoc
.html_synopsis
73 return tpl
.write_to_string
77 redef class CmdComment
79 var mentity
= self.mentity
80 if mentity
== null then return ""
83 var tpl
= new Template
85 # FIXME comments left here until I figure out what to do about the presentation options
86 # if not opts.has_key("no-link") then
87 tpl
.add mentity
.html_link
90 # if not opts.has_key("no-link") and not opts.has_key("no-synopsis") then
93 # if not opts.has_key("no-synopsis") then
94 tpl
.add mdoc
.html_synopsis
99 # if not opts.has_key("no-comment") then
100 tpl
.add mdoc
.html_comment
103 return tpl
.write_to_string
107 redef class CmdEntityCode
109 var output
= render_code
(node
)
110 if output
== null then return ""
111 return "<pre>{output.write_to_string}</pre>"
120 if output
== null then return ""
121 return output
.write_to_string