compile: do not generate table and constructor iroutines of abstract/interface classes
[nit.git] / src / nitdoc.nit
index 5434df0..a8e1b45 100644 (file)
@@ -58,7 +58,6 @@ special AbstractCompiler
        # Write the content to a new file
        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)
@@ -96,6 +95,7 @@ special AbstractCompiler
        # Generate common files (frames, index, overview)
        fun extract_other_doc
        do
+               info("Generating other files",1)
                _module = null
                inside_mode = false
                intrude_mode = false
@@ -187,6 +187,7 @@ special AbstractCompiler
                add("<a href=\"overview.html\"><b>Overview</b></a>&nbsp; <a href=\"index-1.html\"><b>Index</b></a>&nbsp; <a href=\"index.html\" target=\"_top\"><b>With Frames</b></a>\n")
                add("</td></tr></table>")
                add("Visibility: ")
+               var module = module
                if (not inside_mode and not intrude_mode) or module == null then
                        add("<b>Public</b>&nbsp; ")
                else
@@ -247,6 +248,7 @@ special AbstractCompiler
 
        init
        do
+               keep_ast = true
                super("nitdoc")
                option_context.add_option(opt_dir)
        end
@@ -341,13 +343,17 @@ special MMEntity
        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(module: MMModule): MMModule
-       do 
+       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 
+               # is module is publicly imported by self?
+               if mhe < module and visibility_for(module) != 0 then
                        res = known_owner_of_intern(module, self, false)
                else
+                       # Return the canonnical owner of module from the point of view of self
                        res = module.owner(self)
                end
                _known_owner_of_cache[module] = res
@@ -367,6 +373,7 @@ special MMEntity
                return res
        end
 
+       # ???
        private fun known_owner_of_intern(module: MMModule, from: MMModule, as_owner: Bool): MMModule
        do
                if module == self then return self
@@ -376,7 +383,8 @@ special MMEntity
                        if not m.mhe <= module then continue
                        candidates.add(m.known_owner_of_intern(module, from, true))
                end
-               assert not candidates.is_empty
+               # FIXME: I do not know what this does
+               if candidates.is_empty then return module.owner(from)
                var max = candidates.first
                for m in candidates do
                        if max.mhe < m then max = m
@@ -402,7 +410,7 @@ special MMEntity
        do
                var m = module
                if not need_doc(dctx) then m = global.intro.module
-               var m = dctx.known_owner_of(m)
+               m = dctx.known_owner_of(m)
                if m == dctx.module then
                        return "<a href=\"#{html_anchor}\">{self}</a>"
                else
@@ -452,12 +460,12 @@ special MMEntity
        redef fun prototype_body(dctx)
        do
                var res = new Buffer
-               res.append(signature.to_html(dctx))
+               res.append(signature.to_html(dctx, true))
                var s = self
-               if s.node != null 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
@@ -491,15 +499,13 @@ special MMEntity
        redef fun doc
        do
                var n = node
-               if n == null or not node isa PPropdef then
+               if n == null or not n isa APropdef then
                        return null
                end
-               assert n isa PPropdef
                var d = n.n_doc
                if d == null then
                        return null
                end
-               assert d isa ADoc
                if d.n_comment.is_empty then
                        return null
                else
@@ -508,10 +514,10 @@ special MMEntity
        end
 end
 redef class MMMethod
-       redef fun 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 fun kind do return "attr"
+       redef fun kind do return "var"
 end
 redef class MMTypeProperty
        redef fun kind do return "type"
@@ -521,6 +527,7 @@ redef class MMSrcModule
        # Extract and generate html file for the module
        fun extract_module_doc(dctx: DocContext)
        do
+               dctx.info("Generating HTML for module {name}",1)
                dctx.register(self)
 
                dctx.clear
@@ -548,7 +555,7 @@ redef class MMSrcModule
                dctx.add("<h1>Module {self}</h1>\n<dl>")
                var s = ""
                var d: nullable MMDirectory = directory
-               while d == null do
+               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
@@ -658,12 +665,10 @@ redef class MMSrcModule
                        return null
                end
                var np = n.n_packagedecl
-               assert np isa APackagedecl
                var d = np.n_doc
                if d == null then
                        return null
                end
-               assert d isa ADoc
                if d.n_comment.is_empty then
                        return null
                else
@@ -699,7 +704,7 @@ special MMEntity
        do
                var m = module
                if not need_doc(dctx) then m = global.module
-               var m = dctx.known_owner_of(m)
+               m = dctx.known_owner_of(m)
                if m == dctx.module then
                        return "<a href=\"#{html_anchor}\">{self}</a>"
                else
@@ -808,7 +813,6 @@ special MMEntity
                                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
@@ -906,7 +910,6 @@ 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)
@@ -964,7 +967,6 @@ 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)
@@ -1071,16 +1073,14 @@ redef class MMSrcLocalClass
 
        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
                if d == null then
                        return null
                end
-               assert d isa ADoc
                if d.n_comment.is_empty then
                        return null
                else
@@ -1108,7 +1108,7 @@ end
 
 redef class MMSignature
        # Htlm transcription of the signature (with nested links)
-       fun to_html(dctx: DocContext): String
+       fun to_html(dctx: DocContext, with_closure: Bool): String
        do
                var res = new Buffer
                if arity > 0 then
@@ -1124,6 +1124,16 @@ redef class MMSignature
                        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