X-Git-Url: http://nitlanguage.org diff --git a/src/nitdoc.nit b/src/nitdoc.nit index 2bfb3ad..437f837 100644 --- a/src/nitdoc.nit +++ b/src/nitdoc.nit @@ -24,40 +24,40 @@ import abstracttool # Store knowledge and facilities to generate files class DocContext -special AbstractCompiler + super AbstractCompiler # Destination directory - readable writable attr _dir: String + readable writable var _dir: String = "." # Content of a generated file - attr _stage_context: StageContext = new StageContext(null) + var _stage_context: StageContext = new StageContext(null) # Add a string in the content - meth add(s: String) do + fun add(s: String) do _stage_context.content.add(s) _stage_context.validate = true end # Add a string in the content iff some other string are added - meth stage(s: String) do _stage_context.content.add(s) + fun stage(s: String) do _stage_context.content.add(s) # Create a new stage in the content - meth open_stage do _stage_context = new StageContext(_stage_context) + fun open_stage do _stage_context = new StageContext(_stage_context) # Close the current stage in the content - meth close_stage + fun close_stage do var s = _stage_context.parent if _stage_context.validate then s.content.add_all(_stage_context.content) s.validate = true end + assert s != null _stage_context = s end # Write the content to a new file - meth write_to(filename: String) + fun write_to(filename: String) do - print "Generate {filename}" var f = new OFStream.open(filename) for s in _stage_context.content do f.write(s) @@ -65,37 +65,38 @@ special AbstractCompiler f.close end - # Currently computed module - readable attr _module: MMSrcModule + # Currently computed mmmodule + readable var _mmmodule: nullable MMSrcModule # Is the current directory module computed as a simple modude ? - readable writable attr _inside_mode: Bool + readable writable var _inside_mode: Bool = false # Is the current module computed as a intruded one ? - readable writable attr _intrude_mode: Bool + readable writable var _intrude_mode: Bool = false # Compued introducing entities (for the index) - attr _entities: Array[MMEntity] = new Array[MMEntity] + var _entities: Array[MMEntity] = new Array[MMEntity] # Register an entity (for the index) - meth register(e: MMEntity) + fun register(e: MMEntity) do _entities.add(e) if e isa MMSrcModule then - _module = e + _mmmodule = e end end # Start a new file - meth clear + fun clear do _stage_context = new StageContext(null) end # Generate common files (frames, index, overview) - meth extract_other_doc + fun extract_other_doc do - _module = null + info("Generating other files",1) + _mmmodule = null inside_mode = false intrude_mode = false clear @@ -179,60 +180,62 @@ special AbstractCompiler write_to("{dir}/index.html") end - meth add_header(title: String) + fun add_header(title: String) do add("{title}\n\n") add("
\n") add("Overview  Index  With Frames\n") add("
") add("Visibility: ") - if (not inside_mode and not intrude_mode) or module == null then + var mod = mmmodule + if (not inside_mode and not intrude_mode) or mod == null then add("Public  ") else - add("Public  ") + add("Public  ") end - if inside_mode or module == null then + if inside_mode or mod == null then add("Inside  ") - else if module.directory.owner != module then + else if mod.directory.owner != mod then add("Inside  ") else - add("Inside  ") + add("Inside  ") end - if intrude_mode or module == null then + if intrude_mode or mod == null then add("Intrude  ") else - add("Intrude  ") + add("Intrude  ") end add("
") end # Sorter of entities in alphabetical order - attr _sorter: AlphaSorter[MMEntity] = new AlphaSorter[MMEntity] + var _sorter: AlphaSorter[MMEntity] = new AlphaSorter[MMEntity] # Sort entities in the alphabetical order - meth sort(array: Array[MMEntity]) + fun sort(array: Array[MMEntity]) do _sorter.sort(array) end - readable writable attr _owned_modules: Array[MMModule] + readable writable var _owned_modules: Array[MMModule] = new Array[MMModule] # Return the known_owner for current module # if inside_mode is set, it could be a different result - meth known_owner_of(m: MMModule): MMModule + fun known_owner_of(m: MMModule): MMModule do - if module == null then return m - var res = module.known_owner_of(m) - if not inside_mode and not intrude_mode and res.directory.owner == module then - return module + var mod = mmmodule + if mod == null then return m + var res = mod.known_owner_of(m) + if not inside_mode and not intrude_mode and res.directory.owner == mod then + return mod else return res end end - readable attr _opt_dir: OptionString = new OptionString("Directory where doc is generated", "-d", "--dir") + readable var _opt_dir: OptionString = new OptionString("Directory where doc is generated", "-d", "--dir") - redef meth perform_work(mods) + redef fun perform_work(mods) do dir.mkdir @@ -243,39 +246,40 @@ special AbstractCompiler self.extract_other_doc end - redef init + init do - super + keep_ast = true + super("nitdoc") option_context.add_option(opt_dir) end - redef meth process_options + redef fun process_options do super - dir = opt_dir.value - if dir == null then dir = "." + var d = opt_dir.value + if d != null then dir = d end end # Conditionnal part of the text content of a DocContext class StageContext # Content of the current stage - readable attr _content: Array[String] = new Array[String] + readable var _content: Array[String] = new Array[String] # Is a normal string already added? - readable writable attr _validate: Bool + readable writable var _validate: Bool = false # Parent stage is any - readable attr _parent: StageContext + readable var _parent: nullable StageContext = null - init(parent: StageContext) do _parent = parent + init(parent: nullable StageContext) do _parent = parent end # Efficiently sort object with their to_s method class AlphaSorter[E: Object] -special AbstractSorter[E] - redef meth compare(a, b) + super AbstractSorter[E] + redef fun compare(a, b) do var sa: String var sb: String @@ -296,7 +300,7 @@ special AbstractSorter[E] end # Keep track of to_s values - attr _dico: HashMap[Object, String] = new HashMap[Object, String] + var _dico: HashMap[Object, String] = new HashMap[Object, String] init do end end @@ -304,59 +308,63 @@ end # Generalization of metamodel entities class MMEntity # Return a link to - meth html_link(dctx: DocContext): String is abstract + fun html_link(dctx: DocContext): String is abstract # Is the entity should appear in the generaed doc - meth need_doc(dctx: DocContext): Bool is abstract + fun need_doc(dctx: DocContext): Bool is abstract # Return a one liner description - meth short_doc: String do return " " + fun short_doc: String do return " " # The doc node from the AST # Return null is none - meth doc: ADoc do return null + fun doc: nullable ADoc do return null # Human redable location of the entity (module/class/property) - meth locate(dctx: DocContext): String do return "" + fun locate(dctx: DocContext): String do return "" # Part of the prototype before the name (kind, modifiers, qualifier) - meth prototype_head(dctx: DocContext): String is abstract + fun prototype_head(dctx: DocContext): String is abstract # Part of the property after the name (signature, modifiers) - meth prototype_body(dctx: DocContext): String do return "" + fun prototype_body(dctx: DocContext): String do return "" end redef class MMModule -special MMEntity - redef meth html_link(dctx) do - if dctx.module == self then + super MMEntity + redef fun html_link(dctx) do + if dctx.mmmodule == self then return "{self}" else return "{self}" end end - redef meth need_doc(dctx) do return true - redef meth prototype_head(dctx) do return "module " - - attr _known_owner_of_cache: Map[MMModule, MMModule] = new HashMap[MMModule, MMModule] - meth known_owner_of(module: MMModule): MMModule - do - if _known_owner_of_cache.has_key(module) then return _known_owner_of_cache[module] - var res = module - if mhe < module and visibility_for(module) != 0 then - res = known_owner_of_intern(module, self, false) + redef fun need_doc(dctx) do return true + redef fun prototype_head(dctx) do return "module " + + var _known_owner_of_cache: Map[MMModule, MMModule] = new HashMap[MMModule, MMModule] + + # Return the owner of `module` from the point of view of `self` + fun known_owner_of(mod: MMModule): MMModule + do + if _known_owner_of_cache.has_key(mod) then return _known_owner_of_cache[mod] + var res = mod + # is module is publicly imported by self? + if mhe < mod and visibility_for(mod) != 0 then + res = known_owner_of_intern(mod, self, false) else - res = module.owner(self) + # Return the canonnical owner of module from the point of view of self + res = mod.owner(self) end - _known_owner_of_cache[module] = res + _known_owner_of_cache[mod] = res return res end # Return the most general module that own self - meth owner(from: MMModule): MMModule + fun owner(from: MMModule): MMModule do var res = self - var d = directory + var d: nullable MMDirectory = directory while d != null and d != from.directory do var o = d.owner if o != null and o.mhe <= res then res = o @@ -365,16 +373,18 @@ special MMEntity return res end - private meth known_owner_of_intern(module: MMModule, from: MMModule, as_owner: Bool): MMModule + # ??? + private fun known_owner_of_intern(mod: MMModule, from: MMModule, as_owner: Bool): MMModule do - if module == self then return self + if mod == self then return self var candidates = new Array[MMModule] for m in explicit_imported_modules do if from.visibility_for(m) == 0 then continue - if not m.mhe <= module then continue - candidates.add(m.known_owner_of_intern(module, from, true)) + if not m.mhe <= mod then continue + candidates.add(m.known_owner_of_intern(mod, from, true)) end - assert not candidates.is_empty + # FIXME: I do not know what this does + if candidates.is_empty then return mod.owner(from) var max = candidates.first for m in candidates do if max.mhe < m then max = m @@ -389,49 +399,43 @@ special MMEntity end redef class MMLocalProperty -special MMEntity + super MMEntity # Anchor of the property description in the module html file - meth html_anchor: String + fun html_anchor: String do return "PROP_{local_class}_{cmangle(name)}" end - redef meth html_link(dctx) + redef fun html_link(dctx) do - var m = module - if not need_doc(dctx) then m = global.intro.module - var m = dctx.known_owner_of(m) - if m == dctx.module then + var m = mmmodule + if not need_doc(dctx) then m = global.intro.mmmodule + m = dctx.known_owner_of(m) + if m == dctx.mmmodule then return "{self}" else return "{self}" end end - redef meth short_doc do return concrete_property.short_doc - - redef meth doc do return concrete_property.doc - - redef meth need_doc(dctx) do return false + # Kind of property (fun, attr, etc.) + fun kind: String is abstract - # Kind of property (meth, attr, etc.) - meth kind: String is abstract - - redef meth locate(dctx) + redef fun locate(dctx) do - return "in {module.html_link(dctx)}::{local_class.html_link(dctx)}" + return "in {mmmodule.html_link(dctx)}::{local_class.html_link(dctx)}" end - meth known_intro_class(dctx: DocContext): MMLocalClass + fun known_intro_class(dctx: DocContext): MMLocalClass do - var mod = dctx.known_owner_of(global.intro.local_class.module) + var mod = dctx.known_owner_of(global.intro.local_class.mmmodule) var cla = mod[global.intro.local_class.global] return cla end - redef meth prototype_head(dctx) + redef fun prototype_head(dctx) do - var res = "" + var res = new Buffer var intro_class = known_intro_class(dctx) var is_redef = local_class != intro_class @@ -445,42 +449,85 @@ special MMEntity if is_redef then var gp = global.intro if intro_class.global != local_class.global then - res.append(" {module[intro_class.global].html_link(dctx)}::") - else if intro_class.module != module then - res.append(" {intro_class.module.html_link(dctx)}::") + res.append(" {mmmodule[intro_class.global].html_link(dctx)}::") + else if intro_class.mmmodule != mmmodule then + res.append(" {intro_class.mmmodule.html_link(dctx)}::") end end - return res + return res.to_s end - redef meth prototype_body(dctx) + redef fun prototype_body(dctx) do - var res = signature.to_html(dctx) + var res = new Buffer + res.append(signature.to_html(dctx, true)) var s = self - if s isa MMConcreteProperty then - if s.node isa ADeferredMethPropdef then + if s isa MMMethod then + if s.is_abstract then res.append(" is abstract") - else if s.node isa AInternMethPropdef then + else if s.is_intern then res.append(" is intern") end end - return res + return res.to_s + end + + redef fun need_doc(dctx) + do + if global.visibility_level >= 3 or self isa MMAttribute 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 + return doc != null + end + + redef fun short_doc + do + var d = doc + if d != null then + return d.short + else if global.intro == self then + return " " + else + return global.intro.short_doc + end + end + + redef fun doc + do + var n = node + if n == null or not n isa APropdef 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 end redef class MMMethod - redef meth kind do return if global.is_init then "init" else "meth" + redef fun kind do return if global.is_init then "init" else "fun" end redef class MMAttribute - redef meth kind do return "attr" + redef fun kind do return "var" end redef class MMTypeProperty - redef meth kind do return "type" + redef fun kind do return "type" end redef class MMSrcModule # Extract and generate html file for the module - meth extract_module_doc(dctx: DocContext) + fun extract_module_doc(dctx: DocContext) do + dctx.info("Generating HTML for module {name}",1) dctx.register(self) dctx.clear @@ -502,13 +549,13 @@ redef class MMSrcModule end end - meth extract_module_doc_inside(dctx: DocContext) + fun extract_module_doc_inside(dctx: DocContext) do dctx.add_header("Module {self}") dctx.add("

