ni_nitdoc: factorized html lnk to modules
[nit.git] / src / ni_nitdoc.nit
index 2db5723..f928914 100644 (file)
@@ -110,7 +110,7 @@ class Nitdoc
        end
 
        fun overview do
-               var overviewpage = new NitdocOverview.with(modelbuilder.nmodules, self.opt_nodot.value, destinationdir.to_s)
+               var overviewpage = new NitdocOverview.with(modelbuilder, self.opt_nodot.value, destinationdir.to_s)
                overviewpage.save("{destinationdir.to_s}/index.html")
        end
 
@@ -120,20 +120,16 @@ class Nitdoc
        end
 
        fun modules do
-               for mod in modelbuilder.nmodules do
-                       var modulepage = new NitdocModules.with(mod)
-                       modulepage.save("{destinationdir.to_s}/{mod.mmodule.name}.html")
+               for mmodule in model.mmodules do
+                       var modulepage = new NitdocModule.with(mmodule, modelbuilder)
+                       modulepage.save("{destinationdir.to_s}/{mmodule.name}.html")
                end
        end
 
        fun classes do
-               for amodule in modelbuilder.nmodules do
-                       for mclass, aclassdef in amodule.mclass2nclassdef do
-                               mclass.amodule(modelbuilder.mmodule2nmodule)
-                               mclass.mmethod(aclassdef.mprop2npropdef)
-                               var classpage = new NitdocMClasses.with(mclass, aclassdef, source)
-                               classpage.save("{destinationdir.to_s}/{mclass.name}.html")
-                       end
+               for mclass in modelbuilder.model.mclasses do
+                       var classpage = new NitdocClass.with(mclass, modelbuilder, source)
+                       classpage.save("{destinationdir.to_s}/{mclass.name}.html")
                end
        end
 
@@ -170,33 +166,35 @@ class Nitdoc
 
 end
 
-class NitdocOverview
-       super NitdocPage
+# Nitdoc base page
+abstract class NitdocPage
+       super HTMLPage
 
-       var amodules: Array[AModule]
+       var opt_nodot: Bool
+       var destinationdir : String
+       var source: nullable String
 
-       # Init with Array[AModule] to get all ifnormations about each MModule containt in a program
-       # opt_nodot to inform about the graph gen
-       # destination: to know where will be saved dot files
-       init with(modules: Array[AModule], opt_nodot: Bool, destination: String) do
-               self.amodules = modules
-               self.opt_nodot = opt_nodot
-               self.destinationdir = destination
+       redef fun head do
+               add("meta").attr("charset", "utf-8")
+               add("script").attr("type", "text/javascript").attr("src", "scripts/jquery-1.7.1.min.js")
+               add("script").attr("type", "text/javascript").attr("src", "quicksearch-list.js")
+               add("script").attr("type", "text/javascript").attr("src", "scripts/js-facilities.js")
+               add("link").attr("rel", "stylesheet").attr("href", "styles/main.css").attr("type", "text/css").attr("media", "screen")
        end
 
-       redef fun head do
-               super
-               add("title").text("Overview | Nit Standard Library")
+       redef fun body do
+               header
+               content
+               footer
        end
 
-       redef fun header do
+       fun menu is abstract
+
+       fun header do
                open("header")
                open("nav").add_class("main")
                open("ul")
-               add("li").add_class("current").text("Overview")
-               open("li")
-               add_html("<a href=\"full-index.html\">Full Index</a>")
-               close("li")
+               menu
                open("li").attr("id", "liGitHub")
                open("a").add_class("btn").attr("id", "logGitHub")
                add("img").attr("id", "imgGitHub").attr("src", "resources/icons/github-icon.png")
@@ -241,8 +239,74 @@ class NitdocOverview
                close("header")
        end
 
-       redef fun body do
+       fun content is abstract
+
+       fun footer do
+               add("footer").text("Nit standard library. Version jenkins-component=stdlib-19.")
+       end
+
+       # Generate a clickable graphviz image using a dot content
+       fun generate_dot(dot: String, name: String, alt: String) do
+               if opt_nodot then return
+               var file = new OFStream.open("{self.destinationdir}/{name}.dot")
+               file.write(dot)
+               file.close
+               sys.system("\{ test -f {self.destinationdir}/{name}.png && test -f {self.destinationdir}/{name}.s.dot && diff {self.destinationdir}/{name}.dot {self.destinationdir}/{name}.s.dot >/dev/null 2>&1 ; \} || \{ cp {self.destinationdir}/{name}.dot {self.destinationdir}/{name}.s.dot && dot -Tpng -o{self.destinationdir}/{name}.png -Tcmapx -o{self.destinationdir}/{name}.map {self.destinationdir}/{name}.s.dot ; \}")
+               open("article").add_class("graph")
+               add("img").attr("src", "{name}.png").attr("usemap", "#{name}").attr("style", "margin:auto").attr("alt", "{alt}")
+               close("article")
+               var fmap = new IFStream.open("{self.destinationdir}/{name}.map")
+               add_html(fmap.read_all)
+               fmap.close
+       end
+
+       # Add a (source) link for a given location
+       fun show_source(l: Location): String
+       do
+               if source == null then
+                       return "({l.file.filename.simplify_path})"
+               else
+                       # THIS IS JUST UGLY ! (but there is no replace yet)
+                       var x = source.split_with("%f")
+                       source = x.join(l.file.filename.simplify_path)
+                       x = source.split_with("%l")
+                       source = x.join(l.line_start.to_s)
+                       x = source.split_with("%L")
+                       source = x.join(l.line_end.to_s)
+                       return " (<a href=\"{source.to_s}\">show code</a>)"
+               end
+       end
+
+end
+
+# The overview page
+class NitdocOverview
+       super NitdocPage
+
+       var mbuilder: ModelBuilder
+
+       # Init with Array[AModule] to get all ifnormations about each MModule containt in a program
+       # opt_nodot to inform about the graph gen
+       # destination: to know where will be saved dot files
+       init with(mbuilder: ModelBuilder, opt_nodot: Bool, destination: String) do
+               self.mbuilder = mbuilder
+               self.opt_nodot = opt_nodot
+               self.destinationdir = destination
+       end
+
+       redef fun head do
                super
