redef class HierarchyListArticle
redef fun render(v, doc, page, parent) do
if mentities.is_empty then return
- var title = list_title
- var id = list_title.to_lower
- var article = new TplArticle.with_title(id, title)
- var list = new TplList.with_classes(["list-unstyled", "list-definition"])
- for mentity in mentities do
- list.elts.add mentity.tpl_list_item
- end
- article.content = list
+ var article = new TplArticle.with_title(list_title.to_lower, list_title)
+ article.content = write_to_string
parent.add_child article
end
end
module html_components
import doc_base
-import template
+import html::bootstrap
import json::static
+# A label with a text content.
+class DocHTMLLabel
+ super BSLabel
+
+ redef init do
+ css_classes.clear
+ css_classes.add "label"
+ end
+
+ # Init this label from css classes.
+ init with_classes(classes: Array[String]) do
+ init("label", "")
+ css_classes.add_all classes
+ end
+end
+
#########################
# general layout elements
#########################
#
# Mainly used for icons.
var css_classes = new Array[String]
+
+ # A li element that can go in a `HTMLList`.
+ fun html_list_item: ListItem do
+ var tpl = new Template
+ tpl.add new DocHTMLLabel.with_classes(css_classes)
+ tpl.add html_link
+ var comment = html_short_comment
+ if comment != null then
+ tpl.add ": "
+ tpl.add comment
+ end
+ return new ListItem(tpl)
+ end
end
redef class MProject
import html_model
import html::bootstrap
import doc_phases::doc_structure
+import doc_phases::doc_hierarchies
# Renders the page as HTML.
redef class DocPage
super
end
end
+
+redef class HierarchyListArticle
+ redef var html_id is lazy do return "article_hierarchy_{list_title}_{mentity.nitdoc_id}"
+ redef var html_title is lazy do return list_title
+ redef fun is_empty do return mentities.is_empty
+
+ redef fun render_body do
+ var lst = new UnorderedList
+ lst.css_classes.add "list-unstyled list-definition"
+ for mentity in mentities do
+ lst.add_li mentity.html_list_item
+ end
+ addn lst
+ end
+end