ni_nitdoc: fixed broken search with special caracters in JS
[nit.git] / src / ni_nitdoc.nit
index 8b6a8e5..f502981 100644 (file)
@@ -106,10 +106,10 @@ class Nitdoc
                        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
 
@@ -119,21 +119,21 @@ class Nitdoc
        end
 
        fun fullindex do
-               var fullindex = new NitdocFullindex(model.mmodules)
+               var fullindex = new NitdocFullindex(self)
                fullindex.save("{output_dir.to_s}/full-index.html")
        end
 
        fun modules do
                for mmodule in model.mmodules do
                        var modulepage = new NitdocModule(mmodule, modelbuilder, dot_dir)
-                       modulepage.save("{output_dir.to_s}/{mmodule.name}.html")
+                       modulepage.save("{output_dir.to_s}/{mmodule.url}")
                end
        end
 
        fun classes do
                for mclass in modelbuilder.model.mclasses do
                        var classpage = new NitdocClass(mclass, self, dot_dir, source)
-                       classpage.save("{output_dir.to_s}/{mclass.name}.html")
+                       classpage.save("{output_dir.to_s}/{mclass.url}")
                end
        end
 
@@ -142,25 +142,31 @@ class Nitdoc
                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.anchor}\" \}")
-                               if not propdef is prop.mpropdefs.last then content.append(", ")
-                       end
-                       content.append("]")
-                       content.append(", ")
-               end
 
+               for mmodule in model.mmodules do
+                       content.append("\"{mmodule.name}\": [")
+                       content.append("\{txt: \"{mmodule.name}\", url:\"{mmodule.url}\" \},")
+                       content.append("],")
+               end
                for mclass in model.mclasses do
+                       if mclass.visibility <= none_visibility then continue
                        content.append("\"{mclass.name}\": [")
-                       for mclassdef in mclass.mclassdefs do
-                               content.append("\{txt: \"{mclassdef.mclass.full_name}\", url:\"{mclass.link_anchor}\" \}")
-                               if not mclassdef is mclass.mclassdefs.last then content.append(", ")
+                       content.append("\{txt: \"{mclass.name}\", url:\"{mclass.url}\" \},")
+                       content.append("],")
+               end
+               var name2mprops = new HashMap[String, Set[MPropDef]]
+               for mproperty in model.mproperties do
+                       if mproperty.visibility <= none_visibility then continue
+                       if mproperty isa MAttribute then continue
+                       if not name2mprops.has_key(mproperty.name) then name2mprops[mproperty.name] = new HashSet[MPropDef]
+                       name2mprops[mproperty.name].add_all(mproperty.mpropdefs)
+               end
+               for mproperty, mpropdefs in name2mprops do
+                       content.append("\"{mproperty}\": [")
+                       for mpropdef in mpropdefs do
+                               content.append("\{txt: \"{mpropdef.full_name}\", url:\"{mpropdef.url}\" \},")
                        end
-                       content.append("]")
-                       if not mclass is model.mclasses.last then content.append(", ")
+                       content.append("],")
                end
 
                content.append(" \};")
@@ -359,7 +365,7 @@ class NitdocOverview
                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 mmodules do
-                       op.append("\"{mmodule.name}\"[URL=\"{mmodule.name}.html\"];\n")
+                       op.append("\"{mmodule.name}\"[URL=\"{mmodule.url}\"];\n")
                        for imported in mmodule.in_importation.direct_greaters do
                                if imported.direct_owner == null then
                                        op.append("\"{mmodule.name}\"->\"{imported.name}\";\n")
@@ -375,10 +381,10 @@ end
 class NitdocFullindex
        super NitdocPage
 
-       private var mmodules: Array[MModule]
+       private var nitdoc: Nitdoc
 
-       init(mmodules: Array[MModule]) do
-               self.mmodules = mmodules
+       init(nitdoc: Nitdoc) do
+               self.nitdoc = nitdoc
                self.dot_dir = null
        end
 
@@ -403,18 +409,17 @@ class NitdocFullindex
 
        # Add to content modules column
        fun module_column do
-               var ls = new List[nullable MModule]
-               var sorted = mmodules
-               var sorterp = new ComparableSorter[MModule]
-               sorterp.sort(sorted)
-               append("<article class='modules filterable'></article>")
+               var sorter = new ComparableSorter[MModule]
+               var sorted = new Array[MModule]
+               for mmodule in nitdoc.modelbuilder.model.mmodule_importation_hierarchy do
+                       sorted.add(mmodule)
+               end
+               sorter.sort(sorted)
+               append("<article class='modules filterable'>")
                append("<h2>Modules</h2>")
                append("<ul>")
                for mmodule in sorted do
-                       if mmodule.public_owner != null and not ls.has(mmodule.public_owner) then
-                               ls.add(mmodule.public_owner)
-                               append("<li><a href='{mmodule.public_owner.name}.html'>(mmodule.public_owner.name)</a></li>")
-                       end
+                       append("<li>{mmodule.link(nitdoc.modelbuilder)}</li>")
                end
                append("</ul>")
                append("</article>")
@@ -422,14 +427,14 @@ class NitdocFullindex
 
        # Add to content classes modules
        fun classes_column do
-               var sorted = mmodules.first.imported_mclasses.to_a
-               var sorterp = new ComparableSorter[MClass]
-               sorterp.sort(sorted)
-               append("<article class='classes filterable'>")
+               var sorted = nitdoc.modelbuilder.model.mclasses
+               var sorter = new ComparableSorter[MClass]
+               sorter.sort(sorted)
+               append("<article class='modules filterable'>")
                append("<h2>Classes</h2>")
                append("<ul>")
                for mclass in sorted do
-                       append("<li><a href='{mclass}.html'>(mclass.name)</a></li>")
+                       append("<li>{mclass.link(nitdoc.modelbuilder)}</li>")
                end
                append("</ul>")
                append("</article>")
@@ -437,29 +442,15 @@ class NitdocFullindex
 
        # Insert the properties column of fullindex page
        fun properties_column do
-               append("<article class='classes filterable'>")
+               var sorted = nitdoc.modelbuilder.model.mproperties
+               var sorter = new ComparableSorter[MProperty]
+               sorter.sort(sorted)
+               append("<article class='modules filterable'>")
                append("<h2>Properties</h2>")
                append("<ul>")