+               add("title").text("Overview | Nit Standard Library")
+       end
+
+       redef fun menu do
+               add("li").add_class("current").text("Overview")
+               open("li")
+               add_html("<a href=\"full-index.html\">Full Index</a>")
+               close("li")
+       end
+
+       redef fun content do
                open("div").add_class("page")
                open("div").add_class("content fullpage")
                add("h1").text("Nit Standard Library")
@@ -258,38 +322,53 @@ class NitdocOverview
                close("article")
                close("div")
                close("div")
-               add("footer").text("Nit standard library. Version jenkins-component=stdlib-19.")
        end
 
        fun add_modules do
-               var ls = new List[nullable MModule]
-               for amodule in amodules do
-                       var mmodule = amodule.mmodule.public_owner
-                       if mmodule != null and not ls.has(mmodule) then
-                               open("li")
-                               add("a").attr("href", "{mmodule.name}.html").text("{mmodule.to_s} ")
-                               add_html(amodule.comment)
-                               close("li")
-                               ls.add(mmodule)
-                       end
+               var mmodules = list_mmodules
+               var sorted = new Array[MModule].from(mmodules)
+               var sorter = new ComparableSorter[MModule]
+               sorter.sort(sorted)
+               for mmodule in sorted do
+                       var amodule = mbuilder.mmodule2nmodule[mmodule]
+                       open("li")
+                       add_html(mmodule.link(amodule))
+                       add_html("&nbsp;")
+                       add_html(amodule.short_comment)
+                       close("li")
                end
        end
 
        fun process_generate_dot do
                var op = new Buffer
                op.append("digraph dep \{ rankdir=BT; node[shape=none,margin=0,width=0,height=0,fontsize=10]; edge[dir=none,color=gray]; ranksep=0.2; nodesep=0.1;\n")
-               for amodule in amodules do
-                       op.append("\"{amodule.mmodule.name}\"[URL=\"{amodule.mmodule.name}.html\"];\n")
-                       for mmodule2 in amodule.mmodule.in_importation.direct_greaters do
-                               op.append("\"{amodule.mmodule.name}\"->\"{mmodule2.name}\";\n")
+               for mmodule in list_mmodules do
+                       op.append("\"{mmodule.name}\"[URL=\"{mmodule.name}.html\"];\n")
+                       for imported in mmodule.in_importation.direct_greaters do
+                               if imported.direct_owner == null then
+                                       op.append("\"{mmodule.name}\"->\"{imported.name}\";\n")
+                               end
                        end
                end
                op.append("\}\n")
                generate_dot(op.to_s, "dep", "Modules hierarchy")
        end
 
+       private fun list_mmodules: Set[MModule] do
+               var mmodules = new HashSet[MModule]
+               for mmodule in mbuilder.model.mmodules do
+                       var owner = mmodule.public_owner
+                       if owner != null then
+                               mmodules.add(owner)
+                       else
+                               mmodules.add(mmodule)
+                       end
+               end
+               return mmodules
+       end
 end
 
+# The full index page
 class NitdocFullindex
        super NitdocPage
 
@@ -306,73 +385,22 @@ class NitdocFullindex
                add("title").text("Full Index | Nit Standard Library")
        end
 
-       redef fun header do
-               open("header")
-               open("nav").add_class("main")
-               open("ul")
+       redef fun menu do
                open("li")
                add_html("<a href=\"index.html\">Overview</a>")
                close("li")
                add("li").add_class("current").text("Full Index")
-               open("li").attr("id", "liGitHub")
-               open("a").add_class("btn").attr("id", "logGitHub")
-               add("img").attr("id", "imgGitHub").attr("src", "resources/icons/github-icon.png")
-               close("a")
-               open("div").add_class("popover bottom")
-               add("div").add_class("arrow").text(" ")
-               open("div").add_class("githubTitle")
-               add("h3").text("Github Sign In")
-               close("div")
-               open("div")
-               add("label").attr("id", "lbloginGit").text("Username")
-               add("input").attr("id", "loginGit").attr("name", "login").attr("type", "text")
-               open("label").attr("id", "logginMessage").text("Hello ")
-               open("a").attr("id", "githubAccount")
-               add("strong").attr("id", "nickName").text(" ")
-               close("a")
-               close("label")
-               close("div")
-               open("div")
-               add("label").attr("id", "lbpasswordGit").text("Password")
-               add("input").attr("id", "passwordGit").attr("name", "password").attr("type", "password")
-               open("div").attr("id", "listBranches")
-               add("label").attr("id", "lbBranches").text("Branch")
-               add("select").add_class("dropdown").attr("id", "dropBranches").attr("name", "dropBranches").attr("tabindex", "1").text(" ")
-               close("div")
-               close("div")
-               open("div")
-               add("label").attr("id", "lbrepositoryGit").text("Repository")
-               add("input").attr("id", "repositoryGit").attr("name", "repository").attr("type", "text")
-               close("div")
-               open("div")
-               add("label").attr("id", "lbbranchGit").text("Branch")
-               add("input").attr("id", "branchGit").attr("name", "branch").attr("type", "text")
-               close("div")
-               open("div")
-               add("a").attr("id", "signIn").text("Sign In")
-               close("div")
-               close("div")
-               close("li")
-               close("ul")
-               close("nav")
-               close("header")
        end
 
-       redef fun body do
-               super
+       redef fun content do
                open("div").add_class("page")
                open("div").add_class("content fullpage")
                add("h1").text("Full Index")
-               add_content
-               close("div")
-               close("div")
-               add("footer").text("Nit standard library. Version jenkins-component=stdlib-19.")
-       end
-
-       fun add_content do
                module_column
                classes_column
                properties_column
+               close("div")
+               close("div")
        end
 
        # Add to content modules column
@@ -450,100 +478,53 @@ class NitdocFullindex
 
 end
 
