nitdoc: introduce `DocComposite::is_hidden` services in `doc_base`
[nit.git] / src / doc / html_templates / html_templates.nit
index 9de02a9..21ec7c1 100644 (file)
@@ -286,15 +286,13 @@ redef class DocComposite
        # Level <hX> for HTML heading.
        private fun hlvl: Int do return depth
 
-       # Is `self` not displayed in the page.
-       #
-       # By default, empty elements are hidden.
-       fun is_hidden: Bool do return is_empty
-
        # A short, undecorated title that goes in the table of contents.
        #
        # By default, returns `html_title.to_s`, subclasses should redefine it.
-       var toc_title: String is lazy, writable do return html_title.to_s
+       var html_toc_title: nullable String is lazy, writable do
+               if html_title == null then return toc_title
+               return html_title.write_to_string
+       end
 
        # Is `self` hidden in the table of content?
        var is_toc_hidden = false is writable
@@ -304,8 +302,7 @@ redef class DocComposite
                if is_toc_hidden then return
 
                var content = new Template
-               content.add new Link("#{html_id}", toc_title)
-
+               content.add new Link("#{html_id}", html_toc_title.to_s)
                if not children.is_empty then
                        var sublst = new UnorderedList
                        sublst.css_classes.add "nav"
@@ -365,7 +362,8 @@ redef class TabbedGroup
                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)
+                       var title = child.html_toc_title or else child.toc_title or else ""
+                       tabs.add_panel new DocTabPanel(child.html_tab_id, title, child)
                end
                addn tabs
        end
@@ -394,9 +392,6 @@ end
 
 redef class IndexArticle
        redef var html_title = "Index"
-       redef fun is_empty do
-               return mmodules.is_empty and mclasses.is_empty and mprops.is_empty
-       end
 
        redef fun render_body do
                addn "<div class='container-fluid'>"
@@ -447,12 +442,12 @@ end
 redef class ConstructorsSection
        redef var html_title = "Constructors"
        redef var html_subtitle = null
-       redef fun is_toc_hidden do return is_empty
+       redef fun is_toc_hidden do return is_hidden
 end
 
 redef class ConcernSection
        redef var html_title is lazy do return "in {mentity.nitdoc_name}"
-       redef fun is_toc_hidden do return is_empty
+       redef fun is_toc_hidden do return is_hidden
 end
 
 redef class ImportationListSection
@@ -465,7 +460,6 @@ end
 
 redef class IntroArticle
        redef var html_title = null
-       redef var is_hidden = false
        redef var is_toc_hidden = true
 
        # Link to source to display if any.
@@ -479,7 +473,8 @@ redef class IntroArticle
                end
                for child in children do
                        if child.is_hidden then continue
-                       tabs.add_panel new DocTabPanel(child.html_tab_id, child.toc_title, child)
+                       var title = child.html_toc_title or else child.toc_title or else ""
+                       tabs.add_panel new DocTabPanel(child.html_tab_id, title, child)
                end
                var lnk = html_source_link
                if lnk != null then
@@ -491,7 +486,6 @@ end
 
 redef class ConcernsArticle
        redef var html_title = "Concerns"
-       redef fun is_hidden do return concerns.is_empty
        redef fun render_body do add concerns.html_list
 end
 
@@ -504,13 +498,12 @@ redef class DefinitionListArticle
        end
 
        redef var html_subtitle is lazy do return mentity.html_namespace
-       redef var toc_title is lazy do return mentity.html_name
+       redef var html_toc_title is lazy do return mentity.html_name
 end
 
 redef class DefinitionArticle
        redef var html_title is lazy do return mentity.html_name
        redef var html_subtitle is lazy do return mentity.html_declaration
-       redef var is_hidden = false
 
        # Does `self` display only it's title and no body?
        #
@@ -540,7 +533,8 @@ redef class DefinitionArticle
                end
                for child in children do
                        if child.is_hidden then continue
-                       tabs.add_panel new DocTabPanel(child.html_tab_id, child.toc_title, child)
+                       var title = child.html_toc_title or else child.toc_title or else ""
+                       tabs.add_panel new DocTabPanel(child.html_tab_id, title, child)
                end
                var lnk = html_source_link
                if lnk != null then
@@ -551,7 +545,6 @@ redef class DefinitionArticle
 end
 
 redef class HierarchyListArticle
-       redef fun is_empty do return mentities.is_empty
        redef var is_toc_hidden = true
 
        redef fun render_body do
@@ -572,7 +565,6 @@ redef class IntrosRedefsSection
 end
 
 redef class IntrosRedefsListArticle
-       redef fun is_hidden do return mentities.is_empty
        redef var is_toc_hidden = true
 
        redef fun render_body do
@@ -587,7 +579,6 @@ end
 
 redef class DefinitionLinArticle
        redef var html_title is lazy do return "Linearization"
-       redef fun is_hidden do return mentities.is_empty
        redef var is_toc_hidden = true
 
        redef fun render_body do
@@ -612,8 +603,6 @@ end
 
 redef class GraphArticle
        redef var html_title = null
-       redef var toc_title do return "Graph"
-       redef var is_hidden = false
        redef var is_toc_hidden = true
 
        # HTML map used to display link.