highlight: remove default links. Clients have to provide them
authorJean Privat <jean@pryen.org>
Mon, 13 Jun 2016 20:46:52 +0000 (16:46 -0400)
committerJean Privat <jean@pryen.org>
Wed, 15 Jun 2016 23:07:04 +0000 (19:07 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/highlight.nit

index 757af93..6399c5e 100644 (file)
@@ -60,11 +60,9 @@ class HighlightVisitor
        # It is used to refer to some specific entities when generating links.
        # If `null` is returned, then no link are generated and `<a>` elements become `<span>`.
        #
-       # Clients are encouraged to redefine the method in a subclass to control where entities should link to.
-       fun hrefto(entitiy: MEntity): nullable String
-       do
-               return entitiy.href
-       end
+       # By default, `null` is returned.
+       # Clients are therefore encouraged to redefine the method in a subclass to control where entities should link to.
+       fun hrefto(entitiy: MEntity): nullable String do return null
 
        init
        do
@@ -171,7 +169,7 @@ class HighlightVisitor
                var stack = new Array[Prod]
                var line = 0
                var c: nullable Token = first_token
-               var hv = new HighlightVisitor
+               var hv = self
                while c != null do
                        var starting
 
@@ -427,9 +425,6 @@ redef class MEntity
                end
                return (new HTMLTag("a")).attr("href", href).text(text)
        end
-
-       # Default link
-       private fun href: nullable String do return null
 end
 
 redef class MModule
@@ -450,12 +445,6 @@ redef class MModule
                return res
        end
 
-       # The module HTML page
-       redef fun href: String
-       do
-               return c_name + ".html"
-       end
-
        redef fun linkto(v) do return linkto_text(v, name)
 end
 
@@ -501,12 +490,6 @@ redef class MClassDef
                end
                return res
        end
-
-       # The class HTML page (an anchor in the module page)
-       redef fun href: String
-       do
-               return mmodule.href + "#" + to_s
-       end
 end
 
 redef class MPropDef
@@ -540,12 +523,6 @@ redef class MPropDef
 
                return res
        end
-
-       # The property HTML page (an anchor in the module page)
-       redef fun href: String
-       do
-               return self.mclassdef.mmodule.href + "#" + self.to_s
-       end
 end
 
 redef class MClassType