-class NitdocModules
+# A module page
+class NitdocModule
        super NitdocPage
 
-       var amodule: AModule
-       var modulename: String
-       init with(amodule: AModule) do
-               self.amodule = amodule
-               self.modulename = self.amodule.mmodule.name
+       var mmodule: MModule
+       var mbuilder: ModelBuilder
+
+       init with(mmodule: MModule, mbuilder: ModelBuilder) do
+               self.mmodule = mmodule
+               self.mbuilder = mbuilder
                opt_nodot = false
                destinationdir = ""
        end
 
        redef fun head do
                super
-               add("title").text("{modulename} module | {amodule.short_comment}")
+               var amodule = mbuilder.mmodule2nmodule[mmodule]
+               add("title").text("{mmodule.name} module | {amodule.short_comment}")
        end
 
-       redef fun header do
-               open("header")
-               open("nav").add_class("main")
-               open("ul")
+       redef fun menu do
                open("li")
                add_html("<a href=\"index.html\">Overview</a>")
                close("li")
-               add("li").add_class("current").text(modulename)
+               add("li").add_class("current").text(mmodule.name)
                open("li")
                add_html("<a href=\"full-index.html\" >Full Index</a>")
                close("li")
-               open("li").attr("id", "liGitHub")
-               open("a").add_class("btn").attr("id", "logGitHub")
-               add("img").attr("id", "imgGitHub").attr("src", "resources/icons/github-icon.png")
-               close("a")
-               open("div").add_class("popover bottom")
-               add("div").add_class("arrow").text(" ")
-               open("div").add_class("githubTitle")
-               add("h3").text("Github Sign In")
-               close("div")
-               open("div")
-               add("label").attr("id", "lbloginGit").text("Username")
-               add("input").attr("id", "loginGit").attr("name", "login").attr("type", "text")
-               open("label").attr("id", "logginMessage").text("Hello ")
-               open("a").attr("id", "githubAccount")
-               add("strong").attr("id", "nickName").text(" ")
-               close("a")
-               close("label")
-               close("div")
-               open("div")
-               add("label").attr("id", "lbpasswordGit").text("Password")
-               add("input").attr("id", "passwordGit").attr("name", "password").attr("type", "password")
-               open("div").attr("id", "listBranches")
-               add("label").attr("id", "lbBranches").text("Branch")
-               add("select").add_class("dropdown").attr("id", "dropBranches").attr("name", "dropBranches").attr("tabindex", "1").text(" ")
-               close("div")
-               close("div")
-               open("div")
-               add("label").attr("id", "lbrepositoryGit").text("Repository")
-               add("input").attr("id", "repositoryGit").attr("name", "repository").attr("type", "text")
-               close("div")
-               open("div")
-               add("label").attr("id", "lbbranchGit").text("Branch")
-               add("input").attr("id", "branchGit").attr("name", "branch").attr("type", "text")
-               close("div")
-               open("div")
-               add("a").attr("id", "signIn").text("Sign In")
-               close("div")
-               close("div")
-               close("li")
-               close("ul")
-               close("nav")
-               close("header")
        end
 
-       redef fun body do
-               super
+       redef fun content do
                open("div").add_class("page")
-               menu
-               add_content
-               close("div")
-               add("footer").text("Nit standard library. Version jenkins-component=stdlib-19.")
-       end
-
-       # Insert all tags in content part
-       fun add_content do
+               sidebar
                open("div").add_class("content")
-               add("h1").text(modulename)
-               add("div").add_class("subtitle").text("module {modulename}")
+               add("h1").text(mmodule.name)
+               add("div").add_class("subtitle").text("module {mmodule.name}")
                module_comment
+               #process_generate_dot
                classes
                properties
                close("div")
+               close("div")
        end
 
        # Insert module comment in the content
        fun module_comment do
+               var amodule = mbuilder.mmodule2nmodule[mmodule]
                var doc = amodule.comment
                open("div").attr("id", "description")
                add("pre").add_class("text_label").text(doc)
@@ -554,33 +535,50 @@ class NitdocModules
                close("div")
        end
 
-       fun menu do
-               var mmodule = amodule.mmodule 
+       fun process_generate_dot do
+               var op = new Buffer
+               op.append("digraph dep \{ rankdir=BT; node[shape=none,margin=0,width=0,height=0,fontsize=10]; edge[dir=none,color=gray]; ranksep=0.2; nodesep=0.1;\n")
+               for m in mmodule.in_importation.smallers do
+                       op.append("\"{m.name}\"[URL=\"{m.name}.html\"];\n")
+                       for imported in m.in_importation.direct_greaters do
+                                       if imported.direct_owner == null then
+                                               op.append("\"{m.name}\"->\"{imported.name}\";\n")
+                                       end
+                                       end
+               end
+               op.append("\}\n")
+               generate_dot(op.to_s, "dep_{mmodule.name}", "Modules hierarchy")
+       end
+
+       fun sidebar do
+               var amodule = mbuilder.mmodule2nmodule[mmodule]
                open("div").add_class("menu")
                open("nav")
                add("h3").text("Module Hierarchy").attr("style","cursor: pointer;")
-               if mmodule.in_importation.direct_greaters.length > 0 then
+               if mmodule.in_importation.greaters.length > 0 then
                        add_html("<h4>All dependencies</h4><ul>")
-                       var sorted = mmodule.in_importation.direct_greaters.to_a
-                       var sorterp = new ComparableSorter[MModule]
-                       sorterp.sort(sorted)
+                       var sorted = mmodule.in_importation.greaters.to_a
+                       var sorter = new ComparableSorter[MModule]
+                       sorter.sort(sorted)
                        for m in sorted do
-                               if m == mmodule or mmodule == m.public_owner then continue
+                               if m == mmodule or m.public_owner != null then continue
+                               var am = mbuilder.mmodule2nmodule[m]
                                open("li")
-                               add("a").attr("href", "{m.name}.html").text(m.name)
+                               add_html(m.link(am))
                                close("li")
                        end
                        add_html("</ul>")