Module {self}

\n
") var s = "" - var d = directory - while d == null do + var d: nullable MMDirectory = directory + while d != null do if d.owner != null and (d.owner != self or dctx.inside_mode or dctx.intrude_mode) then s = "{d.owner.html_link(dctx)}::{s}" end @@ -520,8 +567,8 @@ redef class MMSrcModule var intrude_modules = new Array[MMModule] var public_modules = new Array[MMModule] var private_modules = new Array[MMModule] - var owned_modules = new Array[MMModule] - dctx.owned_modules = owned_modules + var owned_modules = dctx.owned_modules + owned_modules.clear for m in mhe.greaters do var v = visibility_for(m) if not dctx.inside_mode and not dctx.intrude_mode and m.directory.owner == self then @@ -567,10 +614,12 @@ redef class MMSrcModule end else for m in owned_modules do - var mc = m[c.global] - if mc != null and mc.need_doc(dctx) then - new_classes.add(c) - break + if m.global_classes.has(c.global) then + var mc = m[c.global] + if mc.need_doc(dctx) then + new_classes.add(c) + break + end end end end @@ -599,7 +648,7 @@ redef class MMSrcModule dctx.add("\n") end - redef meth short_doc + redef fun short_doc do var d = doc if d != null then @@ -609,20 +658,14 @@ redef class MMSrcModule end end - redef meth doc + redef fun doc do var n = node - if not n isa AModule then - return null - end - assert n isa AModule - if n.n_packagedecl == null then + if n.n_moduledecl == null then return null end - var np = n.n_packagedecl - assert np isa APackagedecl + var np = n.n_moduledecl var d = np.n_doc - assert d isa ADoc if d == null then return null end @@ -636,72 +679,74 @@ end redef class ADoc # Html transcription of the doc - meth to_html: String + fun to_html: String do - var res = new String + var res = new Buffer for c in n_comment do res.append(c.text.substring_from(1)) end - return res + return res.to_s end # Oneliner transcription of the doc - meth short: String + fun short: String do return n_comment.first.text.substring_from(1) end end redef class MMLocalClass -special MMEntity + super MMEntity # Anchor of the class description in the module html file - meth html_anchor: String do return "CLASS_{self}" + fun html_anchor: String do return "CLASS_{self}" - redef meth html_link(dctx) + redef fun html_link(dctx) do - var m = module - if not need_doc(dctx) then m = global.module - var m = dctx.known_owner_of(m) - if m == dctx.module then + var m = mmmodule + if not need_doc(dctx) then m = global.mmmodule + m = dctx.known_owner_of(m) + if m == dctx.mmmodule then return "{self}" else return "{self}" end end - redef meth short_doc do return global.intro.short_doc + redef fun short_doc do return global.intro.short_doc - redef meth doc do return global.intro.doc + redef fun doc do return global.intro.doc - redef meth need_doc(dctx) do - if module == dctx.module then + redef fun need_doc(dctx) do + if mmmodule == dctx.mmmodule then for m in dctx.owned_modules do - var c = m[global] - if c != null and c.need_doc(dctx) then return true + if m.global_classes.has(global) then + var c = m[global] + if c.need_doc(dctx) then return true + end end end return false end - redef meth locate(dctx) do return "in {module.html_link(dctx)}" + redef fun locate(dctx) do return "in {mmmodule.html_link(dctx)}" - meth known_intro(dctx: DocContext): MMLocalClass do return dctx.known_owner_of(global.intro.module)[global] + fun known_intro(dctx: DocContext): MMLocalClass do return dctx.known_owner_of(global.intro.mmmodule)[global] - redef meth prototype_head(dctx) + redef fun prototype_head(dctx) do - var res = "" + var res = new Buffer var ki = known_intro(dctx) var is_redef = ki != self if is_redef then res.append("redef ") if global.visibility_level == 3 then res.append("private ") res.append("class ") - if is_redef then res.append("{ki.module.html_link(dctx)}::") - return res + if is_redef then res.append("{ki.mmmodule.html_link(dctx)}::") + return res.to_s end - redef meth prototype_body(dctx) + redef fun prototype_body(dctx) do - var res = "" + var res = new Buffer if arity > 0 then res.append("[") for i in [0..arity[ do @@ -712,32 +757,32 @@ special MMEntity end res.append("]") end - return res + return res.to_s end # Extract the doc of a class - meth extract_class_doc(dctx: DocContext) + fun extract_class_doc(dctx: DocContext) do - dctx.add("