-               var sorted_imported = mmodules.first.imported_methods.to_a
-               var sorted_redef = mmodules.first.redef_methods.to_a
-               var sorterp = new ComparableSorter[MProperty]
-               sorterp.sort(sorted_imported)
-               sorterp.sort(sorted_redef)
-
-               for method in sorted_imported do
-                       if method.visibility is none_visibility or method.visibility is intrude_visibility then continue
-                       append("<li class='intro'</li>")
-                       append("<span title='introduction'>I</span>&nbsp;")
-                       append("<a href='{method.local_class.name}.html' title=''>{method.name} ({method.local_class.name})</a>")
-                       append("</li>")
-               end
-
-               for method in sorted_redef do
-                       if method.visibility is none_visibility or method.visibility is intrude_visibility then continue
-                       append("<li class='redef'>")
-                       append("<span title='redefinition'>R</span>&nbsp;")
-                       append("<a href='{method.local_class.name}.html' title=''>{method.name} ({method.local_class.name})</span>")
-                       append("</li>")
+               for mproperty in sorted do
+                       if mproperty isa MAttribute then continue
+                       append("<li>{mproperty.intro.link(nitdoc.modelbuilder)} ({mproperty.intro.mclassdef.mclass.link(nitdoc.modelbuilder)})</li>")
                end
                append("</ul>")
                append("</article>")
@@ -515,7 +506,7 @@ class NitdocModule
                                if m == mmodule then
                                        op.append("\"{m.name}\"[shape=box,margin=0.03];\n")
                                else
-                                       op.append("\"{m.name}\"[URL=\"{m.name}.html\"];\n")
+                                       op.append("\"{m.name}\"[URL=\"{m.url}\"];\n")
                                end
                        end
                        for imported in m.in_importation.direct_greaters do
@@ -569,6 +560,7 @@ class NitdocModule
                append("</ul>")
        end
 
+       # display the class column
        fun classes do
                var amodule = mbuilder.mmodule2nmodule[mmodule]
                var intro_mclasses = mmodule.intro_mclasses
@@ -590,7 +582,6 @@ class NitdocModule
                append("<h2>Classes</h2>")
                append("<ul>")
                for c in sorted do
-                       var nclass = mbuilder.mclassdef2nclassdef[c.intro].as(AStdClassdef)
                        if redef_mclasses.has(c) and c.intro_mmodule.public_owner != mmodule then
                                append("<li class='redef'>")
                                append("<span title='refined in this module'>R </span>")
@@ -598,7 +589,7 @@ class NitdocModule
                                append("<li class='intro'>")
                                append("<span title='introduced in this module'>I </span>")
                        end
-                       append(c.link(nclass))
+                       append(c.link(mbuilder))
                        append("</li>")
                end
                append("</ul>")
@@ -606,7 +597,9 @@ class NitdocModule
                append("</div>")
        end
 
+       # display the property column
        fun properties do
+               # get properties
                var amodule = mbuilder.mmodule2nmodule[mmodule]
                var mpropdefs = new HashSet[MPropDef]
                for m in mmodule.in_nesting.greaters do
@@ -616,23 +609,14 @@ class NitdocModule
                var sorted = mpropdefs.to_a
                var sorter = new ComparableSorter[MPropDef]
                sorter.sort(sorted)
+               # display properties in one column
                append("<article class='properties filterable'>")
                append("<h2>Properties</h2>")
                append("<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
-                               append("<li class='intro'>")
-                               append("<span title='introduction'>I</span>&nbsp;{p.link(nprop)} ({p.mclassdef.mclass.name})")
-                               append("</li>")
-                       else
-                               append("<li class='redef'>")
-                               append("<span title='redefinition'>R</span>&nbsp;{p.link(nprop)} ({p.mclassdef.mclass.name})")
-                               append("</li>")
-                       end
+               for mprop in sorted do
+                       if mprop isa MAttributeDef then continue
+                       if mprop.mproperty.visibility <= none_visibility then continue
+                       append(mprop.html_list_item(mbuilder))
                end
                append("</ul>")
                append("</article>")
@@ -646,6 +630,10 @@ class NitdocClass
        private var mclass: MClass
        private var mbuilder: ModelBuilder
        private var nitdoc: Nitdoc
+       private var vtypes = new HashSet[MVirtualTypeDef]
+       private var consts = new HashSet[MMethodDef]
+       private var meths = new HashSet[MMethodDef]
+       private var inherited = new HashSet[MPropDef]
 
        init(mclass: MClass, nitdoc: Nitdoc, dot_dir: nullable String, source: nullable String) do
                self.mclass = mclass
@@ -653,6 +641,34 @@ class NitdocClass
                self.nitdoc = nitdoc
                self.dot_dir = dot_dir
                self.source = source
+               # load properties
+               for mclassdef in mclass.mclassdefs do
+                       for mpropdef in mclassdef.mpropdefs do
+                               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
+               end
+               # get inherited properties
+               for mprop in mclass.inherited_mproperties do
+                       var mpropdef = mprop.intro
+                       if mprop.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
+                       inherited.add(mpropdef)
+               end
        end
 
        redef fun head do
@@ -691,74 +707,44 @@ class NitdocClass
                var sorter = new ComparableSorter[MPropDef]
                append("<nav class='properties filterable'>")
                append("<h3>Properties</h3>")
-               # 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
-               end
-               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)
                        append("<h4>Virtual Types</h4>")
-                       display_mpropdef_list(vts)
+                       append("<ul>")
+                       for mprop in vts do
+                               append(mprop.html_sidebar_item(self))
+                       end
+                       append("</ul>")
                end
+               # constructors
                if consts.length > 0 then
                        var cts = new Array[MMethodDef]
                        cts.add_all(consts)
                        sorter.sort(cts)
                        append("<h4>Constructors</h4>")
-                       display_mpropdef_list(cts)
+                       append("<ul>")
+                       for mprop in cts do
+                               append(mprop.html_sidebar_item(self))
+                       end
+                       append("</ul>")
                end
+               # methods
                if meths.length > 0 then
                        var mts = new Array[MMethodDef]
                        mts.add_all(meths)
                        sorter.sort(mts)
                        append("<h4>Methods</h4>")
-                       display_mpropdef_list(mts)
-               end
-               append("</nav>")
-       end
-
-       private fun display_mpropdef_list(list: Array[MPropDef]) do
-               append("<ul>")
-               for prop in list do
-                       var nprop = mbuilder.mpropdef2npropdef[prop]
-                       if prop.is_intro and prop.mproperty.intro_mclassdef.mclass != mclass then
-                               append("<li class='inherit'>")
-                               append("<span title='Inherited'>H</span>")
-                       else if prop.is_intro then
-                               append("<li class='intro'>")
-                               append("<span title='Introduced'>I</span>")
-                       else
-                               append("<li class='redef'>")
-                               append("<span title='Redefined'>R</span>")
+                       append("<ul>")
+                       for mprop in mts do
+                               if mprop.mproperty.intro_mclassdef.mclass.name == "Object" then continue
+                               append(mprop.html_sidebar_item(self))
                        end
-                       append(prop.link(nprop))
-                       append("</li>")
+                       append("</ul>")
                end
-               append("</ul>")
+               append("</nav>")
        end
 
        fun inheritance_column do
@@ -773,7 +759,7 @@ class NitdocClass
                        append("<ul>")
                        for sup in sorted do
                                if sup == mclass then continue