-               end     
-               if mmodule.in_importation.greaters.length > 0 then
+               end
+               if mmodule.in_importation.smallers.length > 0 then
                        add_html("<h4>All clients</h4><ul>")
-                       var sorted = mmodule.in_importation.greaters.to_a
-                       var sorterp = new ComparableSorter[MModule]
-                       sorterp.sort(sorted)
+                       var sorted = mmodule.in_importation.smallers.to_a
+                       var sorter = new ComparableSorter[MModule]
+                       sorter.sort(sorted)
                        for m in sorted do
-                               if m == mmodule then continue
+                               if m == mmodule or m.public_owner != null then continue
+                               var am = mbuilder.mmodule2nmodule[m]
                                open("li")
-                               add("a").attr("href", "{m.name}.html").text(m.name)
+                               add_html(m.link(am))
                                close("li")
                        end
                        add_html("</ul>")
@@ -588,41 +586,51 @@ class NitdocModules
                close("nav")
                if mmodule.in_nesting.direct_greaters.length > 0 then
                        var sorted = mmodule.in_nesting.direct_greaters.to_a
-                       var sorterp = new ComparableSorter[MModule]
-                       sorterp.sort(sorted)
+                       var sorter = new ComparableSorter[MModule]
+                       sorter.sort(sorted)
                        open("nav")
                        add("h3").text("Nested Modules").attr("style","cursor: pointer;")
                        open("ul")
                        for m in sorted do
+                               var am = mbuilder.mmodule2nmodule[m]
                                open("li")
-                               add("a").attr("href", "{m.name}.html").text(m.name)
+                               add_html(m.link(am))
                                close("li")
                        end
                        close("ul")
-                       
                        close("nav")
                end
                close("div")
        end
 
        fun classes do
+               var amodule = mbuilder.mmodule2nmodule[mmodule]
+               var intro_mclasses = mmodule.intro_mclasses
+               var redef_mclasses = mmodule.redef_mclasses
+               var all_mclasses = new HashSet[MClass]
+               for m in mmodule.in_nesting.greaters do
+                       all_mclasses.add_all(m.intro_mclasses)
+                       all_mclasses.add_all(m.redef_mclasses)
+               end
+               all_mclasses.add_all(intro_mclasses)
+               all_mclasses.add_all(redef_mclasses)
+
                var sorted = new Array[MClass]
-               sorted.add_all(amodule.mmodule.mclasses.keys)
-               var sorterp = new ComparableSorter[MClass]
-               sorterp.sort(sorted)
+               sorted.add_all(all_mclasses)
+               var sorter = new ComparableSorter[MClass]
+               sorter.sort(sorted)
                open("div").add_class("module")
                open("article").add_class("classes filterable")
                add("h2").text("Classes")
                open("ul")
                for c in sorted do
-                       var state = amodule.mmodule.mclasses[c]
                        var name = c.name
-                       if state == c_is_intro or state == c_is_imported then
-                               open("li").add_class("intro")
-                               add("span").attr("title", "introduced in this module").text("I ")
-                       else
+                       if redef_mclasses.has(c) and c.intro_mmodule.public_owner != mmodule then
                                open("li").add_class("redef")
                                add("span").attr("title", "refined in this module").text("R ")
+                       else
+                               open("li").add_class("intro")
+                               add("span").attr("title", "introduced in this module").text("I ")
                        end
                        add("a").attr("href", "{name}.html").text(name)
                        close("li")
@@ -633,178 +641,136 @@ class NitdocModules
        end
 
        fun properties do
-               var sorted_imported = amodule.mmodule.imported_methods.to_a
-               var sorted_redef = amodule.mmodule.redef_methods.to_a
-               var sorterp = new ComparableSorter[MProperty]
-               sorterp.sort(sorted_imported)
-               sorterp.sort(sorted_redef)
+               var amodule = mbuilder.mmodule2nmodule[mmodule]
+               var mpropdefs = new HashSet[MPropDef]
+               for m in mmodule.in_nesting.greaters do
+                       for c in m.mclassdefs do mpropdefs.add_all(c.mpropdefs)
+               end
+               for c in mmodule.mclassdefs do mpropdefs.add_all(c.mpropdefs)
+               var sorted = mpropdefs.to_a
+               var sorter = new ComparableSorter[MPropDef]
+               sorter.sort(sorted)
                open("article").add_class("properties filterable")
                add_html("<h2>Properties</h2>")
                open("ul")
-               for method in sorted_imported do
-                       if method.visibility is none_visibility or method.visibility is intrude_visibility then continue
-                       open("li").add_class("intro")
-                       add("span").attr("title", "introduction").text("I")
-                       add_html("&nbsp;")
-                       add("a").attr("href", "{method.local_class.name}.html").attr("title", "").text("{method.name} ({method.local_class.name})")
-                       close("li")
-               end
-
-               for method in sorted_redef do
-                       if method.visibility is none_visibility or method.visibility is intrude_visibility then continue
-                       open("li").add_class("redef")
-                       add("span").attr("title", "redefinition").text("R")
+               for p in sorted do
+                       if p.mproperty.visibility <= none_visibility then continue
+                       if p.is_intro then
+                               open("li").add_class("intro")
+                               add("span").attr("title", "introduction").text("I")
+                       else
+                               open("li").add_class("redef")
+                               add("span").attr("title", "redefinition").text("R")
+                       end
                        add_html("&nbsp;")
-                       add("a").attr("href", "{method.local_class.name}.html").attr("title", "").text("{method.name} ({method.local_class.name})")
+                       add("a").attr("href", "{p.mclassdef.mclass.name}.html").attr("title", "").text("{p.mproperty.name} ({p.mclassdef.mclass.name})")
                        close("li")
                end
-
                close("ul")
                close("article")
        end
-
 end
 
-# Nit Standard Library
-class NitdocMClasses
+# A class page
+class NitdocClass
        super NitdocPage
 
        var mclass: MClass
