ni_nitdoc: added graph generation in module and classe page
[nit.git] / src / ni_nitdoc.nit
index b36b8ec..c7c3ed3 100644 (file)
@@ -25,9 +25,11 @@ class Nitdoc
        private var model: Model
        private var modelbuilder: ModelBuilder
        private var mainmodule: MModule
+       private var class_hierarchy: POSet[MClass]
        private var arguments: Array[String]
-       private var destinationdir: nullable String
-       private var sharedir: nullable String
+       private var output_dir: nullable String
+       private var dot_dir: nullable String
+       private var share_dir: nullable String
        private var source: nullable String
 
        private var opt_dir = new OptionString("Directory where doc is generated", "-d", "--dir")
@@ -61,16 +63,17 @@ class Nitdoc
                modelbuilder.full_propdef_semantic_analysis
                assert mmodules.length == 1
                self.mainmodule = mmodules.first
+               self.class_hierarchy = mainmodule.flatten_mclass_hierarchy
        end
 
        private fun process_options do
                if not opt_dir.value is null then
-                       destinationdir = opt_dir.value
+                       output_dir = opt_dir.value
                else
-                       destinationdir = "nitdoc_directory"
+                       output_dir = "doc"
                end
                if not opt_sharedir.value is null then
-                       sharedir = opt_sharedir.value
+                       share_dir = opt_sharedir.value
                else
                        var dir = "NIT_DIR".environ
                        if dir.is_empty then
@@ -78,13 +81,13 @@ class Nitdoc
                        else
                                dir = "{dir}/share/nitdoc"
                        end
-                       sharedir = dir
-                       if sharedir is null then
+                       share_dir = dir
+                       if share_dir is null then
                                print "Error: Cannot locate nitdoc share files. Uses --sharedir or envvar NIT_DIR"
                                abort
                        end
-                       dir = "{sharedir.to_s}/scripts/js-facilities.js"
-                       if sharedir is null then
+                       dir = "{share_dir.to_s}/scripts/js-facilities.js"
+                       if share_dir is null then
                                print "Error: Invalid nitdoc share files. Check --sharedir or envvar NIT_DIR"
                                abort
                        end
@@ -99,50 +102,52 @@ class Nitdoc
        fun start do
                if arguments.length == 1 then
                        # Create destination dir if it's necessary
-                       if not destinationdir.file_exists then destinationdir.mkdir
-                       sys.system("cp -r {sharedir.to_s}/* {destinationdir.to_s}/")
+                       if not output_dir.file_exists then output_dir.mkdir
+                       sys.system("cp -r {share_dir.to_s}/* {output_dir.to_s}/")
+                       self.dot_dir = null
+                       if not opt_nodot.value then self.dot_dir = output_dir.to_s
                        overview
-                       fullindex
+                       #fullindex
                        modules
                        classes
-                       quicksearch_list
+                       #quicksearch_list
                end
        end
 
        fun overview do
-               var overviewpage = new NitdocOverview.with(modelbuilder, self.opt_nodot.value, destinationdir.to_s)
-               overviewpage.save("{destinationdir.to_s}/index.html")
+               var overviewpage = new NitdocOverview(modelbuilder, dot_dir)
+               overviewpage.save("{output_dir.to_s}/index.html")
        end
 
        fun fullindex do
-               var fullindex = new NitdocFullindex.with(model.mmodules)
-               fullindex.save("{destinationdir.to_s}/full-index.html")
+               var fullindex = new NitdocFullindex(model.mmodules)
+               fullindex.save("{output_dir.to_s}/full-index.html")
        end
 
        fun modules do
                for mmodule in model.mmodules do
-                       var modulepage = new NitdocModule.with(mmodule, modelbuilder)
-                       modulepage.save("{destinationdir.to_s}/{mmodule.name}.html")
+                       var modulepage = new NitdocModule(mmodule, modelbuilder, dot_dir)
+                       modulepage.save("{output_dir.to_s}/{mmodule.name}.html")
                end
        end
 
        fun classes do
                for mclass in modelbuilder.model.mclasses do
-                       var classpage = new NitdocClass.with(mclass, modelbuilder, source)
-                       classpage.save("{destinationdir.to_s}/{mclass.name}.html")
+                       var classpage = new NitdocClass(mclass, self, dot_dir, source)
+                       classpage.save("{output_dir.to_s}/{mclass.name}.html")
                end
        end
 
        # Generate QuickSearch file
        fun quicksearch_list do