{self}

{module.html_link(dctx)}::
{prototype_head(dctx)}{self}{prototype_body(dctx)}\n") + dctx.add("

{self}

{mmmodule.html_link(dctx)}::
{prototype_head(dctx)}{self}{prototype_body(dctx)}\n") dctx.add("
\n") dctx.add("
\n") var sup2 = new Array[String] - var intro_module = dctx.known_owner_of(global.module) - if intro_module != module then + var intro_module = dctx.known_owner_of(global.mmmodule) + if intro_module != mmmodule then dctx.add("
Refine {self} from:
{intro_module.html_link(dctx)}\n") sup2.clear var mods = new Array[MMModule] for c in crhe.greaters do if c.need_doc(dctx) then - var km = dctx.known_owner_of(c.module) - if km != module and km != intro_module and not mods.has(km) then + var km = dctx.known_owner_of(c.mmmodule) + if km != mmmodule and km != intro_module and not mods.has(km) then mods.add(km) end end end for c in crhe.linear_extension do - if mods.has(c.module) then sup2.add(c.module.html_link(dctx)) + if mods.has(c.mmmodule) then sup2.add(c.mmmodule.html_link(dctx)) end if not sup2.is_empty then dctx.add("
Previous refinements in:
{sup2.join(", ")}\n") end @@ -764,11 +809,10 @@ special MMEntity sup2.clear for c in crhe.smallers do c.compute_super_classes - for c2 in c.module.local_classes do + for c2 in c.mmmodule.local_classes do if not c2 isa MMConcreteClass then continue c2.compute_super_classes c2.compute_ancestors - c2.inherit_global_properties end for c2 in c.cshe.direct_smallers do if c2.global.intro == c2 then @@ -781,8 +825,8 @@ special MMEntity end sup2.clear for c in crhe.order do - if not module.mhe <= c.module and c.need_doc(dctx) then - sup2.add(c.module.html_link(dctx)) + if not mmmodule.mhe <= c.mmmodule and c.need_doc(dctx) then + sup2.add(c.mmmodule.html_link(dctx)) end end if not sup2.is_empty then @@ -802,13 +846,13 @@ special MMEntity dctx.add("

