nitdoc: display less important data in tabs
authorAlexandre Terrasa <alexandre@moz-code.org>
Fri, 24 Apr 2015 16:04:09 +0000 (12:04 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Mon, 11 May 2015 20:43:53 +0000 (16:43 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/doc/doc_phases/doc_graphs.nit
src/doc/html_templates/html_templates.nit

index 0a011e8..07b7c99 100644 (file)
@@ -126,4 +126,6 @@ class GraphArticle
 
        # Dot script of the graph.
        var dot: Text
+
+       redef var is_empty = false
 end
index a461ba0..b79c87b 100644 (file)
@@ -319,6 +319,15 @@ redef class DocComposite
                end
                lst.add_li new ListItem(content)
        end
+
+       # ID used in HTML tab labels.
+       #
+       # We sanitize it for Boostrap JS panels that do not like ":" and "." in ids.
+       var html_tab_id: String is lazy do
+               var id = html_id.replace(":", "")
+               id = id.replace(".", "")
+               return "{id}-tab"
+       end
 end
 
 redef class DocSection
@@ -348,6 +357,24 @@ redef class DocArticle
        end
 end
 
+redef class TabbedGroup
+       redef fun render_body do
+               var tabs = new DocTabs("{html_id}.tabs", "")
+               for child in children do
+                       if child.is_hidden then continue
+                       tabs.add_panel new DocTabPanel(child.html_tab_id, child.toc_title, child)
+               end
+               addn tabs
+       end
+end
+
+redef class PanelGroup
+       redef var html_id is lazy do return "group:{group_title.to_lower.to_snake_case}"
+       redef var html_title = null
+       redef var toc_title is lazy do return group_title
+       redef var is_toc_hidden = true
+end
+
 redef class HomeArticle
        redef var html_id = "article:home"
        redef var html_title = "Overview"
@@ -513,6 +540,7 @@ redef class DefinitionArticle
        end
 
        redef fun render_body do
+               var tabs = new DocTabs("{html_id}.tabs", "")
                if not is_no_body then
                        var comment
                        if is_short_comment then
@@ -520,9 +548,15 @@ redef class DefinitionArticle
                        else
                                comment = mentity.html_comment
                        end
-                       if comment != null then addn comment
+                       if comment != null then
+                               tabs.add_panel new DocTabPanel("{html_tab_id}-comment", "Comment", comment)
+                       end
                end
-               super
+               for child in children do
+                       if child.is_hidden then continue
+                       tabs.add_panel new DocTabPanel(child.html_tab_id, child.toc_title, child)
+               end
+               addn tabs
        end
 end
 
@@ -530,7 +564,7 @@ redef class HierarchyListArticle
        redef var html_id is lazy do return "article:{list_title}_{mentity.nitdoc_id}.hierarchy"
        redef var html_title is lazy do return list_title
        redef fun is_empty do return mentities.is_empty
-       redef fun is_toc_hidden do return mentities.is_empty
+       redef var is_toc_hidden = true
 
        redef fun render_body do
                var lst = new UnorderedList
@@ -542,8 +576,16 @@ redef class HierarchyListArticle
        end
 end
 
-redef class IntrosRedefsListArticle
+redef class IntrosRedefsSection
        redef var html_id is lazy do return "article:{mentity.nitdoc_id}.intros_redefs"
+       redef var toc_title do return "Intros / Redefs"
+       redef var html_title = null
+       redef var html_subtitle = null
+       redef var is_toc_hidden = true
+end
+
+redef class IntrosRedefsListArticle
+       redef var html_id is lazy do return "article:{list_title}_{mentity.nitdoc_id}.intros_redefs"
        redef var html_title is lazy do return list_title
        redef fun is_hidden do return mentities.is_empty
        redef var is_toc_hidden = true