Merge: nitdoc: introduce useful services
[nit.git] / src / doc / doc_phases / doc_pages.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # Create DocPage instances for each documentated Mentity.
16 module doc_pages
17
18 import doc_extract
19
20 # ExtractionPhase populates the DocModel with DocPage.
21 class MakePagePhase
22 super DocPhase
23
24 # Instanciates documentation pages for the given DocModel.
25 redef fun apply do
26 doc.add_page new OverviewPage("overview", "Overview")
27 doc.add_page new SearchPage("search", "Index")
28 for mgroup in doc.mgroups do
29 doc.add_page new MGroupPage(mgroup)
30 end
31 for mmodule in doc.mmodules do
32 doc.add_page new MModulePage(mmodule)
33 end
34 for mclass in doc.mclasses do
35 doc.add_page new MClassPage(mclass)
36 end
37 for mproperty in doc.mproperties do
38 doc.add_page new MPropertyPage(mproperty)
39 end
40 end
41 end
42
43 # The Nitdoc overview page.
44 class OverviewPage
45 super DocPage
46 end
47
48 # The Nidoc full index page.
49 class SearchPage
50 super DocPage
51 end
52
53 # A DocPage documenting a MEntity.
54 class MEntityPage
55 autoinit mentity
56 super DocPage
57
58 # Type of MEntity documented by this page.
59 type MENTITY: MEntity
60
61 # MEntity documented by this page.
62 var mentity: MENTITY
63
64 redef var id is lazy do return mentity.nitdoc_id
65 redef var title is lazy do return mentity.nitdoc_name
66 end
67
68 # A documentation page about a MGroup.
69 class MGroupPage
70 super MEntityPage
71
72 redef type MENTITY: MGroup
73 end
74
75 # A documentation page about a MModule.
76 class MModulePage
77 super MEntityPage
78
79 redef type MENTITY: MModule
80 end
81
82 # A documentation page about a MClass.
83 class MClassPage
84 super MEntityPage
85
86 redef type MENTITY: MClass
87 end
88
89 # A documentation page about a MProperty.
90 class MPropertyPage
91 super MEntityPage
92
93 redef type MENTITY: MProperty
94 end