nitdoc: introduce MakePagePhase
authorAlexandre Terrasa <alexandre@moz-code.org>
Wed, 4 Feb 2015 19:55:08 +0000 (20:55 +0100)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 4 Feb 2015 20:17:37 +0000 (21:17 +0100)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/doc/doc_phases/doc_pages.nit [new file with mode: 0644]
src/doc/doc_phases/doc_phases.nit
src/nitdoc.nit

diff --git a/src/doc/doc_phases/doc_pages.nit b/src/doc/doc_phases/doc_pages.nit
new file mode 100644 (file)
index 0000000..2594d4b
--- /dev/null
@@ -0,0 +1,90 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Create DocPage instances for each documentated Mentity.
+module doc_pages
+
+import doc_extract
+
+# ExtractionPhase populates the DocModel with DocPage.
+class MakePagePhase
+       super DocPhase
+
+       # Instanciates documentation pages for the given DocModel.
+       redef fun apply do
+               doc.pages.add new OverviewPage("Overview")
+               doc.pages.add new SearchPage("Index")
+               for mgroup in doc.mgroups do
+                       doc.pages.add new MGroupPage(mgroup.nitdoc_id, mgroup)
+               end
+               for mmodule in doc.mmodules do
+                       doc.pages.add new MModulePage(mmodule.nitdoc_id, mmodule)
+               end
+               for mclass in doc.mclasses do
+                       doc.pages.add new MClassPage(mclass.nitdoc_id, mclass)
+               end
+               for mproperty in doc.mproperties do
+                       doc.pages.add new MPropertyPage(mproperty.nitdoc_id, mproperty)
+               end
+       end
+end
+
+# The Nitdoc overview page.
+class OverviewPage
+       super DocPage
+end
+
+# The Nidoc full index page.
+class SearchPage
+       super DocPage
+end
+
+# A DocPage documenting a MEntity.
+class MEntityPage
+       super DocPage
+
+       # Type of MEntity documented by this page.
+       type MENTITY: MEntity
+
+       # MEntity documented by this page.
+       var mentity: MENTITY
+end
+
+# A documentation page about a MGroup.
+class MGroupPage
+       super MEntityPage
+
+       redef type MENTITY: MGroup
+end
+
+# A documentation page about a MModule.
+class MModulePage
+       super MEntityPage
+
+       redef type MENTITY: MModule
+end
+
+# A documentation page about a MClass.
+class MClassPage
+       super MEntityPage
+
+       redef type MENTITY: MClass
+end
+
+# A documentation page about a MProperty.
+class MPropertyPage
+       super MEntityPage
+
+       redef type MENTITY: MProperty
+end
index 00d746e..b17a9ed 100644 (file)
@@ -17,4 +17,4 @@
 # See `DocPhase`.
 module doc_phases
 
-import doc_extract
+import doc_pages
index b9175ed..dd7948d 100644 (file)
@@ -32,7 +32,9 @@ private class Nitdoc
        do
                var doc = new DocModel(mainmodule.model, mainmodule)
 
-               var phases = [new ExtractionPhase(toolcontext, doc)]
+               var phases = [
+                       new ExtractionPhase(toolcontext, doc),
+                       new MakePagePhase(toolcontext, doc): DocPhase]
 
                for phase in phases do
                        toolcontext.info("# {phase.class_name}", 1)