-                               append("<li><a href='{sup.name}.html'>{sup.name}</a></li>")
+                               append("<li>{sup.link(mbuilder)}</li>")
                        end
                        append("</ul>")
                end
@@ -787,7 +773,7 @@ class NitdocClass
                        append("<ul>")
                        for sub in sorted do
                                if sub == mclass then continue
-                               append("<li><a href='{sub.name}.html'>{sub.name}</a></li>")
+                               append("<li>{sub.link(mbuilder)}</li>")
                        end
                        append("</ul>")
                else if mclass.children.length <= 100 then
@@ -797,7 +783,7 @@ class NitdocClass
                        append("<ul>")
                        for sub in sorted do
                                if sub == mclass then continue
-                               append("<li><a href='{sub.name}.html'>{sub.name}</a></li>")
+                               append("<li>{sub.link(mbuilder)}</li>")
                        end
                        append("</ul>")
                else
@@ -808,12 +794,9 @@ class NitdocClass
 
        fun class_doc do
                # title
-               append("<h1>{mclass.to_s}</h1>")
-               append("<div class='subtitle'>")
-               var subtitle = ""
-               if mclass.visibility is none_visibility then subtitle += "private "
-               subtitle += "{mclass.kind} {mclass.public_owner.html_namespace(mbuilder)}::{mclass}"
-               append(subtitle)
+               append("<h1>{mclass.html_signature}</h1>")
+               append("<div class='subtitle info'>{mclass.html_full_signature(mbuilder)}")
+
                append("</div>")
                # comment
                var nclass = mbuilder.mclassdef2nclassdef[mclass.intro]
@@ -823,26 +806,47 @@ class NitdocClass
                process_generate_dot
                append("</section>")
                # concerns
+               var concern2meths = new ArrayMap[MModule, Array[MMethodDef]]
+               var sorted_meths = new Array[MMethodDef]
                var sorted = new Array[MModule]
-               sorted.add_all(mclass.concerns.keys)
-               var sorterp = new ComparableSorter[MModule]
-               sorterp.sort(sorted)
+               sorted_meths.add_all(meths)
+               nitdoc.mainmodule.linearize_mpropdefs(sorted_meths)
+               for meth in meths do
+                       if inherited.has(meth) then continue
+                       var mmodule = meth.mclassdef.mmodule
+                       if not concern2meths.has_key(mmodule) then
+                               sorted.add(mmodule)
+                               concern2meths[mmodule] = new Array[MMethodDef]
+                       end
+                       concern2meths[mmodule].add(meth)
+               end
+               var sections = new ArrayMap[MModule, Array[MModule]]
+               for mmodule in concern2meths.keys do
+                       var owner = mmodule.public_owner
+                       if owner == null then owner = mmodule
+                       if not sections.has_key(owner) then sections[owner] = new Array[MModule]
+                       if owner != mmodule then sections[owner].add(mmodule)
+               end
                append("<section class='concerns'>")
                append("<h2 class='section-header'>Concerns</h2>")
                append("<ul>")
-               for owner in sorted do
-                       var nmodule = mbuilder.mmodule2nmodule[owner]
-                       var childs = mclass.concerns[owner]
+               for owner, mmodules in sections do
+                       var nowner = mbuilder.mmodule2nmodule[owner]
                        append("<li>")
-                       append("<a href=\"#MOD_{owner.name}\">{owner.name}</a>: {nmodule.short_comment}")
-                       if not childs is null then
+                       if nowner.short_comment.is_empty then
+                               append("<a href=\"#{owner.anchor}\">{owner.name}</a>")
+                       else
+                               append("<a href=\"#{owner.anchor}\">{owner.name}</a>: {nowner.short_comment}")
+                       end
+                       if not mmodules.is_empty then
                                append("<ul>")
-                               var sortedc = childs.to_a
-                               var sorterpc = new ComparableSorter[MModule]
-                               sorterpc.sort(sortedc)
-                               for child in sortedc do
-                                       var nchild = mbuilder.mmodule2nmodule[child]
-                                       append("<li><a href=\"#MOD_{child.name}\">{child.name}</a>: {nchild.short_comment} </li>")
+                               for mmodule in mmodules do
+                                       var nmodule = mbuilder.mmodule2nmodule[mmodule]
+                                       if nmodule.short_comment.is_empty then
+                                               append("<li><a href=\"#{mmodule.anchor}\">{mmodule.name}</a></li>")
+                                       else
+                                               append("<li><a href=\"#{mmodule.anchor}\">{mmodule.name}</a>: {nmodule.short_comment}</li>")
+                                       end
                                end
                                append("</ul>")
                        end
@@ -851,68 +855,95 @@ class NitdocClass
                append("</ul>")
                append("</section>")
                # properties
+               var prop_sorter = new ComparableSorter[MPropDef]
                var sorterprop = new ComparableSorter[MProperty]
                var sorterc = new ComparableSorter[MClass]
                var lmmodule = new List[MModule]
                # virtual and formal types
-               if mclass.virtual_types.length > 0 or mclass.arity > 0 then
+               var local_vtypes = new Array[MVirtualTypeDef]
+               for vt in vtypes do if not inherited.has(vt) then local_vtypes.add(vt)
+               if local_vtypes.length > 0 or mclass.arity > 0 then
                        append("<section class='types'>")
                        append("<h2>Formal and Virtual Types</h2>")
-                       if mclass.virtual_types.length > 0 then for prop in mclass.virtual_types do description(prop)
-                       #TODO this is incorrect
+                       # formal types
                        if mclass.arity > 0 and nclass isa AStdClassdef then
-                               for prop in nclass.n_formaldefs do
-                                       append("<article id='FT_Object_{prop.collect_text}'>")
-                                       append("<h3 class='signature'>{prop.collect_text}: nullable ")
-                                       append("<a title=\"The root of the class hierarchy.\" href=\"Object.html\">Object</a>")
-                                       append("</h3>")
+                               for ft, bound in mclass.parameter_types do
+                                       append("<article id='FT_{ft}'>")
+                                       append("<h3 class='signature'>{ft}: {bound.link(mbuilder)}</h3>")
                                        append("<div class=\"info\">formal generic type</div>")
                                        append("</article>")
                                end
                        end
+                       # virtual types
+                       prop_sorter.sort(local_vtypes)
+                       for prop in local_vtypes do append(prop.html_full_desc(self))
                        append("</section>")
                end
                # constructors
-               if mclass.constructors.length > 0 then
-                       var sortedc = mclass.constructors.to_a
-                       sorterprop.sort(sortedc)
+               var local_consts = new Array[MMethodDef]
+               for const in consts do if not inherited.has(const) then local_consts.add(const)
+               prop_sorter.sort(local_consts)
+               if local_consts.length > 0 then
                        append("<section class='constructors'>")
                        append("<h2 class='section-header'>Constructors</h2>")
