")
@@ -179,7 +181,7 @@ class DocContext
end
end
op.append("\}\n")
- self.gen_dot(op.to_s, "dep")
+ self.gen_dot(op.to_s, "dep", "Modules hierarchy")
add("
")
add("")
add("
")
@@ -192,7 +194,9 @@ class DocContext
assert mod isa MMSrcModule
if not mod.require_doc(self) then continue
self.filename = mod.html_name
+ action_bar = "\n"
clear
+ add("")
add("{head}Module {mod.name}\n")
add(action_bar)
add("
")
@@ -206,7 +210,9 @@ class DocContext
for c in mainmod.local_classes do
if not c.require_doc(self) then continue
self.filename = c.html_name
+ action_bar = "\n"
clear
+ add("")
add("{head}Class {c.name}\n")
add(action_bar)
add("
")
@@ -235,11 +243,11 @@ class DocContext
do
var s = opt_source.value
if s == null then
- add("in #{l.file.filename}")
+ add("in #{l.file.filename.simplify_path}")
else
# THIS IS JUST UGLY ! (but there is no replace yet)
var x = s.split_with("%f")
- s = x.join(l.file.filename)
+ s = x.join(l.file.filename.simplify_path)
x = s.split_with("%l")
s = x.join(l.line_start.to_s)
x = s.split_with("%L")
@@ -251,13 +259,13 @@ class DocContext
# Generate a clicable graphiz image using a dot content.
# `name' refer to the filename (without extension) and the id name of the map.
# `name' must also match the name of the graph in the dot content (eg. digraph NAME {...)
- fun gen_dot(dot: String, name: String)
+ fun gen_dot(dot: String, name: String, alt: String)
do
var f = new OFStream.open("{self.dir}/{name}.dot")
f.write(dot)
f.close
sys.system("\{ test -f {self.dir}/{name}.png && test -f {self.dir}/{name}.s.dot && diff {self.dir}/{name}.dot {self.dir}/{name}.s.dot >/dev/null 2>&1 ; \} || \{ cp {self.dir}/{name}.dot {self.dir}/{name}.s.dot && dot -Tpng -o{self.dir}/{name}.png -Tcmapx -o{self.dir}/{name}.map {self.dir}/{name}.s.dot ; \}")
- self.add("
")
+ self.add("")
var fmap = new IFStream.open("{self.dir}/{name}.map")
self.add(fmap.read_all)
fmap.close
@@ -290,6 +298,42 @@ class DocContext
end
end
+redef class String
+ # Replace all occurence of pattern ith string
+ fun replace(p: Pattern, string: String): String
+ do
+ return self.split_with(p).join(string)
+ end
+
+ # Escape the following characters < > & and " with their html counterpart
+ fun html_escape: String
+ do
+ var ret = self
+ if ret.has('&') then ret = ret.replace('&', "&")
+ if ret.has('<') then ret = ret.replace('<', "<")
+ if ret.has('>') then ret = ret.replace('>', ">")
+ if ret.has('"') then ret = ret.replace('"', """)
+ return ret
+ end
+
+ # Remove "/./", "//" and "bla/../"
+ fun simplify_path: String
+ do
+ var a = self.split_with("/")
+ var a2 = new Array[String]
+ for x in a do
+ if x == "." then continue
+ if x == "" and not a2.is_empty then continue
+ if x == ".." and not a2.is_empty then
+ a2.pop
+ continue
+ end
+ a2.push(x)
+ end
+ return a2.join("/")
+ end
+end
+
# A virtual module is used to work as an implicit main module that combine unrelated modules
# Since conflict may arrise in a virtual module (the main method for instance) conflicts are disabled
class MMVirtualModule
@@ -375,7 +419,7 @@ end
redef class MMModule
super MMEntity
redef fun html_link(dctx) do
- return "{self}"
+ return "{self}"
end
fun require_doc(dctx: DocContext): Bool
@@ -552,7 +596,7 @@ redef class MMModule
end
end
op.append("\}\n")
- dctx.gen_dot(op.to_s, name.to_s)
+ dctx.gen_dot(op.to_s, name.to_s, "Dependency graph for module {name}")
dctx.add("")
var clas = new Array[MMLocalClass]
@@ -622,7 +666,7 @@ redef class MMModule
var lpi = self[gp.intro.local_class.global][gp]
if lps.has(lpi) then
- dctx.add("
R {lp.html_open_link(dctx)}{lp} ({lp.local_class})
\n")
end
end
end
@@ -731,16 +773,34 @@ redef class MMLocalProperty
return "PROP_{local_class}_{cmangle(name)}"
end
+ fun html_open_link(dctx: DocContext): String
+ do
+ if not require_doc(dctx) then print "not required {self}"
+ var title = "{name}{signature.to_s}"
+ if short_doc != " " then
+ title += " #{short_doc}"
+ end
+ return ""
+ end
+
redef fun html_link(dctx)
do
if not require_doc(dctx) then print "not required {self}"
- return "{self}"
+ var title = "{name}{signature.to_s}"
+ if short_doc != " " then
+ title += " #{short_doc}"
+ end
+ return "{self}"
end
fun html_link_special(dctx: DocContext, lc: MMLocalClass): String
do
if not require_doc(dctx) then print "not required {self}"
- return "{self}"
+ var title = "{name}{signature_for(lc.get_type)}"
+ if short_doc != " " then
+ title += " #{short_doc}"
+ end
+ return "{self}"
end
# Kind of property (fun, attr, etc.)
@@ -956,6 +1016,42 @@ redef class MMTypeProperty
redef fun kind do return "type"
end
+redef class Symbol
+ # Replace < and > with html entities
+ redef fun to_s
+ do
+ var ret = super.to_s
+
+ if(ret.has('<')) then
+ var parts = ret.split_with("<")
+ ret = ""
+
+ for i in [0..parts.length[ do
+ ret += parts[i]
+
+ if(i < parts.length - 1) then
+ ret += "<"
+ end
+ end
+ end
+
+ if(ret.has('>')) then
+ var parts = ret.split_with(">")
+ ret = ""
+
+ for i in [0..parts.length[ do
+ ret += parts[i]
+
+ if(i < parts.length - 1) then
+ ret += ">"
+ end
+ end
+ end
+
+ return ret
+ end
+end
+
redef class MMSrcModule
redef fun short_doc
do
@@ -994,13 +1090,13 @@ redef class ADoc
for c in n_comment do
res.append(c.text.substring_from(1))
end
- return res.to_s
+ return res.to_s.html_escape
end
# Oneliner transcription of the doc
fun short: String
do
- return n_comment.first.text.substring_from(1)
+ return n_comment.first.text.substring_from(1).html_escape
end
end
@@ -1015,7 +1111,7 @@ redef class MMLocalClass
redef fun html_link(dctx)
do
if not require_doc(dctx) then print "{dctx.filename}: not required {self}"
- return "{self}"
+ return "{self}"
end
redef fun short_doc do return global.intro.short_doc
@@ -1133,7 +1229,7 @@ redef class MMLocalClass
dctx.add("