-               var file = new OFStream.open("{destinationdir.to_s}/quicksearch-list.js")
+               var file = new OFStream.open("{output_dir.to_s}/quicksearch-list.js")
                var content = new Buffer
                content.append("var entries = \{ ")
                for prop in model.mproperties do
                        if not prop isa MMethod then continue
                        content.append("\"{prop.name}\": [")
                        for propdef in prop.mpropdefs do
-                               content.append("\{txt: \"{propdef.mproperty.full_name}\", url:\"{propdef.mproperty.link_anchor}\" \}")
+                               content.append("\{txt: \"{propdef.mproperty.full_name}\", url:\"{propdef.mproperty.anchor}\" \}")
                                if not propdef is prop.mpropdefs.last then content.append(", ")
                        end
                        content.append("]")
@@ -170,8 +175,7 @@ end
 abstract class NitdocPage
        super HTMLPage
 
-       var opt_nodot: Bool
-       var destinationdir : String
+       var dot_dir: nullable String
        var source: nullable String
 
        redef fun head do
@@ -184,7 +188,9 @@ abstract class NitdocPage
 
        redef fun body do
                header
+               open("div").add_class("page")
                content
+               close("div")
                footer
        end
 
@@ -247,15 +253,16 @@ abstract class NitdocPage
 
        # 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")
+               var output_dir = dot_dir
+               if output_dir == null then return
+               var file = new OFStream.open("{output_dir}/{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 ; \}")
+               sys.system("\{ test -f {output_dir}/{name}.png && test -f {output_dir}/{name}.s.dot && diff {output_dir}/{name}.dot {output_dir}/{name}.s.dot >/dev/null 2>&1 ; \} || \{ cp {output_dir}/{name}.dot {output_dir}/{name}.s.dot && dot -Tpng -o{output_dir}/{name}.png -Tcmapx -o{output_dir}/{name}.map {output_dir}/{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")
+               var fmap = new IFStream.open("{output_dir}/{name}.map")
                add_html(fmap.read_all)
                fmap.close
        end
@@ -276,22 +283,31 @@ abstract class NitdocPage
                        return " (<a href=\"{source.to_s}\">show code</a>)"
                end
        end
-
 end
 
 # The overview page
 class NitdocOverview
        super NitdocPage
+       private var mbuilder: ModelBuilder
+       private var mmodules = new Array[MModule]
 
-       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
+       init(mbuilder: ModelBuilder, dot_dir: nullable String) do
                self.mbuilder = mbuilder
-               self.opt_nodot = opt_nodot
-               self.destinationdir = destination
+               self.dot_dir = dot_dir
+               # get modules
+               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
+               # sort modules
+               var sorter = new ComparableSorter[MModule]
+               self.mmodules.add_all(mmodules)
+               sorter.sort(self.mmodules)
        end
 
        redef fun head do
@@ -302,47 +318,37 @@ class NitdocOverview
        redef fun menu do
                add("li").add_class("current").text("Overview")
                open("li")
-               add_html("<a href=\"full-index.html\">Full Index</a>")
+               add("a").attr("href", "full-index.html").text("Full Index")
                close("li")
        end
 
        redef fun content do
-               open("div").add_class("page")
                open("div").add_class("content fullpage")
                add("h1").text("Nit Standard Library")
                open("article").add_class("overview")
                add_html("<p>Documentation for the standard library of Nit<br />Version jenkins-component=stdlib-19<br />Date: TODAY</p>")
                close("article")
                open("article").add_class("overview")
+               # module list
                add("h2").text("Modules")
                open("ul")
-               add_modules
-               close("ul")
-               process_generate_dot
-               close("article")
-               close("div")
-               close("div")
-       end
-
-       fun add_modules do
-               var mmodules = list_mmodules
-               var sorted = new Array[MModule].from(mmodules)
-               var sorter = new ComparableSorter[MModule]
-               sorter.sort(sorted)
-               for mmodule in sorted do
+               for mmodule in mmodules do
                        var amodule = mbuilder.mmodule2nmodule[mmodule]
                        open("li")
-                       add_html(mmodule.link(amodule))
-                       add_html("&nbsp;")
-                       add_html(amodule.short_comment)
+                       add_html("{mmodule.link(amodule)}&nbsp;{amodule.short_comment}")
                        close("li")
                end