-       var aclassdef: AClassdef
-       var stdclassdef: nullable AStdClassdef
-       var public_owner: nullable MModule
+       var mbuilder: ModelBuilder
 
-       init with(mclass: MClass, aclassdef: AClassdef, source: nullable String) do
+       init with(mclass: MClass, mbuilder: ModelBuilder, source: nullable String) do
                self.mclass = mclass
-               self.aclassdef = aclassdef
-               if aclassdef isa AStdClassdef then self.stdclassdef = aclassdef
-               self.public_owner = mclass.intro_mmodule.public_owner
-               opt_nodot = false
-               destinationdir = ""
+               self.mbuilder = mbuilder
+               self.opt_nodot = false
+               self.destinationdir = ""
                self.source = source
        end
 
        redef fun head do
                super
-               add("title").text("{self.mclass.name} class | Nit Standard Library")
+               var nclass = mbuilder.mclassdef2nclassdef[mclass.intro]
+               if nclass isa AStdClassdef then
+                       add("title").text("{mclass.name} class | {nclass.short_comment}")
+               else
+                       add("title").text("{mclass.name} class")
+               end
        end
 
-       redef fun header do
-               open("header")
-               open("nav").add_class("main")
-               open("ul")
+       redef fun menu do
                open("li")
                add_html("<a href=\"index.html\">Overview</a>")
                close("li")
                open("li")
+               var public_owner = mclass.public_owner
                if public_owner is null then
-                       add_html("<a href=\"{mclass.intro_mmodule.name}.html\">{mclass.intro_mmodule.name}</a>")
+                       var am = mbuilder.mmodule2nmodule[mclass.intro_mmodule]
+                       add_html(mclass.intro_mmodule.link(am))
                else
-                       add_html("<a href=\"{public_owner.name}.html\">{public_owner.name}</a>")
+                       var am = mbuilder.mmodule2nmodule[public_owner]
+                       add_html(public_owner.link(am))
                end
                close("li")
                add("li").add_class("current").text(mclass.name)
                open("li")
                add_html("<a href=\"full-index.html\" >Full Index</a>")
                close("li")
-               open("li").attr("id", "liGitHub")
-               open("a").add_class("btn").attr("id", "logGitHub")
-               add("img").attr("id", "imgGitHub").attr("src", "resources/icons/github-icon.png")
-               close("a")
-               open("div").add_class("popover bottom")
-               add("div").add_class("arrow").text(" ")
-               open("div").add_class("githubTitle")
-               add("h3").text("Github Sign In")
-               close("div")
-               open("div")
-               add("label").attr("id", "lbloginGit").text("Username")
-               add("input").attr("id", "loginGit").attr("name", "login").attr("type", "text")
-               open("label").attr("id", "logginMessage").text("Hello ")
-               open("a").attr("id", "githubAccount")
-               add("strong").attr("id", "nickName").text(" ")
-               close("a")
-               close("label")
-               close("div")
-               open("div")
-               add("label").attr("id", "lbpasswordGit").text("Password")
-               add("input").attr("id", "passwordGit").attr("name", "password").attr("type", "password")
-               open("div").attr("id", "listBranches")
-               add("label").attr("id", "lbBranches").text("Branch")
-               add("select").add_class("dropdown").attr("id", "dropBranches").attr("name", "dropBranches").attr("tabindex", "1").text(" ")
-               close("div")
-               close("div")
-               open("div")
-               add("label").attr("id", "lbrepositoryGit").text("Repository")
-               add("input").attr("id", "repositoryGit").attr("name", "repository").attr("type", "text")
-               close("div")
-               open("div")
-               add("label").attr("id", "lbbranchGit").text("Branch")
-               add("input").attr("id", "branchGit").attr("name", "branch").attr("type", "text")
-               close("div")
-               open("div")
-               add("a").attr("id", "signIn").text("Sign In")
-               close("div")
-               close("div")
-               close("li")
-               close("ul")
-               close("nav")
-               close("header")
        end
 
-       redef fun body do
-               super
+       redef fun content do
                open("div").add_class("page")
-               add_content
-               close("div")
-               add("footer").text("Nit standard library. Version jenkins-component=stdlib-19.")
-       end
-
-       # Insert all tags in content part
-       fun add_content do
                open("div").add_class("menu")
                properties_column
                inheritance_column
                close("div")
                open("div").add_class("content")
-               content
+               class_doc
+               close("div")
                close("div")
        end
 
        fun properties_column do
+               var sorted = new Array[MProperty]
+               var sorter = new ComparableSorter[MProperty]
                open("nav").add_class("properties filterable")
                add("h3").text("Properties")
 
                if mclass.virtual_types.length > 0 then
                        add("h4").text("Virtual Types")
                        open("ul")
-                       for prop in mclass.virtual_types do
+                       sorted = mclass.virtual_types.to_a
+                       sorter.sort(sorted)
+                       for prop in sorted do
                                add_html("<li class=\"redef\"><span title=\"Redefined\">R</span><a href=\"{prop.link_anchor}\">{prop.name}</a></li>")
                        end
                        close("ul")
                end
                if mclass.constructors.length > 0 then
+                       sorted = mclass.constructors.to_a
+                       sorter.sort(sorted)
                        add("h4").text("Constructors")
                        open("ul")
-                       for prop in mclass.constructors do
+                       for prop in sorted do
                                add_html("<li class=\"intro\"><span title=\"Introduced\">I</span><a href=\"{prop.link_anchor}\">{prop.name}</a></li>")
                        end
                        close("ul")
                end
                add("h4").text("Methods")
                open("ul")