\n") end - meth pass_name(pass: Int): String + fun pass_name(pass: Int): String do var names = once ["Virtual Types", "Consructors", "Methods", "Attributes"] return names[pass] end - meth accept_prop(p: MMLocalProperty, pass: Int): Bool + fun accept_prop(p: MMLocalProperty, pass: Int): Bool do if pass == 0 then return p isa MMTypeProperty @@ -822,25 +866,27 @@ special MMEntity abort end - meth property_summary(dctx: DocContext, pass: Int): Array[MMLocalProperty] + fun property_summary(dctx: DocContext, pass: Int): Array[MMLocalProperty] do var passname = pass_name(pass) dctx.open_stage dctx.stage("\n") - dctx.stage("\n") + dctx.stage("\n") var new_props = new Array[MMLocalProperty] for g in global_properties do if not accept_prop(g.intro, pass) then continue - if module.visibility_for(g.intro.module) < g.visibility_level then continue + if mmmodule.visibility_for(g.intro.mmmodule) < g.visibility_level then continue var p = self[g] - if not p.need_doc(dctx) then + 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 c == null or not c isa MMConcreteClass then continue + if not c isa MMConcreteClass then continue + if not c.has_global_property(g) then continue var p2 = c[g] - if p2 == null or not p2.need_doc(dctx) then continue + if p2.local_class != c or not p2.need_doc(dctx) then continue cla.add(c) end if cla.is_empty then continue @@ -854,7 +900,7 @@ special MMEntity end dctx.sort(new_props) for p in new_props do - dctx.add("\n") + dctx.add("\n") end dctx.stage("
{passname} Summary of {self}
{passname} Summary of {self}
{p.prototype_head(dctx)}{p.html_link(dctx)}{p.prototype_body(dctx)}
    {p.short_doc}
{p.prototype_head(dctx)}{p.html_link(dctx)}{p.prototype_body(dctx)}
    {p.short_doc}

