1 # This file is part of NIT ( http://www.nitlanguage.org ).
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 # Generates lists about intros/redefs in MEntity.
17 # Actually, this works only for MModules and MclassDefs.
18 module doc_intros_redefs
21 import model
::model_collect
23 # Computes intro / redef mentity list for each DefinitionArticle.
24 class IntroRedefListPhase
28 for page
in doc
.pages
.values
do
29 if not page
isa MEntityPage then continue
30 page
.root
.build_intro_redef_list
(self, doc
, page
)
35 redef class DocComposite
37 # Computes intro / redef lists for this page.
39 # See `IntroRedefListPhase`.
40 fun build_intro_redef_list
(v
: IntroRedefListPhase, doc
: DocModel, page
: MEntityPage) do
41 for child
in children
do child
.build_intro_redef_list
(v
, doc
, page
)
45 redef class DefinitionArticle
46 redef fun build_intro_redef_list
(v
, doc
, page
) do
47 var mentity
= self.mentity
48 if mentity
isa MModule then
49 build_mmodule_list
(v
, doc
, mentity
)
50 else if mentity
isa MClassDef and mentity
.mmodule
== page
.mentity
then
51 build_mclassdef_list
(v
, doc
, mentity
)
56 # TODO this should move to MEntity?
57 private fun build_mmodule_list
(v
: IntroRedefListPhase, doc
: DocModel, mmodule
: MModule) do
58 var section
= new TabbedGroup("{mentity.nitdoc_id}.intros_redefs")
59 section
.toc_title
= "Intros / Redefs"
60 var group
= new PanelGroup("list.group", "List")
61 var intros
= mmodule
.collect_intro_mclassdefs
(v
.doc
).to_a
62 doc
.mainmodule
.linearize_mclassdefs
(intros
)
63 group
.add_child
new MEntitiesListArticle("{mentity.nitdoc_id}.intros", "Introduces", intros
)
64 var redefs
= mmodule
.collect_redef_mclassdefs
(v
.doc
).to_a
65 doc
.mainmodule
.linearize_mclassdefs
(redefs
)
66 group
.add_child
new MEntitiesListArticle("{mentity.nitdoc_id}.redefs", "Redefines", redefs
)
67 section
.add_child group
71 # TODO this should move to MEntity?
72 private fun build_mclassdef_list
(v
: IntroRedefListPhase, doc
: DocModel, mclassdef
: MClassDef) do
73 var section
= new TabbedGroup("{mentity.nitdoc_id}.intros_redefs")
74 section
.toc_title
= "Intros / Redefs"
75 var group
= new PanelGroup("list.group", "List")
76 var intros
= mclassdef
.collect_intro_mpropdefs
(v
.doc
).to_a
77 # FIXME avoid diff changes
78 # v.ctx.mainmodule.linearize_mpropdefs(intros)
79 group
.add_child
new MEntitiesListArticle("{mentity.nitdoc_id}.intros", "Introduces", intros
)
80 var redefs
= mclassdef
.collect_redef_mpropdefs
(v
.doc
).to_a
81 # FIXME avoid diff changes
82 # v.ctx.mainmodule.linearize_mpropdefs(redefs)
83 group
.add_child
new MEntitiesListArticle("{mentity.nitdoc_id}.redefs", "Redefines", redefs
)
84 section
.add_child group