-               if mclass.intro_methods.length > 0 then
-                       for prop in mclass.intro_methods do
-                               if prop.visibility is public_visibility or prop.visibility is protected_visibility then add_html("<li class=\"intro\"><span title=\"Introduced\">I</span><a href=\"{prop.link_anchor}\">{prop.name}</a></li>")
-                       end
-               end
-               if mclass.inherited_methods.length > 0 then
-                       for prop in mclass.inherited_methods do
-                               if prop.visibility is public_visibility or prop.visibility is protected_visibility then add_html("<li class=\"inherit\"><span title=\"Inherited\">H</span><a href=\"{prop.link_anchor}\">{prop.name}</a></li>")
-                       end
-               end
-               if mclass.redef_methods.length > 0 then
-                       for prop in mclass.redef_methods do
-                               if prop.visibility is public_visibility or prop.visibility is protected_visibility then add_html("<li class=\"redef\"><span title=\"Refined\">R</span><a href=\"{prop.link_anchor}\">{prop.name}</a></li>")
+               var mmethods = new HashSet[MMethod]
+               var redef_methods = mclass.redef_methods
+               mmethods.add_all(mclass.intro_methods)
+               mmethods.add_all(mclass.inherited_methods)
+               mmethods.add_all(redef_methods)
+               sorted = mmethods.to_a
+               sorter.sort(sorted)
+               for prop in sorted do
+                       if prop.visibility <= none_visibility then continue
+                       if prop.intro_mclassdef.mclass == mclass then
+                               add_html("<li class=\"intro\"><span title=\"Introduced\">I</span><a href=\"{prop.link_anchor}\">{prop.name}</a></li>")
+                       else if redef_methods.has(prop) then
+                               add_html("<li class=\"redef\"><span title=\"Refined\">R</span><a href=\"{prop.link_anchor}\">{prop.name}</a></li>")
+                       else
+                               add_html("<li class=\"inherit\"><span title=\"Inherited\">H</span><a href=\"{prop.link_anchor}\">{prop.name}</a></li>")
                        end
                end
                close("ul")
@@ -812,26 +778,43 @@ class NitdocMClasses
        end
 
        fun inheritance_column do
+               var sorted = new Array[MClass]
+               var sorterp = new ComparableSorter[MClass]
                open("nav")
                add("h3").text("Inheritance")
-               if mclass.parents.length > 0 then
+               if mclass.ancestors.length > 1 then
+                       sorted = mclass.ancestors.to_a
+                       sorterp.sort(sorted)
                        add("h4").text("Superclasses")
                        open("ul")
-                       for sup in mclass.parents do add_html("<li><a href=\"{sup.name}.html\">{sup.name}</a></li>")
+                       for sup in sorted do
+                               if sup == mclass then continue
+                               add_html("<li><a href=\"{sup.name}.html\">{sup.name}</a></li>")
+                       end
                        close("ul")
                end
 
-               if mclass.descendants.length is 0 then
+               if mclass.descendants.length <= 1 then
                        add("h4").text("No Known Subclasses")
                else if mclass.descendants.length <= 100 then
+                       sorted = mclass.descendants.to_a
+                       sorterp.sort(sorted)
                        add("h4").text("Subclasses")
                        open("ul")
-                       for sub in mclass.descendants do add_html("<li><a href=\"{sub.name}\">{sub.name}</a></li>")
+                       for sub in sorted do
+                               if sub == mclass then continue
+                               add_html("<li><a href=\"{sub.name}\">{sub.name}</a></li>")
+                       end
                        close("ul")
                else if mclass.children.length <= 100 then
+                       sorted = mclass.children.to_a
+                       sorterp.sort(sorted)
                        add("h4").text("Direct Subclasses Only")
                        open("ul")
-                       for sub in mclass.children do add_html("<li><a href=\"{sub.name}\">{sub.name}</a></li>")
+                       for sub in sorted do
+                               if sub == mclass then continue
+                               add_html("<li><a href=\"{sub.name}\">{sub.name}</a></li>")
+                       end
                        close("ul")
                else
                        add("h4").text("Too much Subclasses to list")
@@ -839,30 +822,46 @@ class NitdocMClasses
                close("nav")
        end
 
-       fun content do
+       fun class_doc do
+               var nclass = mbuilder.mclassdef2nclassdef[mclass.intro]
+               var sorted = new Array[MModule]
+               sorted.add_all(mclass.concerns.keys)
+               var sorterp = new ComparableSorter[MModule]
+               var sorterprop = new ComparableSorter[MProperty]
+               var sorterc = new ComparableSorter[MClass]
+               sorterp.sort(sorted)
                var subtitle = ""
                var lmmodule = new List[MModule]
                # Insert the subtitle part
                add("h1").text(mclass.name)
                open("div").add_class("subtitle")
                if mclass.visibility is none_visibility then subtitle += "private "
-               subtitle += "{mclass.kind} <a href=\"{mclass.public_owner.name}.html\">{mclass.public_owner.name}</a>::{mclass.name}"
+               var nowner = mbuilder.mmodule2nmodule[mclass.public_owner]
+               subtitle += "{mclass.kind} {mclass.public_owner.link(nowner)}::{mclass.name}"
                add_html(subtitle)
                close("div")
                add_html("<div style=\"float: right;\"><a id=\"lblDiffCommit\"></a></div>")
                # We add the class description
                open("section").add_class("description")
-               if not stdclassdef is null and not stdclassdef.comment.is_empty then add_html("<pre class=\"text_label\" title=\"122\" name=\"\" tag=\"{mclass.mclassdefs.first.location.to_s}\" type=\"2\">{stdclassdef.comment} </pre><textarea id=\"fileContent\" class=\"edit\" cols=\"76\" rows=\"1\" style=\"display: none;\"></textarea><a id=\"cancelBtn\" style=\"display: none;\">Cancel</a><a id=\"commitBtn\" style=\"display: none;\">Commit</a><pre id=\"preSave\" class=\"text_label\" type=\"2\"></pre>")
+               if nclass isa AStdClassdef and not nclass.comment.is_empty then add_html("<pre class=\"text_label\" title=\"122\" name=\"\" tag=\"{mclass.mclassdefs.first.location.to_s}\" type=\"2\">{nclass.comment} </pre><textarea id=\"fileContent\" class=\"edit\" cols=\"76\" rows=\"1\" style=\"display: none;\"></textarea><a id=\"cancelBtn\" style=\"display: none;\">Cancel</a><a id=\"commitBtn\" style=\"display: none;\">Commit</a><pre id=\"preSave\" class=\"text_label\" type=\"2\"></pre>")
                close("section")
                open("section").add_class("concerns")
                add("h2").add_class("section-header").text("Concerns")
                open("ul")