\n") @@ -864,14 +910,13 @@ special MMEntity # skip pass 1 because constructors are not inherited var cmap = new HashMap[MMLocalClass, Array[MMLocalProperty]] var mmap = new HashMap[MMModule, Array[MMLocalProperty]] - var props = new Array[MMLocalClass] for c in che.greaters do if c isa MMSrcLocalClass then - var km = dctx.known_owner_of(c.module) + var km = dctx.known_owner_of(c.mmmodule) var kc = km[c.global] - if kc == self or not c isa MMConcreteClass then continue + if kc == self then continue var props: Array[MMLocalProperty] - if km == module then + if km == mmmodule then if cmap.has_key(kc) then props = cmap[kc] else @@ -888,7 +933,7 @@ special MMEntity end for g in c.global_properties do var p = c[g] - if p.need_doc(dctx) and accept_prop(p, pass) then + if p.local_class == c and p.need_doc(dctx) and accept_prop(p, pass) then props.add(kc[g]) end end @@ -909,7 +954,7 @@ special MMEntity dctx.open_stage dctx.stage("Imported {passname}\n") - for m in module.mhe.linear_extension do + 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 @@ -922,11 +967,10 @@ special MMEntity end var mmap = new HashMap[MMModule, Array[MMLocalProperty]] - var props = new Array[MMLocalClass] for c in crhe.order do - if module.mhe <= c.module or dctx.owned_modules.has(c.module) or not c isa MMSrcLocalClass then continue - var km = dctx.known_owner_of(c.module) - if module.mhe <= km then continue + 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 @@ -937,7 +981,7 @@ special MMEntity end for g in c.global_properties do var p = c[g] - if p.need_doc(dctx) and accept_prop(p, pass) then + 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 @@ -947,7 +991,7 @@ special MMEntity dctx.open_stage dctx.stage("Added {passname} in known modules\n") for c in crhe.order do - var m = c.module + var m = c.mmmodule if not mmap.has_key(m) then continue var props = mmap[m] if props.is_empty then continue @@ -964,7 +1008,7 @@ special MMEntity return new_props end - meth property_detail(dctx: DocContext, pass: Int, new_props: Array[MMLocalProperty]) + fun property_detail(dctx: DocContext, pass: Int, new_props: Array[MMLocalProperty]) do var passname = pass_name(pass) dctx.open_stage @@ -974,7 +1018,7 @@ special MMEntity dctx.open_stage for p in new_props do - dctx.add("

