src/doc: change structure so pages can describe multiple mentities
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 17 Feb 2015 21:55:04 +0000 (22:55 +0100)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 25 Feb 2015 20:57:09 +0000 (21:57 +0100)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/doc/doc_phases/doc_graphs.nit
src/doc/doc_phases/doc_hierarchies.nit
src/doc/doc_phases/doc_html.nit
src/doc/doc_phases/doc_structure.nit

index aff25d4..ba10850 100644 (file)
@@ -41,7 +41,7 @@ class GraphPhase
                        if article == null then continue
                        # FIXME avoid diff
                        # page.root.add article
-                       page.root.children[1].children.insert(article, 0)
+                       page.root.children.first.children[1].children.insert(article, 0)
                end
        end
 end
index 39ad273..20b4cba 100644 (file)
@@ -47,7 +47,7 @@ redef class MModulePage
                var clients = self.clients.to_a
                v.name_sorter.sort(clients)
                section.add_child new HierarchyListArticle(mentity, "Clients", clients)
-               root.children.insert(section, 1)
+               root.children.first.children.insert(section, 1)
        end
 end
 
@@ -66,7 +66,7 @@ redef class MClassPage
                var descendants = self.descendants.to_a
                v.name_sorter.sort(descendants)
                section.add_child new HierarchyListArticle(mentity, "Descendants", descendants)
-               root.children.insert(section, 1)
+               root.children.first.children.insert(section, 1)
        end
 end
 
index a11e187..e0bba0b 100644 (file)
@@ -579,6 +579,12 @@ redef class ConcernSection
        end
 end
 
+redef class MEntitySection
+       redef fun render(v, doc, page, parent) do
+               for child in children do child.render(v, doc, page, parent)
+       end
+end
+
 redef class IntroArticle
        redef fun render(v, doc, page, parent) do
                var article = new TplArticle("intro")
index 1e0d773..9c32c8c 100644 (file)
@@ -50,10 +50,12 @@ end
 
 redef class MGroupPage
        redef fun apply_structure(v, doc) do
+               var section = new MEntitySection(mentity)
+               root.add_child section
                if mentity.is_root then
-                       root.add_child new IntroArticle(mentity.mproject)
+                       section.add_child new IntroArticle(mentity.mproject)
                else
-                       root.add_child new IntroArticle(mentity)
+                       section.add_child new IntroArticle(mentity)
                end
                var concerns = self.concerns
                if concerns == null or concerns.is_empty then return
@@ -63,12 +65,12 @@ redef class MGroupPage
                concerns.sort_with(v.concerns_sorter)
                mentity.mproject.booster_rank = 0
                mentity.booster_rank = 0
-               root.add_child new ConcernsArticle(mentity, concerns)
+               section.add_child new ConcernsArticle(mentity, concerns)
                for mentity in concerns do
                        if mentity isa MModule then
-                               root.add_child new DefinitionArticle(mentity)
+                               section.add_child new DefinitionArticle(mentity)
                        else
-                               root.add_child new ConcernSection(mentity)
+                               section.add_child new ConcernSection(mentity)
                        end
                end
        end
@@ -76,7 +78,9 @@ end
 
 redef class MModulePage
        redef fun apply_structure(v, doc) do
-               root.add_child new IntroArticle(mentity)
+               var section = new MEntitySection(mentity)
+               root.add_child section
+               section.add_child new IntroArticle(mentity)
                var concerns = self.concerns
                if concerns == null or concerns.is_empty then return
                # FIXME avoid diff
@@ -87,10 +91,10 @@ redef class MModulePage
                mentity.mgroup.mproject.booster_rank = 0
                mentity.mgroup.booster_rank = 0
                mentity.booster_rank = 0
-               root.add_child new ConcernsArticle(mentity, concerns)
+               section.add_child new ConcernsArticle(mentity, concerns)
                # reference list
                for mentity in concerns do