-               for owner, childs in mclass.concerns do
+               for owner in sorted do
+                       var nmodule = mbuilder.mmodule2nmodule[owner]
+                       var childs = mclass.concerns[owner]
                        open("li")
-                       add_html("<a href=\"#MOD_{owner.name}\">{owner.name}</a>: {owner.amodule.short_comment}")
+                       add_html("<a href=\"#MOD_{owner.name}\">{owner.name}</a>: {nmodule.short_comment}")
                        if not childs is null then
                                open("ul")
-                               for child in childs.as(not null) do add_html("<li><a href=\"#MOD_{child.name}\">{child.name}</a>: {child.amodule.short_comment} </li>")
+                               var sortedc = childs.to_a
+                               var sorterpc = new ComparableSorter[MModule]
+                               sorterpc.sort(sortedc)
+                               for child in sortedc do
+                                       var nchild = mbuilder.mmodule2nmodule[child]
+                                       add_html("<li><a href=\"#MOD_{child.name}\">{child.name}</a>: {nchild.short_comment} </li>")
+                               end
                                close("ul")
                        end
                        close("li")
@@ -870,12 +869,12 @@ class NitdocMClasses
                close("ul")
                close("section")
                # Insert virtual types if there is almost one
-               if mclass.virtual_types.length > 0 or (stdclassdef != null and stdclassdef.n_formaldefs.length > 0) then
+               if mclass.virtual_types.length > 0 or mclass.arity > 0 then
                        open("section").add_class("types")
                        add("h2").text("Formal and Virtual Types")
                        if mclass.virtual_types.length > 0 then for prop in mclass.virtual_types do description(prop)
-                       if stdclassdef.n_formaldefs.length > 0 then
-                               for prop in stdclassdef.n_formaldefs do
+                       if mclass.arity > 0 and nclass isa AStdClassdef then
+                               for prop in nclass.n_formaldefs do
                                        open("article").attr("id", "FT_Object_{prop.collect_text}")
                                        open("h3").add_class("signature").text("{prop.collect_text}: nullable ")
                                        add_html("<a title=\"The root of the class hierarchy.\" href=\"Object.html\">Object</a>")
@@ -888,33 +887,43 @@ class NitdocMClasses
                end
                # Insert constructors if there is almost one
                if mclass.constructors.length > 0 then
+                       var sortedc = mclass.constructors.to_a
+                       sorterprop.sort(sortedc)
                        open("section").add_class("constructors")
                        add("h2").add_class("section-header").text("Constructors")
-                       for prop in mclass.constructors do description(prop)
+                       for prop in sortedc do description(prop)
                        close("section")
                end
                open("section").add_class("methods")
                add("h2").add_class("section-header").text("Methods")
                for mmodule, mmethods in mclass.all_methods do
+                       var nmodule = mbuilder.mmodule2nmodule[mmodule]
                        add_html("<a id=\"MOD_{mmodule.name}\"></a>")
                        if mmodule != mclass.intro_mmodule and mmodule != mclass.public_owner then
                                if mclass.has_mmodule(mmodule) then
-                                       add_html("<p class=\"concern-doc\">{mmodule.name}: {mmodule.amodule.short_comment}</p>")
+                                       add_html("<p class=\"concern-doc\">{mmodule.name}: {nmodule.short_comment}</p>")
                                else
-                                       add_html("<h3 class=\"concern-toplevel\">Methods refined in <a href=\"{mmodule.name}.html\">{mmodule.name}</a></h3><p class=\"concern-doc\">{mmodule.name}: {mmodule.amodule.short_comment}</p>")
+                                       add_html("<h3 class=\"concern-toplevel\">Methods refined in {mmodule.link(nmodule)}</h3><p class=\"concern-doc\">{mmodule.name}: {nmodule.short_comment}</p>")
                                end
                        end
-                       for prop in mmethods do description(prop)
+                       var sortedc = mmethods.to_a
+                       sorterprop.sort(sortedc)
+                       for prop in sortedc do description(prop)
                end
                # Insert inherited methods
                if mclass.inherited_methods.length > 0 then
+                       var sortedc = new Array[MClass]
+                       sortedc.add_all(mclass.inherited.keys)
+                       sorterc.sort(sortedc)
                        add("h3").text("Inherited Methods")
-                       for i_mclass, methods in mclass.inherited do
+                       for i_mclass in sortedc do
+                               var sortedp = mclass.inherited[i_mclass].to_a
+                               sorterprop.sort(sortedp)
                                open("p")
                                add_html("Defined in <a href=\"{i_mclass.name}.html\">{i_mclass.name}</a>: ")
-                               for method in methods do
+                               for method in sortedp do
                                        add_html("<a href=\"{method.link_anchor}\">{method.name}</a>")
-                                       if method != methods.last then add_html(", ")
+                                       if method != sortedp.last then add_html(", ")
                                end
                                close("p")
                        end
@@ -938,12 +947,20 @@ class NitdocMClasses
                end
                add_html("<textarea id=\"fileContent\" class=\"edit\" cols=\"76\" rows=\"1\" style=\"display: none;\"></textarea><a id=\"cancelBtn\" style=\"display: none;\">Cancel</a><a id=\"commitBtn\" style=\"display: none;\">Commit</a><pre id=\"preSave\" class=\"text_label\" type=\"2\"></pre>")
                open("p")
-               if prop.local_class != mclass then add_html("inherited from {prop.local_class.intro_mmodule.name} ")
+               if prop.local_class != mclass then
+                       var mredef = prop.local_class.intro_mmodule
+                       var nredef = mbuilder.mmodule2nmodule[mredef]
+                       add_html("inherited from {mredef.link(nredef)} ")
+               end
                #TODO display show code if doc github
