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("]")
redef fun body do
header
+ open("div").add_class("page")
content
+ close("div")
footer
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
self.mbuilder = mbuilder
self.opt_nodot = opt_nodot
self.destinationdir = destination
+ # 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
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(" ")
- add_html(amodule.short_comment)
+ add_html("{mmodule.link(amodule)} {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
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
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
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.name}")
+ add("div").add_class("subtitle")
+ add_html("module {mmodule.namespace(mbuilder)}")
module_comment
#process_generate_dot
classes
properties
close("div")
- close("div")
end
# Insert module comment in the content
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
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")
open("li").add_class("redef")
add("span").attr("title", "redefinition").text("R")
end
- add_html(" ")
- add("a").attr("href", "{p.mclassdef.mclass.name}.html").attr("title", "").text("{p.mproperty.name} ({p.mclassdef.mclass.name})")
+ add_html(" {p.link(nprop)} ({p.mclassdef.mclass.name})")
close("li")
end
close("ul")
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
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
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
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
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
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
add("h1").text(mclass.to_s)
open("div").add_class("subtitle")
if mclass.visibility is none_visibility then subtitle += "private "
- var nowner = mbuilder.mmodule2nmodule[mclass.public_owner]
- subtitle += "{mclass.kind} {mclass.public_owner.link(nowner)}::{mclass}"
+ subtitle += "{mclass.kind} {mclass.public_owner.namespace(mbuilder)}::{mclass}"
add_html(subtitle)
close("div")
add_html("<div style=\"float: right;\"><a id=\"lblDiffCommit\"></a></div>")
end
close("section")
end
- # Insert constructors if there is almost one
+ # constructors
if mclass.constructors.length > 0 then
var sortedc = mclass.constructors.to_a
sorterprop.sort(sortedc)
for prop in sortedc do description(prop)
close("section")
end
+ # methods
open("section").add_class("methods")
add("h2").add_class("section-header").text("Methods")
for mmodule, mmethods in mclass.all_methods do
sorterprop.sort(sortedc)
for prop in sortedc do description(prop)
end
- # Insert inherited methods
+ # inherited methods
if mclass.inherited_methods.length > 0 then
var sortedc = new Array[MClass]
sortedc.add_all(mclass.inherited.keys)
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")
close("section")
end
- # Insert description tags for 'prop'
fun description(prop: MProperty) do
- open("article").add_class("fun public {if prop.is_redef then "redef" else ""}").attr("id", "{prop.anchor}")
+ 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
+ open("article").add_classes(classes).attr("id", "{prop.anchor}")
var sign = prop.name
- if prop.apropdef != null then sign += prop.apropdef.signature
- add_html("<h3 class=\"signature\">{sign}</h3>")
- add_html("<div class=\"info\">{if prop.is_redef then "redef" else ""} fun {prop.intro_mclassdef.namespace(mclass)}::{prop.name}</div><div style=\"float: right;\"><a id=\"lblDiffCommit\"></a></div>")
-
+ open("h3").add_class("signature")
+ add_html("{prop.name}{nprop.signature}")
+ close("h3")
+ open("div").add_class("info")
+ add_html("{if prop.is_redef then "redef" else ""} fun {prop.intro_mclassdef.namespace(mclass)}::{prop.name}</div><div style=\"float: right;\"><a id=\"lblDiffCommit\"></a>")
+ close("div")
open("div").add_class("description")
- if prop.apropdef is null or prop.apropdef.comment == "" then
+ if nprop.comment == "" then
add_html("<a class=\"newComment\" title=\"32\" tag=\"\">New Comment</a>")
else
- add_html("<pre class=\"text_label\" title=\"\" name=\"\" tag=\"\" type=\"1\">{prop.apropdef.comment}</pre>")
+ add_html("<pre class=\"text_label\" title=\"\" name=\"\" tag=\"\" type=\"1\">{nprop.comment}</pre>")
end
add_html("<textarea id=\"fileContent\" class=\"edit\" cols=\"76\" rows=\"1\" style=\"display: none;\"></textarea><a id=\"cancelBtn\" style=\"display: none;\">Cancel</a><a id=\"commitBtn\" style=\"display: none;\">Commit</a><pre id=\"preSave\" class=\"text_label\" type=\"2\"></pre>")
open("p")
fun link(amodule: AModule): String do
return "<a href=\"{name}.html\" title=\"{amodule.short_comment}\">{name}</a>"
end
+
+ # Return the module namespace decorated with html
+ fun namespace(mbuilder: ModelBuilder): String do
+ var str = new Buffer
+ var mowner = public_owner
+ if mowner != null then
+ var nowner = mbuilder.mmodule2nmodule[mowner]
+ str.append(public_owner.link(nowner))
+ end
+ var nmodule = mbuilder.mmodule2nmodule[self]
+ str.append(self.link(nmodule))
+ return str.to_s
+ end
end
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
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
if not n_params.is_empty then
ret = "{ret}({n_params.join(", ")})"
end
- if n_type != null and n_type.to_s != "" then ret += " {n_type.to_s}"
+ if n_type != null and n_type.to_s != "" then ret += ": {n_type.to_s}"
return ret
end
end
redef class AMethPropdef
redef fun short_comment do
- var ret = ""
+ var ret = new Buffer
if n_doc != null then
var txt = n_doc.n_comment.first.text
txt = txt.replace("# ", "")
txt = txt.replace("\n", "")
- ret += txt
+ ret.append(txt)
end
- return ret
+ return ret.to_s
end
redef fun signature: String do
var sign = ""
- if n_signature != null then sign = " {n_signature.to_s}"
+ if n_signature != null then sign = "{n_signature.to_s}"
return sign
end
redef private fun comment: String do
- var ret = ""
+ var ret = new Buffer
if n_doc != null then
for t in n_doc.n_comment do
var txt = t.text.replace("# ", "")
txt = txt.replace("#", "")
- ret += "{txt}"
+ ret.append(txt)
end
end
- return ret
+ return ret.to_s
end
end