src/doc: HierarchyList use new templates
authorAlexandre Terrasa <alexandre@moz-code.org>
Mon, 23 Feb 2015 23:43:14 +0000 (00:43 +0100)
committerAlexandre Terrasa <alexandre@moz-code.org>
Sat, 25 Apr 2015 01:45:24 +0000 (21:45 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/doc/doc_phases/doc_html.nit
src/doc/html_templates/html_components.nit
src/doc/html_templates/html_model.nit
src/doc/html_templates/html_templates.nit

index db5cf94..2b92f96 100644 (file)
@@ -763,14 +763,8 @@ end
 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
index e65059b..0734c8b 100644 (file)
 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
 #########################
index 5d55a53..2118bfa 100644 (file)
@@ -129,6 +129,19 @@ redef class MEntity
        #
        # 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
index d6cd154..3e9421e 100644 (file)
@@ -18,6 +18,7 @@ module html_templates
 import html_model
 import html::bootstrap
 import doc_phases::doc_structure
+import doc_phases::doc_hierarchies
 
 # Renders the page as HTML.
 redef class DocPage
@@ -299,3 +300,18 @@ redef class DefinitionArticle
                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