-               add_html("defined by the module <a href=\"{prop.intro_mclassdef.mmodule.name}.html\">{prop.intro_mclassdef.mmodule.name}</a> {if prop.apropdef is null then "" else show_source(prop.apropdef.location)}.")
+               var mintro = prop.intro_mclassdef.mmodule
+               var nintro = mbuilder.mmodule2nmodule[mintro]
+               add_html("defined by the module {mintro.link(nintro)}{if prop.apropdef is null then "" else show_source(prop.apropdef.location)}.")
 
                for parent in mclass.parents do
-                       if prop isa MMethod then if parent.constructors.has(prop) then add_html(" Previously defined by: <a href=\"{parent.intro_mmodule.name}.html\">{parent.intro_mmodule.name}</a> for <a href=\"{parent.name}.html\">{parent.name}</a>.")
+                       var mparent = parent.intro_mmodule
+                       var nparent = mbuilder.mmodule2nmodule[mparent]
+                       if prop isa MMethod then if parent.constructors.has(prop) then add_html(" Previously defined by: {mparent.link(nparent)} for <a href=\"{parent.name}.html\">{parent.name}</a>.")
                end
                close("p")
                close("div")
@@ -951,58 +968,6 @@ class NitdocMClasses
                close("article")
        end
 
-end    
-
-class NitdocPage
-       super HTMLPage
-       
-       var opt_nodot: Bool
-       var destinationdir : String
-       var source: nullable String
-
-       redef fun head do
-               add("meta").attr("charset", "utf-8")
-               add("script").attr("type", "text/javascript").attr("src", "scripts/jquery-1.7.1.min.js")
-               add("script").attr("type", "text/javascript").attr("src", "quicksearch-list.js")
-               add("script").attr("type", "text/javascript").attr("src", "scripts/js-facilities.js")
-               add("link").attr("rel", "stylesheet").attr("href", "styles/main.css").attr("type", "text/css").attr("media", "screen")
-       end
-
-       redef fun body do header
-       fun header do end
-
-       # Generate a clickable graphviz image using a dot content
-       fun generate_dot(dot: String, name: String, alt: String) do
-               if opt_nodot then return
-               var file = new OFStream.open("{self.destinationdir}/{name}.dot")
-               file.write(dot)
-               file.close
-               sys.system("\{ test -f {self.destinationdir}/{name}.png && test -f {self.destinationdir}/{name}.s.dot && diff {self.destinationdir}/{name}.dot {self.destinationdir}/{name}.s.dot >/dev/null 2>&1 ; \} || \{ cp {self.destinationdir}/{name}.dot {self.destinationdir}/{name}.s.dot && dot -Tpng -o{self.destinationdir}/{name}.png -Tcmapx -o{self.destinationdir}/{name}.map {self.destinationdir}/{name}.s.dot ; \}")
-               open("article").add_class("graph")
-               add("img").attr("src", "{name}.png").attr("usemap", "#{name}").attr("style", "margin:auto").attr("alt", "{alt}")
-               close("article")
-               var fmap = new IFStream.open("{self.destinationdir}/{name}.map")
-               add_html(fmap.read_all)
-               fmap.close
-       end
-
-       # Add a (source) link fo a given location
-       fun show_source(l: Location): String
-       do
-               if source == null then
-                       return "({l.file.filename.simplify_path})"
-               else
-                       # THIS IS JUST UGLY ! (but there is no replace yet)
-                       var x = source.split_with("%f")
-                       source = x.join(l.file.filename.simplify_path)
-                       x = source.split_with("%l")
-                       source = x.join(l.line_start.to_s)
-                       x = source.split_with("%L")
-                       source = x.join(l.line_end.to_s)
-                       return " (<a href=\"{source.to_s}\">show code</a>)"
-               end
-       end
-
 end
 
 redef class AModule
@@ -1011,7 +976,10 @@ redef class AModule
                if n_moduledecl is null or n_moduledecl.n_doc is null then ret
                if n_moduledecl.n_doc is null then return ""
                for t in n_moduledecl.n_doc.n_comment do
-                       ret += "{t.text.replace("# ", "")}"
+                       var txt = t.text
+                       txt = txt.replace("# ", "")
+                       txt = txt.replace("#", "")
+                       ret += txt
                end
                return ret
        end
@@ -1029,13 +997,10 @@ redef class AModule
 end
 
 redef class MModule
-
        super Comparable
        redef type OTHER: MModule
        redef fun <(other: OTHER): Bool do return self.name < other.name
 
-       var amodule: nullable AModule
-
        # Get the list of all methods in a module
        fun imported_methods: Set[MMethod] do
                var methods = new HashSet[MMethod]
@@ -1057,10 +1022,19 @@ redef class MModule
                end
                return methods
        end
+
+       # Return a link (html a tag) to the nitdoc module page
+       fun link(amodule: AModule): String do
+               return "<a href=\"{name}.html\" title=\"{amodule.short_comment}\">{name}</a>"
+       end
+end
+redef class MPropDef
+       super Comparable
+       redef type OTHER: MPropDef
+       redef fun <(other: OTHER): Bool do return self.mproperty.name < other.mproperty.name
 end
 
 redef class MProperty
-
        super Comparable
        redef type OTHER: MProperty
        redef fun <(other: OTHER): Bool do return self.name < other.name
@@ -1094,7 +1068,6 @@ redef class MProperty
 end
 
 redef class MClass
-
        super Comparable
        redef type OTHER: MClass
        redef fun <(other: OTHER): Bool do return self.name < other.name
@@ -1146,14 +1119,6 @@ redef class MClass
                        return owner.public_owner.as(not null)
                end
        end
-       
-       # Associate Amodule to all MModule concern by 'self'
-       fun amodule(amodules: HashMap[MModule, AModule]) do
-               for owner, childs in concerns do
-                       if childs != null then for child in childs do child.amodule = amodules[child]
-                       owner.amodule = amodules[owner]
-               end
-       end
 
        # Associate MClass to all MMethod include in 'inherited_methods'
        fun inherited: HashMap[MClass, Set[MMethod]] do