ni_nitdoc: moved JS GitHub to Nitdoc.GitHub module
[nit.git] / src / ni_nitdoc.nit
index 2dca23d..26ad41d 100644 (file)
@@ -163,7 +163,7 @@ class NitdocContext
 
        private fun quicksearch_list do
                var file = new OFStream.open("{output_dir.to_s}/quicksearch-list.js")
-               file.write("var entries = \{ ")
+               file.write("var nitdocQuickSearchRawList = \{ ")
                for mmodule in model.mmodules do
                        file.write("\"{mmodule.name}\": [")
                        file.write("\{txt: \"{mmodule.full_name}\", url:\"{mmodule.url}\" \},")
@@ -210,13 +210,16 @@ abstract class NitdocPage
                append("<meta charset='utf-8'/>")
                append("<script type='text/javascript' src='scripts/jquery-1.7.1.min.js'></script>")
                append("<script type='text/javascript' src='scripts/ZeroClipboard.min.js'></script>")
+               append("<script type='text/javascript' src='scripts/Nitdoc.UI.js'></script>")
                append("<script type='text/javascript' src='scripts/Markdown.Converter.js'></script>")
-               append("<script type='text/javascript' src='quicksearch-list.js'></script>")
                append("<script type='text/javascript' src='scripts/base64.js'></script>")
-               append("<script type='text/javascript' src='scripts/github.js'></script>")
-               append("<script type='text/javascript' src='scripts/js-facilities.js'></script>")
+               append("<script type='text/javascript' src='scripts/Nitdoc.GitHub.js'></script>")
+               append("<script type='text/javascript' src='quicksearch-list.js'></script>")
+               append("<script type='text/javascript' src='scripts/Nitdoc.QuickSearch.js'></script>")
                append("<link rel='stylesheet' href='styles/main.css' type='text/css' media='screen'/>")
-               append("<link rel='stylesheet' href='styles/github.css' type='text/css' media='screen'/>")
+               append("<link rel='stylesheet' href='styles/Nitdoc.UI.css' type='text/css' media='screen'/>")
+               append("<link rel='stylesheet' href='styles/Nitdoc.QuickSearch.css' type='text/css' media='screen'/>")
+               append("<link rel='stylesheet' href='styles/Nitdoc.GitHub.css' type='text/css' media='screen'/>")
                var title = ""
                if ctx.opt_custom_title.value != null then
                        title = " | {ctx.opt_custom_title.value.to_s}"
@@ -296,7 +299,9 @@ abstract class NitdocPage
                end
                append(">")
                header
-               append("<div class='page'>")
+               var footed = ""
+               if ctx.opt_custom_footer_text.value != null then footed = "footed"
+               append("<div class='page {footed}'>")
                content
                append("</div>")
                footer
@@ -351,9 +356,7 @@ class NitdocOverview
        end
 
        redef fun content do
-               var footed = ""
-               if ctx.opt_custom_footer_text.value != null then footed = "footed"
-               append("<div class='content fullpage {footed}'>")
+               append("<div class='content fullpage'>")
                var title = "Overview"
                if ctx.opt_custom_title.value != null then
                        title = ctx.opt_custom_title.value.to_s
@@ -428,9 +431,7 @@ class NitdocSearch
        end
 
        redef fun content do
-               var footed = ""
-               if ctx.opt_custom_footer_text.value != null then footed = "footed"
-               append("<div class='content fullpage {footed}'>")
+               append("<div class='content fullpage'>")
                append("<h1>{title}</h1>")
                module_column
                classes_column
@@ -505,7 +506,6 @@ class NitdocModule
        private var local_mclasses = new HashSet[MClass]
        private var intro_mclasses = new HashSet[MClass]
        private var redef_mclasses = new HashSet[MClass]
-       private var inherited_mclasses = new HashSet[MClass]
 
        init(mmodule: MModule, ctx: NitdocContext, dot_dir: nullable String) do
                super(ctx)
@@ -525,15 +525,6 @@ class NitdocModule
                                local_mclasses.add(mclassdef.mclass)
                        end
                end
-               # get inherited mclasses
-               for m in mmodule.in_importation.greaters do
-                       if m == mmodule then continue
-                       for mclassdef in m.mclassdefs do
-                               if mclassdef.mclass.visibility < ctx.min_visibility then continue
-                               if local_mclasses.has(mclassdef.mclass) then continue
-                               inherited_mclasses.add(mclassdef.mclass)
-                       end
-               end
        end
 
        redef fun title do
@@ -553,13 +544,11 @@ class NitdocModule
        end
 
        redef fun content do
-               append("<div class='menu'>")
+               append("<div class='sidebar'>")
                classes_column
                importation_column
                append("</div>")
-               var footed = ""
-               if ctx.opt_custom_footer_text.value != null then footed = "footed"
-               append("<div class='content {footed}'>")
+               append("<div class='content'>")
                module_doc
                append("</div>")
        end
@@ -586,7 +575,7 @@ class NitdocModule
                append("<h3>Module Hierarchy</h3>")
                var dependencies = new Array[MModule]
                for dep in mmodule.in_importation.greaters do
