ni_nitdoc: cleaned visibility in model redef
[nit.git] / src / ni_nitdoc.nit
index cb0eef3..770a568 100644 (file)
@@ -407,14 +407,25 @@ class NitdocOverview
        end
 
        private fun process_generate_dot do
+               # build poset with public owners
+               var poset = new POSet[MModule]
+               for mmodule in mmodules do
+                       poset.add_node(mmodule)
+                       for omodule in mmodules do
+                               if mmodule == omodule then continue
+                               if mmodule.in_importation < omodule then
+                                       poset.add_node(omodule)
+                                       poset.add_edge(mmodule, omodule)
+                               end
+                       end
+               end
+               # build graph
                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 mmodules do
+               for mmodule in poset do
                        op.append("\"{mmodule.name}\"[URL=\"{mmodule.url}\"];\n")
-                       for imported in mmodule.in_importation.direct_greaters do
-                               if imported.direct_owner == null then
-                                       op.append("\"{mmodule.name}\"->\"{imported.name}\";\n")
-                               end
+                       for omodule in poset[mmodule].direct_greaters do
+                               op.append("\"{mmodule.name}\"->\"{omodule.name}\";\n")
                        end
                end
                op.append("\}\n")
@@ -540,7 +551,7 @@ class NitdocModule
                sidebar
                append("<div class='content'>")
                append("<h1>{mmodule.name}</h1>")
-               append("<div class='subtitle'>")
+               append("<div class='subtitle info'>")
                mmodule.html_signature(self)
                append("</div>")
                mmodule.html_full_comment(self)
@@ -551,25 +562,35 @@ class NitdocModule
        end
 
        private fun process_generate_dot do
-               var name = "dep_{mmodule.name}"
+               # build poset with public owners
+               var poset = new POSet[MModule]
+               for mmodule in self.mmodule.in_importation.poset do
+                       if mmodule.name == "<main>" then continue
+                       if mmodule.public_owner != null then continue
+                       if not mmodule.in_importation < self.mmodule and not self.mmodule.in_importation < mmodule and mmodule != self.mmodule then continue
+                       poset.add_node(mmodule)
+                       for omodule in mmodule.in_importation.poset do
+                               if mmodule == omodule then continue
+                               if omodule.name == "<main>" then continue
+                               if omodule.public_owner != null then continue
+                               if mmodule.in_importation < omodule then
+                                       poset.add_node(omodule)
+                                       poset.add_edge(mmodule, omodule)
+                               end
+                       end
+               end
+               # build graph
                var op = new Buffer
+               var name = "dep_{mmodule.name}"
                op.append("digraph {name} \{ 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 m in mmodule.in_importation.poset do
-                       if m.name == "<main>" then continue
-                       var public_owner = m.public_owner
-                       if public_owner == null then
-                               public_owner = m
-                               if m == mmodule then
-                                       op.append("\"{m.name}\"[shape=box,margin=0.03];\n")
-                               else
-                                       op.append("\"{m.name}\"[URL=\"{m.url}\"];\n")
-                               end
+               for mmodule in poset do
+                       if mmodule == self.mmodule then
+                               op.append("\"{mmodule.name}\"[shape=box,margin=0.03];\n")
+                       else
+                               op.append("\"{mmodule.name}\"[URL=\"{mmodule.url}\"];\n")
                        end
-                       for imported in m.in_importation.direct_greaters do
-                               if imported.name == "<main>" then continue
-                               if imported.public_owner == null then
-                                       op.append("\"{public_owner.name}\"->\"{imported.name}\";\n")
-                               end
+                       for omodule in poset[mmodule].direct_greaters do
+                               op.append("\"{mmodule.name}\"->\"{omodule.name}\";\n")
                        end
                end
                op.append("\}\n")
@@ -599,11 +620,13 @@ class NitdocModule
                        display_module_list(clients)
                end
                append("</nav>")
-               if mmodule.in_nesting.direct_greaters.length > 0 then
-                       append("<nav>")
-                       append("<h3>Nested Modules</h3>")
-                       display_module_list(mmodule.in_nesting.direct_greaters.to_a)
-                       append("</nav>")
+               if ctx.min_visibility < protected_visibility then
+                       if mmodule.in_nesting.direct_greaters.length > 0 then
+                               append("<nav>")
+                               append("<h3>Nested Modules</h3>")
+                               display_module_list(mmodule.in_nesting.direct_greaters.to_a)
+                               append("</nav>")
+                       end
                end
                append("</div>")
        end
@@ -787,6 +810,7 @@ class NitdocClass
                        append("<h4>Constructors</h4>")
                        append("<ul>")
                        for mprop in cts do
+                               if mprop.mproperty.name == "init" and mprop.mclassdef.mclass != mclass then continue
                                mprop.html_sidebar_item(self)
                        end
                        append("</ul>")
@@ -1080,28 +1104,6 @@ redef class MModule
        redef type OTHER: MModule
        redef fun <(other: OTHER): Bool do return self.name < other.name
 
-       # Get the list of all methods in a module
-       fun imported_methods: Set[MMethod] do
-               var methods = new HashSet[MMethod]
-               for mclass in imported_mclasses do
-                       for method in mclass.intro_methods do
-                               methods.add(method)
-                       end
-               end
-               return methods
-       end
-
-       # Get the list aof all refined methods in a module
-       fun redef_methods: Set[MMethod] do
-               var methods = new HashSet[MMethod]
-               for mclass in redef_mclasses do
-                       for method in mclass.intro_methods do
-                               methods.add(method)
-                       end
-               end
-               return methods
-       end
-
        # URL to nitdoc page
        fun url: String do
                var res = new Buffer
@@ -1313,7 +1315,7 @@ redef class MPropDef
        end
 
        # Return a list item for the mpropdef
-       fun html_list_item(page: NitdocPage) do
+       private fun html_list_item(page: NitdocPage) do
                if is_intro then
                        page.append("<li class='intro'>")
                        page.append("<span title='introduction'>I</span>&nbsp;")
@@ -1329,7 +1331,7 @@ redef class MPropDef
        end
 
        # Return a list item for the mpropdef
-       fun html_sidebar_item(page: NitdocClass) do
+       private fun html_sidebar_item(page: NitdocClass) do
                if is_intro and mclassdef.mclass == page.mclass then
                        page.append("<li class='intro'>")
                        page.append("<span title='Introduced'>I</span>")
@@ -1344,14 +1346,14 @@ redef class MPropDef
                page.append("</li>")
        end
 
-       fun html_full_desc(page: NitdocClass) is abstract
-       fun html_info(page: NitdocClass) is abstract
+       private fun html_full_desc(page: NitdocClass) is abstract
+       private fun html_info(page: NitdocClass) is abstract
 
        fun full_name: String do
                return "{mclassdef.mclass.public_owner.name}::{mclassdef.mclass.name}::{mproperty.name}"
        end
 
-       fun html_inheritance(page: NitdocClass) do
+       private fun html_inheritance(page: NitdocClass) do
                # definitions block
                page.append("<p class='info'>")
                page.ctx.mainmodule.linearize_mpropdefs(mproperty.mpropdefs)