-                       for prop in sortedc do description(prop)
+                       for prop in local_consts do append(prop.html_full_desc(self))
                        append("</section>")
                end
                # methods
-               append("<section class='methods'>")
-               append("<h2 class='section-header'>Methods</h2>")
-               for mmodule, mmethods in mclass.all_methods do
-                       var nmodule = mbuilder.mmodule2nmodule[mmodule]
-                       append("<a id=\"MOD_{mmodule.name}\"></a>")
-                       if mmodule != mclass.intro_mmodule and mmodule != mclass.public_owner then
-                               if mclass.has_mmodule(mmodule) then
-                                       append("<p class=\"concern-doc\">{mmodule.name}: {nmodule.short_comment}</p>")
-                               else
-                                       append("<h3 class=\"concern-toplevel\">Methods refined in {mmodule.link(mbuilder)}</h3><p class=\"concern-doc\">{mmodule.name}: {nmodule.short_comment}</p>")
+               if not concern2meths.is_empty then
+                       append("<section class='methods'>")
+                       append("<h2 class='section-header'>Methods</h2>")
+                       for owner, mmodules in sections do
+                               append("<a id=\"{owner.anchor}\"></a>")
+                               if owner != mclass.intro_mmodule and owner != mclass.public_owner then
+                                       var nowner = mbuilder.mmodule2nmodule[owner]
+                                       append("<h3 class=\"concern-toplevel\">Methods refined in {owner.link(mbuilder)}</h3>")
+                                       if nowner.short_comment.is_empty then
+                                               append("<p class=\"concern-doc\">{owner.link(mbuilder)}</p>")
+                                       else
+                                               append("<p class=\"concern-doc\">{owner.link(mbuilder)}: {nowner.short_comment}</p>")
+                                       end
                                end
+                               if concern2meths.has_key(owner) then
+                                       var mmethods = concern2meths[owner]
+                                       prop_sorter.sort(mmethods)
+                                       for prop in mmethods do append(prop.html_full_desc(self))
+                               end
+                               for mmodule in mmodules do
+                                       append("<a id=\"{mmodule.anchor}\"></a>")
+                                       var nmodule = mbuilder.mmodule2nmodule[mmodule]
+                                       if mmodule != mclass.intro_mmodule and mmodule != mclass.public_owner then
+                                               if nmodule.short_comment.is_empty then
+                                                       append("<p class=\"concern-doc\">{mmodule.link(mbuilder)}</p>")
+                                               else
+                                                       append("<p class=\"concern-doc\">{mmodule.link(mbuilder)}: {nmodule.short_comment}</p>")
+                                               end
+                                       end
+                                       var mmethods = concern2meths[mmodule]
+                                       prop_sorter.sort(mmethods)
+                                       for prop in mmethods do append(prop.html_full_desc(self))
+                               end
+                       end
+               end
+               # inherited properties
+               if inherited.length > 0 then
+                       var sorted_inherited = new Array[MPropDef]
+                       sorted_inherited.add_all(inherited)
+                       nitdoc.mainmodule.linearize_mpropdefs(sorted_inherited)
+                       var classes = new ArrayMap[MClass, Array[MPropDef]]
+                       for mmethod in sorted_inherited.reversed do
+                               var mclass = mmethod.mclassdef.mclass
+                               if not classes.has_key(mclass) then classes[mclass] = new Array[MPropDef]
+                               classes[mclass].add(mmethod)
                        end