-                       if dep == mmodule or dep.public_owner != null then continue
+                       if dep == mmodule or dep.direct_owner == mmodule or dep.public_owner == mmodule then continue
                        dependencies.add(dep)
                end
                if mmodule.in_nesting.direct_greaters.length > 0 then
@@ -600,7 +589,7 @@ class NitdocModule
                var clients = new Array[MModule]
                for dep in mmodule.in_importation.smallers do
                        if dep.name == "<main>" then continue
-                       if dep == mmodule or dep.public_owner != null then continue
+                       if dep == mmodule then continue
                        clients.add(dep)
                end
                if clients.length > 0 then
@@ -630,6 +619,7 @@ class NitdocModule
                append("</div>")
                # comment
                mmodule.html_comment(self)
+               process_generate_dot
                # classes
                var class_sorter = new MClassNameSorter
                # intro
@@ -652,36 +642,6 @@ class NitdocModule
                        for mclass in redefs do mclass.html_full_desc(self)
                        append("</section>")
                end
-               # inherited properties
-               var inherited = new Array[MClass]
-               inherited.add_all(inherited_mclasses)
-               if inherited_mclasses.length > 0 then
-                       var modules2classes = new ArrayMap[MModule, Array[MClass]]
-                       for mclass in inherited_mclasses do
-                               if not modules2classes.has_key(mclass.intro_mmodule) then modules2classes[mclass.intro_mmodule] = new Array[MClass]
-                               modules2classes[mclass.intro_mmodule].add(mclass)
-                       end
-                       append("<section class='classes'>")
-                       append("<h2 class='section-header'>Inherited Classes</h2>")
-                       var mmodules = new Array[MModule]
-                       mmodules.add_all(modules2classes.keys)
-                       var msorter = new MModuleNameSorter
-                       msorter.sort(mmodules)
-                       for m in mmodules do
-                               var mclasses = modules2classes[m]
-                               class_sorter.sort(mclasses)
-                               append("<p>Defined in ")
-                               m.html_link(self)
-                               append(": ")
-                               for i in [0..mclasses.length[ do
-                                       var mclass = mclasses[i]
-                                       mclass.html_link(self)
-                                       if i <= mclasses.length - 1 then append(", ")
-                               end
-                       append("</p>")
-                       end
-                       append("</section>")
-               end
        end
 
        private fun process_generate_dot do
@@ -689,17 +649,26 @@ class NitdocModule
                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 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 not omodule.in_importation < self.mmodule and not self.mmodule.in_importation < omodule then continue
+                               if omodule.in_importation < mmodule then
+                                       poset.add_node(omodule)
+                                       poset.add_edge(omodule, mmodule)
+                               end
                                if mmodule.in_importation < omodule then
                                        poset.add_node(omodule)
                                        poset.add_edge(mmodule, omodule)
                                end
+                               #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
@@ -758,8 +727,9 @@ class NitdocClass
                        for pclassdef in pclass.mclassdefs do
                                for mprop in pclassdef.intro_mproperties do
                                        var mpropdef = mprop.intro
-                                       if mprop.visibility < ctx.min_visibility then continue
-                                       if locals.has(mprop) then continue
+                                       if mprop.visibility < ctx.min_visibility then continue # skip if not correct visibiility
+                                       if locals.has(mprop) then continue # skip if local
+                                       if mclass.name != "Object" and mprop.intro_mclassdef.mclass.name == "Object" and (mprop.visibility <= protected_visibility or mprop.intro_mclassdef.mmodule.public_owner == null or mprop.intro_mclassdef.mmodule.public_owner.name != "standard") then continue # skip toplevels
                                        if mpropdef isa MVirtualTypeDef then vtypes.add(mpropdef)
                                        if mpropdef isa MMethodDef then
                                                if mpropdef.mproperty.is_init then
@@ -801,13 +771,11 @@ class NitdocClass
        end
 
        redef fun content do
-               append("<div class='menu'>")
+               append("<div class='sidebar'>")
                properties_column
                inheritance_column
                append("</div>")
-               var footed = ""
-               if ctx.opt_custom_footer_text.value != null then footed = "footed"
-               append("<div class='content {footed}'>")
+               append("<div class='content'>")
                class_doc
                append("</div>")
        end
@@ -849,7 +817,6 @@ class NitdocClass
                        append("<h4>Methods</h4>")
                        append("<ul>")
                        for mprop in mts do
-                               if mclass.name != "Object" and mprop.mproperty.intro_mclassdef.mclass.name == "Object" and mprop.mproperty.visibility <= protected_visibility then continue
                                mprop.html_sidebar_item(self)
                        end
                        append("</ul>")
@@ -1396,13 +1363,6 @@ redef class MClass
                        page.append("</span></h3>")
                        html_info(page)
                        html_comment(page)
-                       if is_redef and not redefs.is_empty then
-                               page.append("<div class='refinements'>")
-                               for mpropdef in redefs do
-                                       mpropdef.html_full_desc(page, self)
-                               end
-                               page.append("</div>")
-                       end
                        page.append("</article>")
                end
        end
@@ -1771,7 +1731,8 @@ redef class ADoc
                        if text.first == ' ' then text = text.substring_from(1)
                        res.append(text.html_escape)
                end
-               return res.to_s
+               var str = res.to_s
+               return str.substring(0, str.length - 1)
        end
 end