lnk.add def.tpl_link
return new TplListItem.with_content(lnk)
end
-
- # inheritance section
- private fun tpl_inheritance(parent: TplSection) do
- # Display lists
- var section = new TplSection.with_title("dependencies", "Dependencies")
-
- # Imports
- var lst = new Array[MModule]
- if not lst.is_empty then
- name_sorter.sort lst
- section.add_child tpl_list("imports", "Imports", lst)
- end
-
- # Clients
- lst = new Array[MModule]
- if not lst.is_empty then
- name_sorter.sort lst
- section.add_child tpl_list("clients", "Clients", lst)
- end
-
- parent.add_child section
- end
-
- private fun tpl_list(id: String, title: String, mmodules: Array[MModule]): TplArticle do
- var article = new TplArticle.with_title(id, title)
- var list = new TplList.with_classes(["list-unstyled", "list-definition"])
- for mmodule in mmodules do list.elts.add mmodule.tpl_list_item
- article.content = list
- return article
- end
end
# A class page
lnk.add mprop.tpl_anchor
return new TplListItem.with_content(lnk)
end
-
- private fun tpl_inheritance(parent: TplSection) do
- # Display lists
- var section = new TplSection.with_title("inheritance", "Inheritance")
-
- # parents
- if not hparents.is_empty then
- var lst = hparents.to_a
- name_sorter.sort lst
- section.add_child tpl_list("parents", "Parents", lst)
- end
-
- # ancestors
- if not hancestors.is_empty then
- var lst = hancestors.to_a
- name_sorter.sort lst
- section.add_child tpl_list("ancestors", "Ancestors", lst)
- end
-
- # children
- if not hchildren.is_empty then
- var lst = hchildren.to_a
- name_sorter.sort lst
- section.add_child tpl_list("children", "Children", lst)
- end
-
- # descendants
- if not hdescendants.is_empty then
- var lst = hdescendants.to_a
- name_sorter.sort lst
- section.add_child tpl_list("descendants", "Descendants", lst)
- end
-
- parent.add_child section
- end
-
- private fun tpl_list(id: String, title: String, elts: Array[MClass]): TplArticle do
- var article = new TplArticle.with_title(id, title)
- if elts.length > 20 then
- var tpl = new Template
- for e in elts do
- tpl.add e.tpl_link
- if e != elts.last then tpl.add ", "
- end
- article.content = tpl
- else
- var list = new TplList.with_classes(["list-unstyled", "list-definition"])
- for elt in elts do list.elts.add elt.tpl_list_item
- article.content = list
- end
- return article
- end
end
# A MProperty page
--- /dev/null
+# 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.
+
+# Computes importation and class hierarchy lists.
+module doc_hierarchies
+
+import doc_structure
+import doc_poset
+
+# Insert inheritance / importation lists in the page.
+class InheritanceListsPhase
+ super DocPhase
+
+ # Used to sort list by name.
+ var name_sorter = new MEntityNameSorter
+
+ redef fun apply do
+ for page in doc.pages do
+ if page isa MEntityPage then page.build_inh_list(self, doc)
+ end
+ end
+end
+
+redef class MEntityPage
+
+ # Build importation / inheritance list for this page.
+ fun build_inh_list(v: InheritanceListsPhase, doc: DocModel) do end
+end
+
+redef class MModulePage
+ redef fun build_inh_list(v, doc) do
+ var section = new ImportationListSection
+ var imports = self.imports.to_a
+ v.name_sorter.sort(imports)
+ section.children.add new HierarchyListArticle(mentity, "Imports", imports)
+ var clients = self.clients.to_a
+ v.name_sorter.sort(clients)
+ section.children.add new HierarchyListArticle(mentity, "Clients", clients)
+ root.children.insert(section, 1)
+ end
+end
+
+redef class MClassPage
+ redef fun build_inh_list(v, doc) do
+ var section = new InheritanceListSection
+ var parents = self.parents.to_a
+ v.name_sorter.sort(parents)
+ section.children.add new HierarchyListArticle(mentity, "Parents", parents)
+ var ancestors = self.ancestors.to_a
+ v.name_sorter.sort(ancestors)
+ section.children.add new HierarchyListArticle(mentity, "Ancestors", ancestors)
+ var children = self.children.to_a
+ v.name_sorter.sort(children)
+ section.children.add new HierarchyListArticle(mentity, "Children", children)
+ var descendants = self.descendants.to_a
+ v.name_sorter.sort(descendants)
+ section.children.add new HierarchyListArticle(mentity, "Descendants", descendants)
+ root.children.insert(section, 1)
+ end
+end
+
+# FIXME diff hack
+class ImportationListSection
+ super DocSection
+end
+
+# FIXME diff hack
+class InheritanceListSection
+ super DocSection
+end
+
+# Dislay a hierarchical list of mentities.
+class HierarchyListArticle
+ super MEntityArticle
+
+ # Title displayed in the top of this list.
+ var list_title: String
+
+ # MEntities to display in this list.
+ var mentities: Array[MEntity]
+end