+               close("ul")
+               # module graph
+               process_generate_dot
+               close("article")
+               close("div")
        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 mmodule in list_mmodules do
+               for mmodule in 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
@@ -353,31 +359,17 @@ class NitdocOverview
                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
 
-       var mmodules: Array[MModule]
+       private var mmodules: Array[MModule]
 
-       init with(mmodules: Array[MModule]) do
+       init(mmodules: Array[MModule]) do
                self.mmodules = mmodules
-               opt_nodot = false
-               destinationdir = ""
+               self.dot_dir = null
        end
 
        redef fun head do
@@ -387,20 +379,18 @@ class NitdocFullindex
 
        redef fun menu do
                open("li")
-               add_html("<a href=\"index.html\">Overview</a>")
+               add("a").attr("href", "index.html").text("Overview")
                close("li")
                add("li").add_class("current").text("Full Index")
        end
 
        redef fun content do
-               open("div").add_class("page")
                open("div").add_class("content fullpage")
                add("h1").text("Full Index")
                module_column
                classes_column
                properties_column
                close("div")
-               close("div")
        end
 
        # Add to content modules column
@@ -482,14 +472,13 @@ end
 class NitdocModule
        super NitdocPage
 
-       var mmodule: MModule
-       var mbuilder: ModelBuilder
+       private var mmodule: MModule
+       private var mbuilder: ModelBuilder
 
-       init with(mmodule: MModule, mbuilder: ModelBuilder) do
+       init(mmodule: MModule, mbuilder: ModelBuilder, dot_dir: nullable String) do
                self.mmodule = mmodule
                self.mbuilder = mbuilder
-               opt_nodot = false
-               destinationdir = ""
+               self.dot_dir = dot_dir
        end
 
        redef fun head do
@@ -500,26 +489,25 @@ class NitdocModule
 
        redef fun menu do
                open("li")
-               add_html("<a href=\"index.html\">Overview</a>")
+               add("a").attr("href", "index.html").text("Overview")
                close("li")
                add("li").add_class("current").text(mmodule.name)
                open("li")
-               add_html("<a href=\"full-index.html\" >Full Index</a>")
+               add("a").attr("href", "full-index.html").text("Full Index")
                close("li")
        end
 
        redef fun content do
-               open("div").add_class("page")
                sidebar
                open("div").add_class("content")
                add("h1").text(mmodule.name)
-               add("div").add_class("subtitle").text("module {mmodule.namespace(mbuilder)}")
+               add("div").add_class("subtitle")
+               add_html("module {mmodule.namespace(mbuilder)}")
                module_comment
-               #process_generate_dot
+               process_generate_dot
                classes
                properties
                close("div")
-               close("div")
        end
 
        # Insert module comment in the content
@@ -536,73 +524,75 @@ class NitdocModule
        end
 
        fun process_generate_dot do
+               var name = "dep_{mmodule.name}"
                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")
