From: Alexandre Terrasa Date: Mon, 23 Feb 2015 23:43:14 +0000 (+0100) Subject: src/doc: HierarchyList use new templates X-Git-Tag: v0.7.5~80^2~3 X-Git-Url: http://nitlanguage.org src/doc: HierarchyList use new templates Signed-off-by: Alexandre Terrasa --- diff --git a/src/doc/doc_phases/doc_html.nit b/src/doc/doc_phases/doc_html.nit index db5cf94..2b92f96 100644 --- a/src/doc/doc_phases/doc_html.nit +++ b/src/doc/doc_phases/doc_html.nit @@ -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 diff --git a/src/doc/html_templates/html_components.nit b/src/doc/html_templates/html_components.nit index e65059b..0734c8b 100644 --- a/src/doc/html_templates/html_components.nit +++ b/src/doc/html_templates/html_components.nit @@ -17,9 +17,25 @@ 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 ######################### diff --git a/src/doc/html_templates/html_model.nit b/src/doc/html_templates/html_model.nit index 5d55a53..2118bfa 100644 --- a/src/doc/html_templates/html_model.nit +++ b/src/doc/html_templates/html_model.nit @@ -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 diff --git a/src/doc/html_templates/html_templates.nit b/src/doc/html_templates/html_templates.nit index d6cd154..3e9421e 100644 --- a/src/doc/html_templates/html_templates.nit +++ b/src/doc/html_templates/html_templates.nit @@ -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