-                       var section = new ConcernSection(mentity)
+                       var ssection = new ConcernSection(mentity)
                        if mentity isa MModule then
                                var mclasses = mclasses_for_mmodule(mentity).to_a
                                v.name_sorter.sort(mclasses)
@@ -104,10 +108,10 @@ redef class MModulePage
                                        for mclassdef in mclassdefs do
                                                article.add_child(new DefinitionArticle(mclassdef))
                                        end
-                                       section.add_child article
+                                       ssection.add_child article
                                end
                        end
-                       root.add_child section
+                       section.add_child ssection
                end
        end
 
@@ -136,7 +140,9 @@ end
 
 redef class MClassPage
        redef fun apply_structure(v, doc) do
-               root.add_child new IntroArticle(mentity)
+               var section = new MEntitySection(mentity)
+               root.add_child section
+               section.add_child new IntroArticle(mentity)
                var concerns = self.concerns
                if concerns == null or concerns.is_empty then return
                # FIXME diff hack
@@ -147,9 +153,9 @@ redef class MClassPage
                mentity.intro_mmodule.mgroup.mproject.booster_rank = 0
                mentity.intro_mmodule.mgroup.booster_rank = 0
                mentity.intro_mmodule.booster_rank = 0
-               root.add_child new ConcernsArticle(mentity, concerns)
+               section.add_child new ConcernsArticle(mentity, concerns)
                for mentity in concerns do
-                       var section = new ConcernSection(mentity)
+                       var ssection = new ConcernSection(mentity)
                        if mentity isa MModule then
                                var mprops = mproperties_for(mentity)
                                var by_kind = new PropertiesByKind.with_elements(mprops)
@@ -157,12 +163,12 @@ redef class MClassPage
                                        v.name_sorter.sort(group)
                                        for mprop in group do
                                                for mpropdef in mpropdefs_for(mprop, mentity) do
-                                                       section.add_child new DefinitionArticle(mpropdef)
+                                                       ssection.add_child new DefinitionArticle(mpropdef)
                                                end
                                        end
                                end
                        end
-                       root.add_child section
+                       section.add_child ssection
                end
        end
 
@@ -196,7 +202,9 @@ end
 
 redef class MPropertyPage
        redef fun apply_structure(v, doc) do
-               root.add_child new IntroArticle(mentity)
+               var section = new MEntitySection(mentity)
+               root.add_child section
+               section.add_child new IntroArticle(mentity)
                var concerns = self.concerns
                if concerns == null or concerns.is_empty then return
                # FIXME diff hack
@@ -207,18 +215,18 @@ redef class MPropertyPage
                mentity.intro.mclassdef.mmodule.mgroup.mproject.booster_rank = 0
                mentity.intro.mclassdef.mmodule.mgroup.booster_rank = 0
                mentity.intro.mclassdef.mmodule.booster_rank = 0
-               root.add_child new ConcernsArticle(mentity, concerns)
+               section.add_child new ConcernsArticle(mentity, concerns)
                for mentity in concerns do
-                       var section = new ConcernSection(mentity)
+                       var ssection = new ConcernSection(mentity)
                        if mentity isa MModule then
                                # Add mproperties
                                var mpropdefs = mpropdefs_for(mentity).to_a
                                v.name_sorter.sort(mpropdefs)
                                for mpropdef in mpropdefs do
-                                       section.add_child new DefinitionArticle(mpropdef)
+                                       ssection.add_child new DefinitionArticle(mpropdef)
                                end
                        end
-                       root.add_child section
+                       section.add_child ssection
                end
        end
 
@@ -258,6 +266,14 @@ abstract class MEntityArticle
        super DocArticle
 end
 
+# A section about a Mentity.
+#
+# Used to regroup content about a MEntity.
+class MEntitySection
+       super MEntityComposite
+       super DocSection
+end
+
 # An introduction article about a MEntity.
 #
 # Used at the top of a documentation page to introduce the documented MEntity.