-                       var sortedc = mmethods.to_a
-                       sorterprop.sort(sortedc)
-                       for prop in sortedc do description(prop)
-               end
-               # inherited methods
-               if mclass.inherited_methods.length > 0 then
-                       var sortedc = new Array[MClass]
-                       sortedc.add_all(mclass.inherited.keys)
-                       sorterc.sort(sortedc)
-                       append("<h3>Inherited Methods</h3>")
-                       for imclass in sortedc do
-                               var inclass = mbuilder.mclassdef2nclassdef[imclass.intro].as(AStdClassdef)
-                               var sortedp = mclass.inherited[imclass].to_a
-                               sorterprop.sort(sortedp)
-                               append("<p>Defined in {imclass.link(inclass)}: ")
-                               for method in sortedp do
-                                       #TODO link to inherited propdef
-                                       append("<a href=\"\">{method.name}</a>")
-                                       if method != sortedp.last then append(", ")
+                       append("<h3>Inherited Properties</h3>")
+                       for c, mmethods in classes do
+                               prop_sorter.sort(mmethods)
+                               append("<p>Defined in {c.link(mbuilder)}: ")
+                               for i in [0..mmethods.length[ do
+                                       var mmethod = mmethods[i]
+                                       append(mmethod.link(mbuilder))
+                                       if i <= mmethods.length - 1 then append(", ")
                                end
                                append("</p>")
                        end
@@ -920,55 +951,6 @@ class NitdocClass
                append("</section>")
        end
 
-       fun description(prop: MProperty) do
-               if not mbuilder.mpropdef2npropdef.has_key(prop.intro) then return
-               var nprop = mbuilder.mpropdef2npropdef[prop.intro]
-               if not nprop isa AMethPropdef then return
-               var classes = new Array[String]
-               if nprop isa AInitPropdef then
-                       classes.add("init")
-               else
-                       classes.add("fun")
-               end
-               if prop.is_redef then classes.add("redef")
-               if prop.visibility == none_visibility then
-                       classes.add("private")
-               else if prop.visibility == protected_visibility then
-                       classes.add("protected")
-               else
-                       classes.add("public")
-               end
-               append("<article class='{classes.join(" ")}' id='{prop.anchor}'>")
-               var sign = prop.name
-               append("<h3 class='signature'>{prop.name}{nprop.signature}</h3>")
-               append("<div class='info'>")
-               append("{if prop.is_redef then "redef" else ""} fun {prop.intro_mclassdef.namespace(mclass)}::{prop.name}</div><div style=\"float: right;\"><a id=\"lblDiffCommit\"></a>")
-               append("</div>")
-               append("<div class='description'>")
-               if nprop.comment == "" then
-                       append("<a class=\"newComment\" title=\"32\" tag=\"\">New Comment</a>")
-               else
-                       append("<pre class=\"text_label\" title=\"\" name=\"\" tag=\"\" type=\"1\">{nprop.comment}</pre>")
-               end
-               append("<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>")
-               append("<p>")
-               if prop.local_class != mclass then
-                       var mredef = prop.local_class.intro_mmodule
-                       append("inherited from {mredef.link(mbuilder)} ")
-               end
-               #TODO display show code if doc github
-               var mintro = prop.intro_mclassdef.mmodule
-               append("defined by the module {mintro.link(mbuilder)}{if prop.apropdef is null then "" else show_source(prop.apropdef.location)}.")
-
-               for parent in mclass.parents do
-                       var mparent = parent.intro_mmodule
-                       if prop isa MMethod then if parent.constructors.has(prop) then append(" Previously defined by: {mparent.link(mbuilder)} for <a href=\"{parent.name}.html\">{parent.name}</a>.")
-               end
-               append("</p>")
-               append("</div>")
-               append("</article>")
-       end
-
        fun process_generate_dot do
                var pe = nitdoc.class_hierarchy[mclass]
                var cla = new HashSet[MClass]
@@ -994,7 +976,7 @@ class NitdocClass
                        if c == mclass then
                                op.append("\"{c.name}\"[shape=box,margin=0.03];\n")
                        else
-                               op.append("\"{c.name}\"[URL=\"{c.name}.html\"];\n")
+                               op.append("\"{c.name}\"[URL=\"{c.url}\"];\n")
                        end
                        for c2 in pe.poset[c].direct_greaters do
                                if not cla.has(c2) then continue
@@ -1016,25 +998,9 @@ class NitdocClass
        end
 end
 
-redef class AModule
-       private fun comment: String do
-               var ret = new Buffer
-               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.append(t.text.substring_from(1))
-               end
-               return ret.to_s.html_escape
-       end
-
-       private fun short_comment: String do
-               var ret = new Buffer
-               if n_moduledecl != null and n_moduledecl.n_doc != null then
-                       ret.append(n_moduledecl.n_doc.n_comment.first.text.substring_from(2).replace("\n", ""))
-               end
-               return ret.to_s.html_escape
-       end
-end
+#
+# Model redefs
+#
 
 redef class MModule
        super Comparable
@@ -1063,18 +1029,42 @@ redef class MModule
                return methods
        end
 
+       # URL to nitdoc page
+       fun url: String do
+               var res = new Buffer
+               res.append("module_")
+               var mowner = public_owner
+               if mowner != null then
+                       res.append("{public_owner.name}_")
+               end
+               res.append("{self.name}.html")
+               return res.to_s
+       end
+
+       # html anchor id to the module in a nitdoc page
+       fun anchor: String do
+               var res = new Buffer
+               res.append("MOD_")
+               var mowner = public_owner
+               if mowner != null then
+                       res.append("{public_owner.name}_")
+               end
+               res.append(self.name)
+               return res.to_s
+       end
+
        # Return a link (html a tag) to the nitdoc module page
        fun link(mbuilder: ModelBuilder): String do
-               return "<a href='{name}.html' title='{mbuilder.mmodule2nmodule[self].short_comment}'>{name}</a>"
+               return "<a href='{url}' title='{mbuilder.mmodule2nmodule[self].short_comment}'>{name}</a>"
        end
 
        # Return the module signature decorated with html
        fun html_signature(mbuilder: ModelBuilder): String do
-               return "<span>module {html_namespace(mbuilder)}</span>"
+               return "<span>module {html_full_namespace(mbuilder)}</span>"
        end
 
-       # Return the module namespace decorated with html
-       fun html_namespace(mbuilder: ModelBuilder): String do
+       # Return the module full namespace decorated with html
+       fun html_full_namespace(mbuilder: ModelBuilder): String do
                var res = new Buffer
                res.append("<span>")
                var mowner = public_owner
@@ -1087,6 +1077,20 @@ redef class MModule
                return res.to_s
        end
 
+       # Return the module full namespace decorated with html
+       fun html_namespace(mbuilder: ModelBuilder): String do
+               var res = new Buffer
+               res.append("<span>")
+               var mowner = public_owner
+               if mowner != null then
+                       res.append(public_owner.html_namespace(mbuilder))
+               else
+                       res.append(self.link(mbuilder))
+               end
+               res.append("</span>")
+               return res.to_s
+       end
+
        # Return the full comment of the module decorated with html
        fun html_full_comment(mbuilder: ModelBuilder): String do
                var res = new Buffer
@@ -1100,15 +1104,61 @@ redef class MModule
                return res.to_s
        end
 end
-redef class MPropDef
+
+redef class MClass
        super Comparable
-       redef type OTHER: MPropDef
-       redef fun <(other: OTHER): Bool do return self.mproperty.name < other.mproperty.name
+       redef type OTHER: MClass
+       redef fun <(other: OTHER): Bool do return self.name < other.name
+
+       # Return the module signature decorated with html
+       fun html_full_signature(mbuilder: ModelBuilder): String do
+               var res = new Buffer
+               if visibility <= none_visibility then
+                       res.append("private ")
+               else if visibility == protected_visibility then
+                       res.append("protected ")
+               end
+               res.append("{kind} {html_namespace(mbuilder)}")
+               return res.to_s
+       end
+
+       # Add type parameters
+       fun html_signature: String do
+               if arity > 0 then
+                       return "{name}[{intro.parameter_names.join(", ")}]"
+               else
+                       return name
+               end
+       end
 
        # 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.name}</a>"
+       fun link(mbuilder: ModelBuilder): String do
+               if mbuilder.mclassdef2nclassdef.has_key(intro) then
+                       var nclass = mbuilder.mclassdef2nclassdef[intro]
+                       if nclass isa AStdClassdef then
+                               return "<a href='{url}' title=\"{nclass.short_comment}\">{html_signature}</a>"
+                       else
+                               return "<a href='{url}'>{html_signature}</a>"
+                       end
+               else
+                       return "<a href='{url}'>{html_signature}</a>"
+               end
+       end
+
+       # Return the class namespace decorated with html
+       fun html_namespace(mbuilder: ModelBuilder): String do
+               var res = new Buffer
+               res.append(intro_mmodule.html_namespace(mbuilder))
+               res.append("::<span>{self.link(mbuilder)}</span>")
+               return res.to_s
+       end
+
+       fun url: String do
+               return "class_{public_owner}_{c_name}.html"
        end
+
+       # Escape name for html output
+       redef fun name do return super.html_escape
 end
 
 redef class MProperty
@@ -1116,203 +1166,366 @@ redef class MProperty
        redef type OTHER: MProperty
        redef fun <(other: OTHER): Bool do return self.name < other.name
 
-       var is_redef: Bool
-       var apropdef: nullable APropdef
-
-       redef init(intro_mclassdef: MClassDef, name: String, visibility: MVisibility)
-       do
-               super
-               is_redef = false
+       # Return the property namespace decorated with html
+       fun html_namespace(mbuilder: ModelBuilder): String do
+               return "{intro_mclassdef.mclass.html_namespace(mbuilder)}::<span>{intro.link(mbuilder)}</span>"
        end
 
-       fun local_class: MClass do
-               var classdef = self.intro_mclassdef
-               return classdef.mclass
+       # Escape name for html output
+       redef fun name do return super.html_escape
+end
+
+redef class MType
+       fun link(mbuilder: ModelBuilder): String is abstract
+end
+
+redef class MClassType
+       redef fun link(mbuilder) do return mclass.link(mbuilder)
+end
+
+redef class MNullableType
+       redef fun link(mbuilder) do return "nullable {mtype.link(mbuilder)}"
+end
+
+redef class MGenericType
+       redef fun link(mbuilder) do
+               var res = new Buffer
+               res.append("<a href='{mclass.url}'>{mclass.name}</a>[")
+               for i in [0..arguments.length[ do
+                       res.append(arguments[i].link(mbuilder))
+                       if i < arguments.length - 1 then res.append(", ")
+               end
+               res.append("]")
+               return res.to_s
        end
+end
 
-       fun anchor: String do
-               return "PROP_{c_name}"
+redef class MParameterType
+       redef fun link(mbuilder) do
+               var name = mclass.intro.parameter_names[rank]
+               return "<a href='{mclass.url}#FT_{name}' title='formal type'>{name}</a>"
        end
+end
 
-       # Escape name for html output
-       redef fun name do return super.html_escape
+redef class MVirtualType
+       redef fun link(mbuilder) do return mproperty.intro.link(mbuilder)
 end
 
-redef class MClass
+redef class MClassDef
+       # Return the classdef namespace decorated with html
+       fun html_namespace(mbuilder: ModelBuilder): String do
+               var res = new Buffer
+               res.append(mmodule.html_full_namespace(mbuilder))
+               res.append("::<span>{self.mclass.link(mbuilder)}</span>")
+               return res.to_s
+       end
+end
+
+redef class MPropDef
        super Comparable
-       redef type OTHER: MClass
-       redef fun <(other: OTHER): Bool do return self.name < other.name
+       redef type OTHER: MPropDef
+       redef fun <(other: OTHER): Bool do return self.mproperty.name < other.mproperty.name
 
-       # Add type parameters
-       fun html_signature: String do
-               if arity > 0 then
-                       return "{name}[{intro.parameter_names.join(", ")}]"
+       fun url: String do return "{mclassdef.mclass.url}#{anchor}"
+       fun anchor: String do return "PROP_{mclassdef.mclass.public_owner.name}_{c_name}"
+
+       # Return a link (html a tag) to the nitdoc class page
+       fun link(mbuilder: ModelBuilder): String do
+               if mbuilder.mpropdef2npropdef.has_key(self) then
+                       var nprop = mbuilder.mpropdef2npropdef[self]
+                       return "<a href=\"{url}\" title=\"{nprop.short_comment}\">{mproperty.name}</a>"
                else
-                       return name
+                       return "<a href=\"{url}\">{mproperty.name}</a>"
                end
        end
 
-       # Return a link (html a tag) to the nitdoc class page
-       fun link(aclass: AStdClassdef): String do
-               return "<a href='{name}.html' title=\"{aclass.short_comment}\">{html_signature}</a>"
-       end
-
-       # Associate all MMethods to each MModule concerns
-       fun all_methods: HashMap[MModule, Set[MMethod]] do
-               var hm = new HashMap[MModule, Set[MMethod]]
-               for mmodule, childs in concerns do
-                       if not hm.has_key(mmodule) then hm[mmodule] = new HashSet[MMethod]
-                       for prop in intro_methods do
-                               if mmodule == prop.intro_mclassdef.mmodule then
-                                       prop.is_redef = false
-                                       hm[mmodule].add(prop)
-                               end
-                       end
-                       for prop in redef_methods do
-                               if mmodule == prop.intro_mclassdef.mmodule then
-                                       prop.is_redef = true
-                                       hm[mmodule].add(prop)
-                               end
-                       end
-
-                       if childs != null then
-                               for child in childs do
-                                       if not hm.has_key(child) then hm[child] = new HashSet[MMethod]
-                                       for prop in intro_methods do
-                                               if child == prop.intro_mclassdef.mmodule then
-                                                       prop.is_redef = false
-                                                       hm[child].add(prop)
-                                               end
-                                       end
-                                       for prop in redef_methods do
-                                               if child == prop.intro_mclassdef.mmodule then
-                                                       prop.is_redef = true
-                                                       hm[child].add(prop)
-                                               end
-                                       end
-                               end
-                       end
+       # Return a list item for the mpropdef
+       fun html_list_item(mbuilder: ModelBuilder): String do
+               var res = new Buffer
+               if is_intro then
+                       res.append("<li class='intro'>")
+                       res.append("<span title='introduction'>I</span>&nbsp;{link(mbuilder)} ({mclassdef.mclass.link(mbuilder)})")
+                       res.append("</li>")
+               else
+                       res.append("<li class='redef'>")
+                       res.append("<span title='redefinition'>R</span>&nbsp;{link(mbuilder)} ({mclassdef.mclass.link(mbuilder)})")
+                       res.append("</li>")
                end
-               return hm
+               return res.to_s
        end
 
-       fun public_owner: MModule do
-               var owner = intro_mmodule
-               if owner.public_owner is null then
-                       return owner
+       # Return a list item for the mpropdef
+       fun html_sidebar_item(page: NitdocClass): String do
+               var res = new Buffer
+               if is_intro and mclassdef.mclass == page.mclass then
+                       res.append("<li class='intro'>")
+                       res.append("<span title='Introduced'>I</span>")
+               else if is_intro and mclassdef.mclass != page.mclass then
+                       res.append("<li class='inherit'>")
+                       res.append("<span title='Inherited'>H</span>")
                else
-                       return owner.public_owner.as(not null)
+                       res.append("<li class='redef'>")
+                       res.append("<span title='Redefined'>R</span>")
                end
+               res.append(link(page.mbuilder))
+               res.append("</li>")
+               return res.to_s
        end
 
-       # Associate MClass to all MMethod include in 'inherited_methods'
-       fun inherited: HashMap[MClass, Set[MMethod]] do
-               var hm = new HashMap[MClass, Set[MMethod]]
-               for method in inherited_methods do
-                       var mclass = method.intro_mclassdef.mclass
-                       if not hm.has_key(mclass) then hm[mclass] = new HashSet[MMethod]
-                       hm[mclass].add(method)
-               end
-               return hm
+       fun html_full_desc(page: NitdocClass): String is abstract
+       fun html_info(page: NitdocClass): String is abstract
+
+       fun full_name: String do
+               return "{mclassdef.mclass.public_owner.name}::{mclassdef.mclass.name}::{mproperty.name}"
        end
+end
 
-       # Return true if MModule concern contain subMModule
-       fun has_mmodule(sub: MModule): Bool do
-               for mmodule, childs in concerns do
-                       if childs is null then continue
-                       if childs.has(sub) then return true
+redef class MMethodDef
+       redef fun html_full_desc(page) do
+               if not page.mbuilder.mpropdef2npropdef.has_key(self) then
+                       return ""
+               end
+               var res = new Buffer
+               var mprop = mproperty
+               var nprop = page.mbuilder.mpropdef2npropdef[self]
+               var classes = new Array[String]
+               var is_redef = mprop.intro_mclassdef.mclass != page.mclass
+               classes.add("fun")
+               if mprop.is_init then classes.add("init")
+               if is_redef then classes.add("redef")
+               if mprop.visibility == none_visibility then
+                       classes.add("private")
+               else if mprop.visibility == protected_visibility then
+                       classes.add("protected")
+               else
+                       classes.add("public")
+               end
+               res.append("<article class='{classes.join(" ")}' id='{anchor}'>")
+               if nprop isa AAttrPropdef then
+                       if nprop.mreadpropdef == self then
+                               res.append("<h3 class='signature'>{mprop.name}: {nprop.html_signature(page.mbuilder)}</h3>")
+                       else
+                               res.append("<h3 class='signature'>{mprop.name}(value: {nprop.html_signature(page.mbuilder)})</h3>")
+                       end
+               else
+                       var intro_nprop = page.mbuilder.mpropdef2npropdef[mprop.intro]
+                       res.append("<h3 class='signature'>{mprop.name}{intro_nprop.html_signature(page.mbuilder)}</h3>")
+               end
+               res.append(html_info(page))
+               res.append("<div class='description'>")
+               if nprop.comment == "" then
+                       res.append("<a class=\"newComment\" title=\"32\" tag=\"\">New Comment</a>")
+               else
+                       res.append("<pre class=\"text_label\" title=\"\" name=\"\" tag=\"\" type=\"1\">{nprop.comment}</pre>")
+               end
+               res.append("<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>")
+               # definitions block
+               res.append("<p class='info'>")
+               page.nitdoc.mainmodule.linearize_mpropdefs(mprop.mpropdefs)
+               var previous_defs = new Array[MMethodDef]
+               var next_defs = new Array[MMethodDef]
+               var self_passed = false
+               for def in mprop.mpropdefs do
+                       if def == self then
+                               self_passed = true
+                               continue
+                       end
+                       if not self_passed then
+                               if not page.mclass.ancestors.has(def.mclassdef.mclass) then continue
+                               if def.is_intro then continue
+                               previous_defs.add(def)
+                       else
+                               if not page.mclass.descendants.has(def.mclassdef.mclass) then continue
+                               next_defs.add(def)
+                       end
+               end
+               res.append("defined by {mclassdef.mmodule.html_full_namespace(page.mbuilder)}")
+               if not is_intro then
+                       res.append(", introduced by {mprop.intro.mclassdef.mclass.link(page.mbuilder)}")
+               end
+               if not previous_defs.is_empty then
+                       res.append(", inherited from ")
+                       for i in [0..previous_defs.length[ do
+                                res.append(previous_defs[i].mclassdef.mclass.link(page.mbuilder))
+                                if i < previous_defs.length - 1 then res.append(", ")
+                       end
+               end
+               if not next_defs.is_empty then
+                       res.append(", redefined by ")
+                       for i in [0..next_defs.length[ do
+                                res.append(next_defs[i].mclassdef.mclass.link(page.mbuilder))
+                                if i < next_defs.length - 1 then res.append(", ")
+                       end
                end
-               return false
+               res.append(".</p>")
+               res.append("</div>")
+               res.append("</article>")
+               return res.to_s
        end
 
-       fun mmethod(mprop2npropdef: Map[MProperty, APropdef]) do
-               for const in constructors do
-                       if mprop2npropdef.has_key(const)then
-                               const.apropdef = mprop2npropdef[const].as(AMethPropdef)
-                       end
+       redef fun html_info(page) do
+               var res = new Buffer
+               res.append("<div class='info'>")
+               if mproperty.visibility <= none_visibility then
+                       res.append("private ")
+               else if mproperty.visibility <= protected_visibility then
+                       res.append("protected ")
+               end
+               if mproperty.intro_mclassdef.mclass != page.mclass then res.append("redef ")
+               res.append("fun {mproperty.html_namespace(page.mbuilder)}")
+               res.append("</div>")
+               res.append("<div style=\"float: right;\"><a id=\"lblDiffCommit\"></a></div>")
+               return res.to_s
+       end
+end
+
+redef class MVirtualTypeDef
+       redef fun html_full_desc(page) do
+               var res = new Buffer
+               var mprop = mproperty
+               var is_redef = mprop.intro_mclassdef.mclass != page.mclass
+               var classes = new Array[String]
+               classes.add("type")
+               if is_redef then classes.add("redef")
+               if mprop.visibility == none_visibility then
+                       classes.add("private")
+               else if mprop.visibility == protected_visibility then
+                       classes.add("protected")
+               else
+                       classes.add("public")
                end
+               res.append("<article class='{classes.join(" ")}' id='{anchor}'>")
+               res.append("<h3 class='signature'>{mprop.name}: {bound.link(page.mbuilder)}</h3>")
+               res.append(html_info(page))
+               res.append("<div class='description'>")
 
-               for intro in intro_methods do
-                       if mprop2npropdef.has_key(intro)then
-                               if mprop2npropdef[intro] isa AMethPropdef then intro.apropdef = mprop2npropdef[intro].as(AMethPropdef)
+               if page.mbuilder.mpropdef2npropdef.has_key(self) and page.mbuilder.mpropdef2npropdef[self].comment != "" then
+                       var nprop = page.mbuilder.mpropdef2npropdef[self]
+                       res.append("<pre class=\"text_label\" title=\"\" name=\"\" tag=\"\" type=\"1\">{nprop.comment}</pre>")
+               else
+                       res.append("<a class=\"newComment\" title=\"32\" tag=\"\">New Comment</a>")
+               end
+               res.append("<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>")
+               # definitions block
+               res.append("<p class='info'>")
+               page.nitdoc.mainmodule.linearize_mpropdefs(mprop.mpropdefs)
+               var previous_defs = new Array[MVirtualTypeDef]
+               var next_defs = new Array[MVirtualTypeDef]
+               var self_passed = false
+               for def in mprop.mpropdefs do
+                       if def == self then
+                               self_passed = true
+                               continue
+                       end
+                       if not self_passed then
+                               if not page.mclass.ancestors.has(def.mclassdef.mclass) then continue
+                               if def.is_intro then continue
+                               previous_defs.add(def)
+                       else
+                               if not page.mclass.descendants.has(def.mclassdef.mclass) then continue
+                               next_defs.add(def)
                        end
                end
-
-               for rd in redef_methods do
-                       if mprop2npropdef.has_key(rd)then
-                               if mprop2npropdef[rd] isa AMethPropdef then rd.apropdef = mprop2npropdef[rd].as(AMethPropdef)
+               res.append("defined by {mclassdef.mmodule.html_full_namespace(page.mbuilder)}")
+               if not is_intro then
+                       res.append(", introduced by {mprop.intro.mclassdef.mclass.link(page.mbuilder)}")
+               end
+               if not previous_defs.is_empty then
+                       res.append(", inherited from ")
+                       for i in [0..previous_defs.length[ do
+                                res.append(previous_defs[i].mclassdef.mclass.link(page.mbuilder))
+                                if i < previous_defs.length - 1 then res.append(", ")
+                       end
+               end
+               if not next_defs.is_empty then
+                       res.append(", redefined by ")
+                       for i in [0..next_defs.length[ do
+                                res.append(next_defs[i].mclassdef.mclass.link(page.mbuilder))
+                                if i < next_defs.length - 1 then res.append(", ")
                        end
                end
+               res.append(".</p>")
+               res.append("</div>")
+               res.append("</article>")
+               return res.to_s
        end
 
-       fun link_anchor: String do
-               return "{name}.html"
+       redef fun html_info(page) do
+               var res = new Buffer
+               res.append("<div class='info'>")
+               if mproperty.intro_mclassdef.mclass != page.mclass then res.append("redef ")
+               res.append("type {mproperty.html_namespace(page.mbuilder)}")
+               res.append("</div>")
+               res.append("<div style=\"float: right;\"><a id=\"lblDiffCommit\"></a></div>")
+               return res.to_s
        end
-
-       # Escape name for html output
-       redef fun name do return super.html_escape
 end
 
-redef class AStdClassdef
+#
+# Nodes redefs
+#
+
+redef class AModule
        private fun comment: String do
                var ret = new Buffer
-               if n_doc != null then
-                       for t in n_doc.n_comment do ret.append(t.text.substring_from(1))
+               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.append(t.text.substring_from(1))
                end
                return ret.to_s.html_escape
        end
 
        private fun short_comment: String do
                var ret = new Buffer
-               if n_doc != null then ret.append(n_doc.n_comment.first.text.substring_from(2).replace("\n", ""))
-               return ret.to_s.html_escape
-       end
-end
-
-redef class ASignature
-       redef fun to_s do
-               #TODO closures
-               var ret = ""
-               if not n_params.is_empty then
-                       ret = "{ret}({n_params.join(", ")})"
+               if n_moduledecl != null and n_moduledecl.n_doc != null then
+                       ret.append(n_moduledecl.n_doc.n_comment.first.text.substring_from(2).replace("\n", ""))
                end
-               if n_type != null and n_type.to_s != "" then ret += ": {n_type.to_s}"
-               return ret
+               return ret.to_s.html_escape
        end
 end
 
-redef class AParam
-       redef fun to_s do
-               var ret = "{n_id.text}"
-               if n_type != null then
-                       ret = "{ret}: {n_type.to_s}"
-                       if n_dotdotdot != null then ret = "{ret}..."
+redef class AStdClassdef
+       private fun comment: String do
+               var ret = new Buffer
+               if n_doc != null then
+                       for t in n_doc.n_comment do ret.append(t.text.substring_from(1))
                end
-               return ret
+               return ret.to_s.html_escape
        end
-end
 
-redef class AType
-       redef fun to_s do
-               var ret = "<a href=\"{n_id.text}.html\">{n_id.text}</a>"
-               if n_kwnullable != null then ret = "nullable {ret}"
-               if not n_types.is_empty then ret = "{ret}[{n_types.join(", ")}]"
-               return ret
+       private fun short_comment: String do
+               var ret = new Buffer
+               if n_doc != null then ret.append(n_doc.n_comment.first.text.substring_from(2).replace("\n", ""))
+               return ret.to_s.html_escape
        end
 end
 
 redef class APropdef
        private fun short_comment: String is abstract
-       private fun signature: String is abstract
+       private fun html_signature(mbuilder: ModelBuilder): String is abstract
        private fun comment: String is abstract
 end
 
 redef class AAttrPropdef
        redef fun short_comment do
                var ret = new Buffer
-               if n_doc != null then ret.append(n_doc.n_comment.first.text.substring_from(1))
+               if n_doc != null then ret.append(n_doc.n_comment.first.text.substring_from(2).replace("\n", ""))
                return ret.to_s.html_escape
        end
+
+       redef private fun comment: String do
+               var ret = new Buffer
+               if n_doc != null then
+                       for t in n_doc.n_comment do ret.append(t.text.substring_from(1))
+               end
+               return ret.to_s.html_escape
+       end
+
+       redef fun html_signature(mbuilder) do
+               if n_type != null then return n_type.mtype.link(mbuilder)
+               return ""
+       end
 end
 
 redef class AMethPropdef
@@ -1322,10 +1535,25 @@ redef class AMethPropdef
                return ret.to_s.html_escape
        end
 
-       redef fun signature: String do
-               var sign = ""
-               if n_signature != null then sign = "{n_signature.to_s}"
-               return sign
+       redef private fun comment: String do
+               var ret = new Buffer
+               if n_doc != null then
+                       for t in n_doc.n_comment do ret.append(t.text.substring_from(1))
+               end
+               return ret.to_s.html_escape
+       end
+
+       redef fun html_signature(mbuilder) do
+               if n_signature != null then return n_signature.to_html(mbuilder)
+               return ""
+       end
+end
+
+redef class ATypePropdef
+       redef fun short_comment do
+               var ret = new Buffer
+               if n_doc != null then ret.append(n_doc.n_comment.first.text.substring_from(2).replace("\n", ""))
+               return ret.to_s.html_escape
        end
 
        redef private fun comment: String do
@@ -1335,24 +1563,37 @@ redef class AMethPropdef
                end
                return ret.to_s.html_escape
        end
-end
 
-redef class MClassDef
-       private fun namespace(mclass: MClass): String do
+       redef fun html_signature(mbuilder) do
+               return mpropdef.bound.link(mbuilder)
+       end
+end
 
-               if mmodule.public_owner is null then
-                       return "{mmodule.full_name}::{mclass.name}"
-               else if mclass is self.mclass then
-                       return "{mmodule.public_owner.name}::{mclass.name}"
-               else
-                       return "{mmodule.public_owner.name}::<a href=\"{mclass.name}.html\">{mclass.name}</a>"
+redef class ASignature
+       fun to_html(mbuilder: ModelBuilder): String do
+               #TODO closures
+               var res = new Buffer
+               if not n_params.is_empty then
+                       res.append("(")
+                       for i in [0..n_params.length[ do
+                               res.append(n_params[i].to_html(mbuilder))
+                               if i < n_params.length - 1 then res.append(", ")
+                       end
+                       res.append(")")
                end
+               if n_type != null and n_type.mtype.link(mbuilder) != "" then res.append(": {n_type.mtype.link(mbuilder)}")
+               return res.to_s
        end
 end
 
-redef class Set[E]
-       fun last: E do
-               return to_a[length-1]
+redef class AParam
+       fun to_html(mbuilder: ModelBuilder): String do
+               var ret = "{n_id.text}"
+               if n_type != null then
+                       ret = "{ret}: {n_type.mtype.link(mbuilder)}"
+                       if n_dotdotdot != null then ret = "{ret}..."
+               end
+               return ret
        end
 end