+ append("<li><a href='index.html'>Overview</a></li>")
+ var public_owner = mclass.public_owner
+ if public_owner is null then
+ append("<li>")
+ mclass.intro_mmodule.html_link(self)
+ append("</li>")
+ else
+ append("<li>")
+ public_owner.html_link(self)
+ append("</li>")
+ end
+ append("<li class='current'>{mclass.name}</li>")
+ append("<li><a href='full-index.html'>Full Index</a></li>")
+ end
+
+ redef fun content do
+ append("<div class='menu'>")
+ properties_column
+ inheritance_column
+ append("</div>")
+ append("<div class='content'>")
+ class_doc
+ append("</div>")
+ end
+
+ private fun properties_column do
+ var sorter = new MPropDefNameSorter
+ append("<nav class='properties filterable'>")
+ append("<h3>Properties</h3>")
+ # virtual types
+ if vtypes.length > 0 then
+ var vts = new Array[MVirtualTypeDef]
+ vts.add_all(vtypes)
+ sorter.sort(vts)
+ append("<h4>Virtual Types</h4>")
+ append("<ul>")
+ for mprop in vts do
+ 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>")
+ append("<ul>")
+ for mprop in cts do
+ if mprop.mproperty.name == "init" and mprop.mclassdef.mclass != mclass then continue
+ 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>")
+ append("<ul>")
+ for mprop in mts do
+ if mclass.name != "Object" and mprop.mproperty.intro_mclassdef.mclass.name == "Object" and mprop.mproperty.visibility <= protected_visibility then continue
+ mprop.html_sidebar_item(self)
+ end
+ append("</ul>")
+ end
+ append("</nav>")
+ end
+
+ private fun inheritance_column do
+ var sorted = new Array[MClass]
+ var sorterp = new MClassNameSorter
+ append("<nav>")
+ append("<h3>Inheritance</h3>")
+ var greaters = mclass.in_hierarchy(ctx.mainmodule).greaters.to_a
+ if greaters.length > 1 then
+ ctx.mainmodule.linearize_mclasses(greaters)
+ append("<h4>Superclasses</h4>")
+ append("<ul>")
+ for sup in greaters do
+ if sup == mclass then continue
+ append("<li>")
+ sup.html_link(self)
+ append("</li>")
+ end
+ append("</ul>")
+ end
+ var smallers = mclass.in_hierarchy(ctx.mainmodule).smallers.to_a
+ var direct_smallers = mclass.in_hierarchy(ctx.mainmodule).direct_smallers.to_a
+ if smallers.length <= 1 then
+ append("<h4>No Known Subclasses</h4>")
+ else if smallers.length <= 100 then
+ ctx.mainmodule.linearize_mclasses(smallers)
+ append("<h4>Subclasses</h4>")
+ append("<ul>")
+ for sub in smallers do
+ if sub == mclass then continue
+ append("<li>")
+ sub.html_link(self)
+ append("</li>")
+ end
+ append("</ul>")
+ else if direct_smallers.length <= 100 then
+ ctx.mainmodule.linearize_mclasses(direct_smallers)
+ append("<h4>Direct Subclasses Only</h4>")
+ append("<ul>")
+ for sub in direct_smallers do
+ if sub == mclass then continue
+ append("<li>")
+ sub.html_link(self)
+ append("</li>")
+ end
+ append("</ul>")
+ else
+ append("<h4>Too much Subclasses to list</h4>")
+ end
+ append("</nav>")
+ end
+
+ private fun class_doc do
+ # title
+ append("<h1>{mclass.signature}</h1>")
+ append("<div class='subtitle info'>")
+ mclass.html_full_signature(self)
+ append("</div>")
+ # comment
+ var nclass = ctx.mbuilder.mclassdef2nclassdef[mclass.intro]
+ append("<div style=\"float: right;\"><a id=\"lblDiffCommit\"></a></div>")
+ append("<section class='description'>")
+ if nclass isa AStdClassdef and not nclass.full_comment.is_empty then append("<pre class=\"text_label\" title=\"122\" name=\"\" tag=\"{mclass.mclassdefs.first.location.to_s}\" type=\"2\">{nclass.full_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
+ append("</section>")
+ # concerns
+ var concern2meths = new ArrayMap[MModule, Array[MMethodDef]]
+ var sorted_meths = new Array[MMethodDef]
+ var sorted = new Array[MModule]
+ sorted_meths.add_all(meths)
+ ctx.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, mmodules in sections do
+ var nowner = ctx.mbuilder.mmodule2nmodule[owner]
+ append("<li>")
+ 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>")
+ for mmodule in mmodules do
+ var nmodule = ctx.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
+ append("</li>")
+ end
+ append("</ul>")
+ append("</section>")
+ # properties
+ var prop_sorter = new MPropDefNameSorter
+ var lmmodule = new List[MModule]
+ # virtual and formal types
+ 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>")
+ # formal types
+ if mclass.arity > 0 and nclass isa AStdClassdef then
+ for ft, bound in mclass.parameter_types do
+ append("<article id='FT_{ft}'>")
+ append("<h3 class='signature'>{ft}: ")
+ bound.html_link(self)
+ append("</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 prop.html_full_desc(self)
+ append("</section>")
+ end
+ # constructors
+ 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 local_consts do prop.html_full_desc(self)
+ append("</section>")
+ end
+ # methods
+ 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 = ctx.mbuilder.mmodule2nmodule[owner]
+ append("<h3 class=\"concern-toplevel\">Methods refined in ")
+ owner.html_link(self)
+ append("</h3>")
+ append("<p class=\"concern-doc\">")
+ owner.html_link(self)
+ if not nowner.short_comment.is_empty then
+ append(": {nowner.short_comment}")
+ end
+ append("</p>")
+ end
+ if concern2meths.has_key(owner) then
+ var mmethods = concern2meths[owner]
+ prop_sorter.sort(mmethods)
+ for prop in mmethods do prop.html_full_desc(self)
+ end
+ for mmodule in mmodules do
+ append("<a id=\"{mmodule.anchor}\"></a>")
+ var nmodule = ctx.mbuilder.mmodule2nmodule[mmodule]
+ if mmodule != mclass.intro_mmodule and mmodule != mclass.public_owner then
+ append("<p class=\"concern-doc\">")
+ mmodule.html_link(self)
+ if not nmodule.short_comment.is_empty then
+ append(": {nmodule.short_comment}")
+ end
+ append("</p>")
+ end
+ var mmethods = concern2meths[mmodule]
+ prop_sorter.sort(mmethods)
+ for prop in mmethods do 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)
+ ctx.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
+ append("<h3>Inherited Properties</h3>")
+ for c, mmethods in classes do
+ prop_sorter.sort(mmethods)
+ append("<p>Defined in ")
+ c.html_link(self)
+ append(": ")
+ for i in [0..mmethods.length[ do
+ var mmethod = mmethods[i]
+ mmethod.html_link(self)
+ if i <= mmethods.length - 1 then append(", ")
+ end
+ append("</p>")
+ end
+ end
+ append("</section>")
+ end
+
+ private fun process_generate_dot do
+ var pe = ctx.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.url}\"];\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
+
+#
+# Model redefs
+#
+
+redef class MModule
+ # URL to nitdoc page
+ fun url: String do
+ if url_cache == null then
+ 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")
+ url_cache = res.to_s
+ end
+ return url_cache.as(not null)
+ end
+ private var url_cache: nullable String
+
+ # html anchor id to the module in a nitdoc page
+ fun anchor: String do
+ if anchor_cache == null then
+ 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)
+ anchor_cache = res.to_s
+ end
+ return anchor_cache.as(not null)
+ end
+ private var anchor_cache: nullable String
+
+ # Return a link (html a tag) to the nitdoc module page
+ fun html_link(page: NitdocPage) do
+ if html_link_cache == null then
+ var res = new Buffer
+ if page.ctx.mbuilder.mmodule2nmodule.has_key(self) then
+ res.append("<a href='{url}' title='{page.ctx.mbuilder.mmodule2nmodule[self].short_comment}'>{name}</a>")
+ else
+ res.append("<a href='{url}'>{name}</a>")
+ end
+ html_link_cache = res.to_s
+ end
+ page.append(html_link_cache.as(not null))
+ end
+ private var html_link_cache: nullable String
+
+ # Return the module signature decorated with html
+ fun html_signature(page: NitdocPage) do
+ page.append("<span>module ")
+ html_full_namespace(page)
+ page.append("</span>")
+ end
+
+ # Return the module full namespace decorated with html
+ fun html_full_namespace(page: NitdocPage) do
+ page.append("<span>")
+ var mowner = public_owner
+ if mowner != null then
+ public_owner.html_namespace(page)
+ page.append("::")
+ end
+ html_link(page)
+ page.append("</span>")