doc/commands: CmdCode does not use infoboxes in html highlight
authorAlexandre Terrasa <alexandre@moz-code.org>
Fri, 1 Jun 2018 16:38:16 +0000 (12:38 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Fri, 1 Jun 2018 17:14:36 +0000 (13:14 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/doc/commands/commands_html.nit
src/doc/commands/commands_model.nit

index 8cffb32..7aac39a 100644 (file)
@@ -322,3 +322,13 @@ redef class CmdTesting
                return "<pre>{command}</pre>"
        end
 end
+
+# Misc
+
+redef class CmdHtmlightVisitor
+       redef fun hrefto(mentity) do
+               if mentity isa MClassDef then return mentity.mclass.html_url
+               if mentity isa MPropDef then return mentity.mproperty.html_url
+               return mentity.html_url
+       end
+end
index 71f23ed..ffb530d 100644 (file)
@@ -447,7 +447,8 @@ abstract class CmdCode
        fun render_code(node: nullable ANode): nullable Writable do
                if node == null then return null
                if format == "html" then
-                       var hl = new HtmlightVisitor
+                       var hl = new CmdHtmlightVisitor
+                       hl.show_infobox = false
                        hl.highlight_node node
                        return hl.html
                else if format == "ansi" then
@@ -459,6 +460,14 @@ abstract class CmdCode
        end
 end
 
+# Custom HtmlightVisitor for commands
+#
+# We create a new subclass so its behavior can be refined in clients without
+# breaking the main implementation.
+class CmdHtmlightVisitor
+       super HtmlightVisitor
+end
+
 # Cmd that finds the source code related to an `mentity`
 class CmdEntityCode
        super CmdEntity