- var doc = doc
- if doc != null then
- dctx.add("<pre>{doc.to_html}</pre>\n")
- end
-
- var details = new Array[Array[MMLocalProperty]]
- for i in [0..4[ do details.add(property_summary(dctx, i))
- for i in [0..4[ do property_detail(dctx, i, details[i])
-
- dctx.add("</blockquote><hr/>\n")
- end
-
- fun pass_name(pass: Int): String
- do
- var names = once ["Virtual Types", "Consructors", "Methods", "Attributes"]
- return names[pass]
- end
-
- fun accept_prop(p: MMLocalProperty, pass: Int): Bool
- do
- if pass == 0 then
- return p isa MMTypeProperty
- else if pass == 1 then
- return p.global.is_init
- else if pass == 2 then
- return p isa MMMethod and not p.global.is_init
- else if pass == 3 then
- return p isa MMAttribute
- end
- abort
- end
-
- fun property_summary(dctx: DocContext, pass: Int): Array[MMLocalProperty]
- do
- var passname = pass_name(pass)
- dctx.open_stage
- dctx.stage("<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n")
- dctx.stage("<tr bgcolor=\"#CCCCFF\"><th colspan=\"2\">{passname} Summary of {self}</th></tr>\n")
-
- var new_props = new Array[MMLocalProperty]
- for g in global_properties do
- if not accept_prop(g.intro, pass) then continue
- if mmmodule.visibility_for(g.intro.mmmodule) < g.visibility_level then continue
- var p = self[g]
- if p.local_class != self or not p.need_doc(dctx) then
- var cla = new Array[MMLocalClass]
- for m in dctx.owned_modules do
- if not m.global_classes.has(global) then continue
- var c = m[global]
- if not c isa MMConcreteClass then continue
- if not c.has_global_property(g) then continue
- var p2 = c[g]
- if p2.local_class != c or not p2.need_doc(dctx) then continue
- cla.add(c)
- end
- if cla.is_empty then continue
- cla = crhe.order.select_smallests(cla)
- end
-
- new_props.add(p)
- if p.global.intro == p then
- dctx.register(p)
- end
- end
- dctx.sort(new_props)
- for p in new_props do
- dctx.add("<tr><td width=\"20%\" align=\"right\">{p.prototype_head(dctx)}</td><td><b>{p.html_link(dctx)}</b>{p.prototype_body(dctx)}<br/> {p.short_doc}</td></tr>\n")
- end
- dctx.stage("</table><br/>\n")
-
- dctx.open_stage
- dctx.stage("<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n")
- if pass != 1 then
- # skip pass 1 because constructors are not inherited
- var cmap = new HashMap[MMLocalClass, Array[MMLocalProperty]]
- var mmap = new HashMap[MMModule, Array[MMLocalProperty]]
- for c in che.greaters do
- if c isa MMSrcLocalClass then
- var km = dctx.known_owner_of(c.mmmodule)
- var kc = km[c.global]
- if kc == self then continue
- var props: Array[MMLocalProperty]
- if km == mmmodule then
- if cmap.has_key(kc) then
- props = cmap[kc]
- else
- props = new Array[MMLocalProperty]
- cmap[kc] = props
- end
- else
- if mmap.has_key(km) then
- props = mmap[km]
- else
- props = new Array[MMLocalProperty]
- mmap[km] = props
- end
- end
- for g in c.global_properties do
- var p = c[g]
- if p.local_class == c and p.need_doc(dctx) and accept_prop(p, pass) then
- props.add(kc[g])
- end
- end
- end
- end
- dctx.open_stage
- dctx.stage("<tr bgcolor=\"#EEEEFF\"><th colspan=\"2\"><small>Inherited {passname}</small></th><tr>\n")
- for c in cshe.linear_extension do
- if not cmap.has_key(c) then continue
- var props = cmap[c]
- if props.is_empty then continue
- dctx.sort(props)
- var properties = new Array[String]
- for p in props do properties.add(p.html_link(dctx))
- dctx.add("<tr><td width=\"20%\"><small>from {c.html_link(dctx)}</small></td><td><small>{properties.join(", ")}</small></td><tr>\n")
- end
- dctx.close_stage
-
- dctx.open_stage
- dctx.stage("<tr bgcolor=\"#EEEEFF\"><th colspan=\"2\"><small>Imported {passname}</small></th><tr>\n")
- for m in mmmodule.mhe.linear_extension do
- if not mmap.has_key(m) then continue
- var props = mmap[m]
- if props.is_empty then continue
- dctx.sort(props)
- var properties = new Array[String]
- for p in props do properties.add(p.html_link(dctx))
- dctx.add("<tr><td width=\"20%\"><small>from {m.html_link(dctx)}</small></td><td><small>{properties.join(", ")}</small></td><tr>\n")
- end
- dctx.close_stage
- end
-
- var mmap = new HashMap[MMModule, Array[MMLocalProperty]]
- for c in crhe.order do
- if mmmodule.mhe <= c.mmmodule or dctx.owned_modules.has(c.mmmodule) or not c isa MMSrcLocalClass then continue
- var km = dctx.known_owner_of(c.mmmodule)
- if mmmodule.mhe <= km then continue
- var kc = km[c.global]
- var props: Array[MMLocalProperty]
- if mmap.has_key(km) then
- props = mmap[km]
- else
- props = new Array[MMLocalProperty]
- mmap[km] = props
- end
- for g in c.global_properties do
- var p = c[g]
- if p.local_class == c and p.need_doc(dctx) and accept_prop(p, pass) then
- var kp = kc[g]
- if not props.has(kp) then props.add(kp)
- end
- end
- # c.properties_inherited_from(dctx, self, pass)
- end
- dctx.open_stage
- dctx.stage("<tr bgcolor=\"#EEEEFF\"><th colspan=\"2\"><small>Added {passname} in known modules</small></th><tr>\n")
- for c in crhe.order do
- var m = c.mmmodule
- if not mmap.has_key(m) then continue
- var props = mmap[m]
- if props.is_empty then continue
- dctx.sort(props)
- var properties = new Array[String]
- for p in props do properties.add(p.html_link(dctx))
- dctx.add("<tr><td width=\"20%\"><small>in {m.html_link(dctx)}</small></td><td><small>{properties.join(", ")}</small></td><tr>\n")
- end
- dctx.close_stage
- dctx.stage("</table><br/><br/>\n")
- dctx.close_stage
-
- dctx.close_stage
- return new_props
- end
-
- fun property_detail(dctx: DocContext, pass: Int, new_props: Array[MMLocalProperty])
- do
- var passname = pass_name(pass)
- dctx.open_stage
- dctx.stage("<table border=\"1\" width=\"100%\" cellpadding=\"3\" cellspacing=\"0\">\n")
- dctx.stage("<tr bgcolor=\"#CCCCFF\"><th>{passname} Detail of {self}</th><tr>\n")
- dctx.stage("</table>\n")
-
- dctx.open_stage
- for p in new_props do
- dctx.add("<a name=\"{p.html_anchor}\"></a><h3>{p}</h3><p><small>{p.mmmodule.html_link(dctx)}::{p.local_class.html_link(dctx)}::</small><br/>{p.prototype_head(dctx)} <b>{p.name}</b>{p.prototype_body(dctx)}</p>\n")
- dctx.add("<blockquote>")
- var doc = p.doc
- if doc != null then
- dctx.add("<pre>{doc.to_html}</pre>\n")
- end
- dctx.stage("</blockquote>\n")
- dctx.close_stage
-
- dctx.open_stage
- dctx.stage("<hr/>\n")
- end
- dctx.close_stage
-
- dctx.close_stage
- end
-
- # Add rows for properties inheriterd to some heirs
- fun properties_inherited_from(dctx: DocContext, heir: MMLocalClass, pass: Int)
- do
- var properties = new Array[String]
- for g in global_properties do
- var p = self[g]
- if p.local_class == self and p.need_doc(dctx) and accept_prop(p, pass) then
- properties.add(p.html_link(dctx))
- end
- end
- if not properties.is_empty then
- var s: String
- if heir.global == global then
- s = mmmodule.html_link(dctx)
- else
- s = self.html_link(dctx)
- end
- dctx.add("<tr><td width=\"20%\"><small>in {s}</small></td><td><small>{properties.join(", ")}</small></td><tr>\n")
- end
- end
-end
-
-redef class MMSrcLocalClass
- redef fun short_doc
- do
- var d = doc
- if d != null then
- return d.short
- else if global.intro == self then
- return " "
- else
- var bc = global.intro
- return bc.short_doc
- end
- end
-
- redef fun doc
- do
- var n = node
- if not n isa AStdClassdef then
- return null
- end
- var d = n.n_doc
- if d == null then
- return null
- end
- if d.n_comment.is_empty then
- return null
- else
- return d
- end
- end
-
- redef fun need_doc(dctx)
- do
- if global.visibility_level >= 3 then
- if not dctx.intrude_mode then return false
- if dctx.mmmodule.visibility_for(mmmodule) == 0 then return false
- end
- if global.intro == self then
- return true
- end
- for p in src_local_properties do
- if p.need_doc(dctx) then
- return true
- end
- end
- return super
- end
-end
-
-redef class MMSignature
- # Htlm transcription of the signature (with nested links)
- fun to_html(dctx: DocContext, with_closure: Bool): String
- do
- var res = new Buffer
- if arity > 0 then
- res.append("(")
- res.append(self[0].html_link(dctx))
- for i in [1..arity[ do
- res.append(", ")
- res.append(self[i].html_link(dctx))
- end
- res.append(")")
- end
- if return_type != null then
- res.append(": ")
- res.append(return_type.html_link(dctx))
- end
- if with_closure then
- for c in closures do
- res.append(" ")
- if c.is_optional then res.append("[")
- if c.is_break then res.append("break ")
- res.append("!{c.name}")
- res.append(c.signature.to_html(dctx, false))
- if c.is_optional then res.append("]")
- end
- end
- return res.to_s
- end
-end
-
-redef class MMType
- # Htlm transcription of the type (with nested links)
- fun html_link(dctx: DocContext): String do return to_s
-end
-
-redef class MMTypeSimpleClass
- redef fun html_link(dctx) do return local_class.html_link(dctx)
-end
-
-redef class MMTypeGeneric
- redef fun html_link(dctx)
- do
- var res = new Buffer
- res.append(local_class.html_link(dctx))
- res.append("[")
- res.append(params[0].html_link(dctx))
- for i in [1..params.length[ do
- res.append(", ")
- res.append(params[i].html_link(dctx))
- end
- res.append("]")
- return res.to_s
- end
-end