{p}

{p.module.html_link(dctx)}::{p.local_class.html_link(dctx)}::
{p.prototype_head(dctx)} {p.name}{p.prototype_body(dctx)}

\n") + dctx.add("

{p}

{p.mmmodule.html_link(dctx)}::{p.local_class.html_link(dctx)}::
{p.prototype_head(dctx)} {p.name}{p.prototype_body(dctx)}

\n") dctx.add("
") var doc = p.doc if doc != null then @@ -992,19 +1036,19 @@ special MMEntity end # Add rows for properties inheriterd to some heirs - meth properties_inherited_from(dctx: DocContext, heir: MMLocalClass, pass: Int) + 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.need_doc(dctx) and accept_prop(p, pass) then + 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 = module.html_link(dctx) + s = mmmodule.html_link(dctx) else s = self.html_link(dctx) end @@ -1014,7 +1058,7 @@ special MMEntity end redef class MMSrcLocalClass - redef meth short_doc + redef fun short_doc do var d = doc if d != null then @@ -1027,15 +1071,13 @@ redef class MMSrcLocalClass end end - redef meth doc + redef fun doc do - var n = nodes.first - if not n isa AClassdef then + var n = node + if not n isa AStdClassdef then return null end - assert n isa AClassdef var d = n.n_doc - assert d isa ADoc if d == null then return null end @@ -1046,11 +1088,11 @@ redef class MMSrcLocalClass end end - redef meth need_doc(dctx) + redef fun need_doc(dctx) do if global.visibility_level >= 3 then if not dctx.intrude_mode then return false - if dctx.module.visibility_for(module) == 0 then return false + if dctx.mmmodule.visibility_for(mmmodule) == 0 then return false end if global.intro == self then return true @@ -1064,56 +1106,11 @@ redef class MMSrcLocalClass end end -redef class MMConcreteProperty - redef meth need_doc(dctx) - do - if global.visibility_level >= 3 or self isa MMAttribute then - if not dctx.intrude_mode then return false - if dctx.module.visibility_for(module) == 0 then return false - end - if global.intro == self then - return true - end - return true - end - - redef meth short_doc - do - var d = doc - if d != null then - return d.short - else if global.intro == self then - return " " - else - return global.intro.short_doc - end - end - - redef meth doc - do - var n = node - if not node isa PPropdef then - return null - end - assert n isa PPropdef - var d = n.n_doc - assert d isa ADoc - if d == null then - return null - end - if d.n_comment.is_empty then - return null - else - return d - end - end -end - redef class MMSignature # Htlm transcription of the signature (with nested links) - meth to_html(dctx: DocContext): String + fun to_html(dctx: DocContext, with_closure: Bool): String do - var res = new String + var res = new Buffer if arity > 0 then res.append("(") res.append(self[0].html_link(dctx)) @@ -1127,23 +1124,34 @@ redef class MMSignature res.append(": ") res.append(return_type.html_link(dctx)) end - return res + 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) - meth html_link(dctx: DocContext): String do return to_s + fun html_link(dctx: DocContext): String do return to_s end redef class MMTypeSimpleClass - redef meth html_link(dctx) do return local_class.html_link(dctx) + redef fun html_link(dctx) do return local_class.html_link(dctx) end redef class MMTypeGeneric - redef meth html_link(dctx) + redef fun html_link(dctx) do - var res = local_class.html_link(dctx) + 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 @@ -1151,7 +1159,7 @@ redef class MMTypeGeneric res.append(params[i].html_link(dctx)) end res.append("]") - return res + return res.to_s end end