+               op.append("digraph {name} \{ 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.poset do
+                       var public_owner = m.public_owner
+                       if public_owner == null then
+                               public_owner = m
+                               if m == mmodule then
+                                       op.append("\"{m.name}\"[shape=box,margin=0.03];\n")
+                               else
+                                       op.append("\"{m.name}\"[URL=\"{m.name}.html\"];\n")
+                               end
+                       end
                        for imported in m.in_importation.direct_greaters do
-                                       if imported.direct_owner == null then
-                                               op.append("\"{m.name}\"->\"{imported.name}\";\n")
-                                       end
-                                       end
+                               if imported.public_owner == null then
+                                       op.append("\"{public_owner.name}\"->\"{imported.name}\";\n")
+                               end
+                       end
                end
                op.append("\}\n")
-               generate_dot(op.to_s, "dep_{mmodule.name}", "Modules hierarchy")
+               generate_dot(op.to_s, name, "Dependency graph for module {mmodule.name}")
        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.greaters.length > 0 then
-                       add_html("<h4>All dependencies</h4><ul>")
-                       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 m.public_owner != null then continue
-                               var am = mbuilder.mmodule2nmodule[m]
-                               open("li")
-                               add_html(m.link(am))
-                               close("li")
-                       end
-                       add_html("</ul>")
-               end
-               if mmodule.in_importation.smallers.length > 0 then
-                       add_html("<h4>All clients</h4><ul>")
-                       var sorted = mmodule.in_importation.smallers.to_a
-                       var sorter = new ComparableSorter[MModule]
-                       sorter.sort(sorted)
-                       for m in sorted do
-                               if m == mmodule or m.public_owner != null then continue
-                               var am = mbuilder.mmodule2nmodule[m]
-                               open("li")
-                               add_html(m.link(am))
-                               close("li")
-                       end
-                       add_html("</ul>")
+               add("h3").text("Module Hierarchy")
+               var dependencies = new Array[MModule]
+               for dep in mmodule.in_importation.greaters do
+                       if dep == mmodule or dep.public_owner != null then continue
+                       dependencies.add(dep)
+               end
+               if dependencies.length > 0 then
+                       add("h4").text("All dependencies")
+                       display_module_list(dependencies)
+               end
+               var clients = new Array[MModule]
+               for dep in mmodule.in_importation.smallers do
+                       if dep == mmodule or dep.public_owner != null then continue
+                       clients.add(dep)
+               end
+               if clients.length > 0 then
+                       add("h4").text("All clients")
+                       display_module_list(clients)
                end
                close("nav")
                if mmodule.in_nesting.direct_greaters.length > 0 then
-                       var sorted = mmodule.in_nesting.direct_greaters.to_a
-                       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_html(m.link(am))
-                               close("li")
-                       end
-                       close("ul")
+                       add("h3").text("Nested Modules")
+                       display_module_list(mmodule.in_nesting.direct_greaters.to_a)
                        close("nav")
                end
                close("div")
        end
 
+       private fun display_module_list(list: Array[MModule]) do
+               open("ul")
+               var sorter = new ComparableSorter[MModule]
+               sorter.sort(list)
+               for m in list do
+                       var am = mbuilder.mmodule2nmodule[m]
+                       open("li")
+                       add_html(m.link(am))
+                       close("li")
+               end
+               close("ul")
+       end
+
        fun classes do
                var amodule = mbuilder.mmodule2nmodule[mmodule]
                var intro_mclasses = mmodule.intro_mclasses
@@ -651,10 +641,13 @@ class NitdocModule
                var sorter = new ComparableSorter[MPropDef]
                sorter.sort(sorted)
                open("article").add_class("properties filterable")
-               add_html("<h2>Properties</h2>")
+               add("h2").text("Properties")
                open("ul")
                for p in sorted do
+                       if p isa MAttributeDef then continue
                        if p.mproperty.visibility <= none_visibility then continue
+                       if not mbuilder.mpropdef2npropdef.has_key(p) then continue
+                       var nprop = mbuilder.mpropdef2npropdef[p]
                        if p.is_intro then
                                open("li").add_class("intro")
                                add("span").attr("title", "introduction").text("I")
@@ -662,8 +655,7 @@ class NitdocModule
                                open("li").add_class("redef")
                                add("span").attr("title", "redefinition").text("R")
                        end
-                       add_html("&nbsp;")
-                       add("a").attr("href", "{p.mclassdef.mclass.name}.html").attr("title", "").text("{p.mproperty.name} ({p.mclassdef.mclass.name})")
+                       add_html("&nbsp;{p.link(nprop)} ({p.mclassdef.mclass.name})")
                        close("li")
                end
                close("ul")
@@ -675,14 +667,15 @@ end
 class NitdocClass
        super NitdocPage
 
-       var mclass: MClass
-       var mbuilder: ModelBuilder
+       private var mclass: MClass
+       private var mbuilder: ModelBuilder
+       private var nitdoc: Nitdoc
 
-       init with(mclass: MClass, mbuilder: ModelBuilder, source: nullable String) do
+       init(mclass: MClass, nitdoc: Nitdoc, dot_dir: nullable String, source: nullable String) do
                self.mclass = mclass
-               self.mbuilder = mbuilder
-               self.opt_nodot = false
-               self.destinationdir = ""
+               self.mbuilder = nitdoc.modelbuilder
+               self.nitdoc = nitdoc
+               self.dot_dir = dot_dir
                self.source = source
        end
 
@@ -698,7 +691,7 @@ class NitdocClass
 
        redef fun menu do
                open("li")
-               add_html("<a href=\"index.html\">Overview</a>")
+               add("a").attr("href", "index.html").text("Overview")
                close("li")
                open("li")
                var public_owner = mclass.public_owner
@@ -712,12 +705,11 @@ class NitdocClass
                close("li")
                add("li").add_class("current").text(mclass.name)
                open("li")
-               add_html("<a href=\"full-index.html\" >Full Index</a>")
+               add("a").attr("href", "full-index.html").text("Full Index")
                close("li")
        end
 
        redef fun content do
-               open("div").add_class("page")
                open("div").add_class("menu")
                properties_column
                inheritance_column
@@ -725,56 +717,80 @@ class NitdocClass
                open("div").add_class("content")
                class_doc
                close("div")
-               close("div")
        end
 
        fun properties_column do
-               var sorted = new Array[MProperty]
-               var sorter = new ComparableSorter[MProperty]
+               var sorter = new ComparableSorter[MPropDef]
                open("nav").add_class("properties filterable")
                add("h3").text("Properties")
-
-               if mclass.virtual_types.length > 0 then
-                       add("h4").text("Virtual Types")
-                       open("ul")
-                       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>")
+               # get properties
+               var vtypes = new HashSet[MVirtualTypeDef]
+               var consts = new HashSet[MMethodDef]
+               var meths = new HashSet[MMethodDef]
+               for mclassdef in mclass.mclassdefs do
+                       for mpropdef in mclassdef.mpropdefs do
+                               if not mbuilder.mpropdef2npropdef.has_key(mpropdef) then continue
+                               if mpropdef.mproperty.visibility <= none_visibility then continue
+                               if mpropdef isa MVirtualTypeDef then vtypes.add(mpropdef)
+                               if mpropdef isa MMethodDef then
+                                       if mpropdef.mproperty.is_init then
+                                               consts.add(mpropdef)
+                                       else
+                                               meths.add(mpropdef)
+                                       end
+                               end
                        end
-                       close("ul")
                end
-               if mclass.constructors.length > 0 then
-                       sorted = mclass.constructors.to_a
-                       sorter.sort(sorted)
+               for mprop in mclass.inherited_methods do
+                       var mpropdef = mprop.intro
+                       if not mbuilder.mpropdef2npropdef.has_key(mpropdef) then continue
+                       if mprop.visibility <= none_visibility then continue
+                       if mprop.intro_mclassdef.mclass.name == "Object" then continue
+                       meths.add(mpropdef)
+               end
+               # virtual types
+               if vtypes.length > 0 then
+                       var vts = new Array[MVirtualTypeDef]
+                       vts.add_all(vtypes)
+                       sorter.sort(vts)
+                       add("h4").text("Virtual Types")
+                       display_mpropdef_list(vts)
+               end
+               if consts.length > 0 then
+                       var cts = new Array[MMethodDef]
+                       cts.add_all(consts)
+                       sorter.sort(cts)
                        add("h4").text("Constructors")
-                       open("ul")
-                       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")
+                       display_mpropdef_list(cts)
+               end
+               if meths.length > 0 then
+                       var mts = new Array[MMethodDef]
+                       mts.add_all(meths)
+                       sorter.sort(mts)
+                       add("h4").text("Methods")
+                       display_mpropdef_list(mts)
                end
-               add("h4").text("Methods")
+               close("nav")
+       end
+
+       private fun display_mpropdef_list(list: Array[MPropDef]) do
                open("ul")
-               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>")
+               for prop in list do
+                       var nprop = mbuilder.mpropdef2npropdef[prop]
+                       if prop.is_intro and prop.mproperty.intro_mclassdef.mclass != mclass then
+                               open("li").add_class("inherit")
+                               add("span").attr("title", "Inherited").text("H")
+                       else if prop.is_intro then
+                               open("li").add_class("intro")
+                               add("span").attr("title", "Introduced").text("I")
                        else
-                               add_html("<li class=\"inherit\"><span title=\"Inherited\">H</span><a href=\"{prop.link_anchor}\">{prop.name}</a></li>")
+                               open("li").add_class("redef")
+                               add("span").attr("title", "Redefined").text("R")
                        end
+                       add_html(prop.link(nprop))
+                       close("li")
                end
                close("ul")
-               close("nav")
        end
 
        fun inheritance_column do
@@ -789,7 +805,9 @@ class NitdocClass
                        open("ul")
                        for sup in sorted do
                                if sup == mclass then continue
-                               add_html("<li><a href=\"{sup.name}.html\">{sup.name}</a></li>")
+                               open("li")
+                               add("a").attr("href", "{sup.name}.html").text(sup.name)
+                               close("li")
                        end
                        close("ul")
                end
@@ -803,7 +821,9 @@ class NitdocClass
                        open("ul")
                        for sub in sorted do
                                if sub == mclass then continue
-                               add_html("<li><a href=\"{sub.name}\">{sub.name}</a></li>")
+                               open("li")
+                               add("a").attr("href", "{sub.name}.html").text(sub.name)
+                               close("li")
                        end
                        close("ul")
                else if mclass.children.length <= 100 then
@@ -813,7 +833,9 @@ class NitdocClass
                        open("ul")
                        for sub in sorted do
                                if sub == mclass then continue
-                               add_html("<li><a href=\"{sub.name}\">{sub.name}</a></li>")
+                               open("li")
+                               add("a").attr("href", "{sub.name}.html").text(sub.name)
+                               close("li")
                        end
                        close("ul")
                else
@@ -843,6 +865,7 @@ class NitdocClass
                # We add the class description
                open("section").add_class("description")
                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>")
+               process_generate_dot
                close("section")
                open("section").add_class("concerns")
                add("h2").add_class("section-header").text("Concerns")
@@ -923,7 +946,8 @@ class NitdocClass
                                open("p")
                                add_html("Defined in {imclass.link(inclass)}: ")
                                for method in sortedp do
-                                       add_html("<a href=\"{method.link_anchor}\">{method.name}</a>")
+                                       #TODO link to inherited propdef
+                                       add_html("<a href=\"\">{method.name}</a>")
                                        if method != sortedp.last then add_html(", ")
                                end
                                close("p")
@@ -987,6 +1011,51 @@ class NitdocClass
                close("article")
        end
 
+       fun process_generate_dot do
+               var pe = nitdoc.class_hierarchy[mclass]
+               var cla = new HashSet[MClass]
+               var sm = new HashSet[MClass]
+               var sm2 = new HashSet[MClass]
+               sm.add(mclass)
+               while cla.length + sm.length < 10 and sm.length > 0 do
+                       cla.add_all(sm)
+                       sm2.clear
+                       for x in sm do
+                               sm2.add_all(pe.poset[x].direct_smallers)
+                       end
+                       var t = sm
+                       sm = sm2
+                       sm2 = t
+               end
+               cla.add_all(pe.greaters)
+
+               var op = new Buffer
+               var name = "dep_{mclass.name}"
+               op.append("digraph {name} \{ 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 c in cla do
+                       if c == mclass then
+                               op.append("\"{c.name}\"[shape=box,margin=0.03];\n")
+                       else
+                               op.append("\"{c.name}\"[URL=\"{c.name}.html\"];\n")
+                       end
+                       for c2 in pe.poset[c].direct_greaters do
+                               if not cla.has(c2) then continue
+                               op.append("\"{c.name}\"->\"{c2.name}\";\n")
+                       end
+                       if not pe.poset[c].direct_smallers.is_empty then
+                               var others = true
+                               for c2 in pe.poset[c].direct_smallers do
+                                       if cla.has(c2) then others = false
+                               end
+                               if others then
+                                       op.append("\"{c.name}...\"[label=\"\"];\n")
+                                       op.append("\"{c.name}...\"->\"{c.name}\"[style=dotted];\n")
+                               end
+                       end
+               end
+               op.append("\}\n")
+               generate_dot(op.to_s, name, "Dependency graph for class {mclass.name}")
+       end
 end
 
 redef class AModule
@@ -1064,6 +1133,11 @@ redef class MPropDef
        super Comparable
        redef type OTHER: MPropDef
        redef fun <(other: OTHER): Bool do return self.mproperty.name < other.mproperty.name
+
+       # Return a link (html a tag) to the nitdoc class page
+       fun link(nprop: APropdef): String do
+               return "<a href=\"{mclassdef.mclass.name}.html#{mproperty.anchor}\" title=\"{nprop.short_comment}\">{mproperty}</a>"
+       end
 end
 
 redef class MProperty
@@ -1085,14 +1159,6 @@ redef class MProperty
                return classdef.mclass
        end
 
-       fun class_text: String do
-               return local_class.name
-       end
-
-       fun link_anchor: String do
-               return "{class_text}.html#{anchor}"
-       end
-
        fun anchor: String do
                return "PROP_{c_name}"
        end