doc/commands: introduce CmdEntityLink command
[nit.git] / src / doc / term / term.nit
index 33b5221..a82d7b8 100644 (file)
@@ -207,7 +207,10 @@ redef class CmdFeatures
        end
 end
 
-redef class CmdCode
+redef class CmdEntityCode
+
+       redef var format = "ansi" is optional
+
        redef fun execute(no_color) do
                var mentity = self.mentity
                if mentity == null then return
@@ -218,7 +221,16 @@ redef class CmdCode
                else
                        print title
                end
-               printn mentity.cs_source_code
+               if no_color == null or not no_color then
+                       var ansi = render_code(node)
+                       if ansi != null then
+                               print "~~~"
+                               print ansi.write_to_string
+                               print "~~~"
+                       end
+               else
+                       printn mentity.cs_source_code
+               end
        end
 end