nitdoc: better display of section headers
authorAlexandre Terrasa <alexandre@moz-code.org>
Mon, 30 Jun 2014 18:11:20 +0000 (14:11 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 1 Jul 2014 15:48:10 +0000 (11:48 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

share/nitdoc/css/nitdoc.css
src/doc/doc_model.nit
src/doc/doc_pages.nit
src/doc/doc_templates.nit

index a9b4326..eabe3e7 100644 (file)
@@ -29,6 +29,10 @@ code {
        padding: 5px 10px;
 }
 
+h3 {
+       margin: 10px 0;
+}
+
 /*
  * Sidebar
  */
@@ -194,7 +198,7 @@ code {
 }
 
 .subtitle {
-       margin-bottom: 25px;
+       margin-bottom: 10px;
 }
 
 .label:empty {
index d460f07..1c39a2f 100644 (file)
@@ -147,7 +147,7 @@ end
 redef class MProject
        redef fun nitdoc_name do return name.html_escape
        redef fun nitdoc_id do return nitdoc_name
-       redef fun nitdoc_url do return "project_{name}.html"
+       redef fun nitdoc_url do return root.nitdoc_url
 
        redef fun mdoc do
                if root != null then
@@ -218,8 +218,6 @@ redef class MGroup
                end
                return tpl
        end
-
-       redef fun tpl_css_classes do return ["public"]
 end
 
 redef class MModule
@@ -272,13 +270,6 @@ redef class MModule
                return tpl
        end
 
-       redef fun tpl_title do
-               var title = new Template
-               title.add tpl_icon
-               title.add tpl_namespace
-               return title
-       end
-
        redef fun tpl_css_classes do return ["public"]
 end
 
index cba936f..35c5c8a 100644 (file)
@@ -296,7 +296,7 @@ abstract class NitdocPage
 
        # Clickable graphviz image using dot format
        # return null if no graph for this page
-       fun tpl_graph(dot: FlatBuffer, name: String, title: String): nullable TplArticle do
+       fun tpl_graph(dot: FlatBuffer, name: String, title: nullable String): nullable TplArticle do
                if ctx.opt_nodot.value then return null
                var output_dir = ctx.output_dir
                var file = new OFStream.open("{output_dir}/{name}.dot")
@@ -307,7 +307,9 @@ abstract class NitdocPage
                var map = fmap.read_all
                fmap.close
 
-               var article = new TplArticle.with_title("graph", title)
+               var article = new TplArticle("graph")
+               if title != null then article.title = title
+               article.css_classes.add "text-center"
                var content = new Template
                content.add "<img src='{name}.png' usemap='#{name}' style='margin:auto' alt='{title}'/>"
                content.add map
@@ -790,8 +792,8 @@ class NitdocModule
        redef fun tpl_content do
                tpl_sidebar_mclasses
                var top = tpl_intro
-               tpl_concerns(top)
                tpl_inheritance(top)
+               tpl_concerns(top)
                tpl_mclasses(top)
                tpl_page.add_section top
        end
@@ -825,7 +827,7 @@ class NitdocModule
                        end
                end
                op.append("\}\n")
-               return tpl_graph(op, name, "Dependency graph")
+               return tpl_graph(op, name, null)
        end
 
        private fun sort_by_mclass(mclassdefs: Collection[MClassDef]): Map[MClass, Set[MClassDef]] do
@@ -935,6 +937,12 @@ class NitdocClass
        end
 
        private fun tpl_concerns(parent: TplSection) do
+               # intro title
+               var section = new TplSection.with_title("intro", "Introduction")
+               section.summary_title = "Introduction"
+               section.add_child tpl_mclassdef_article(mclass.intro)
+               parent.add_child section
+               # concerns
                if concerns.is_empty then return
                parent.add_child new TplArticle.with_content("concerns", "Concerns", concerns.to_tpl)
        end
@@ -1037,7 +1045,7 @@ class NitdocClass
                                title.add "in "
                                title.add mentity.tpl_namespace
                                section.title = title
-                               section.summary_title = "In {mentity.nitdoc_name}"
+                               section.summary_title = "in {mentity.nitdoc_name}"
 
                                # properties
                                var mprops = mmodules2mprops[mentity]
@@ -1074,8 +1082,8 @@ class NitdocClass
        redef fun tpl_content do
                tpl_sidebar_properties
                var top = tpl_intro
-               tpl_concerns(top)
                tpl_inheritance(top)
+               tpl_concerns(top)
                tpl_properties(top)
                tpl_page.add_section top
        end
@@ -1185,7 +1193,7 @@ class NitdocClass
                        end
                end
                op.append("\}\n")
-               return tpl_graph(op, name, "Inheritance graph")
+               return tpl_graph(op, name, null)
        end
 end
 
index ecc2d3d..a95361d 100644 (file)
@@ -430,10 +430,11 @@ class TplSection
        super TplSectionElt
 
        redef fun rendering do
-               add "<section id='{id}'>"
+               add "<section id='{id}' class='{css_classes.join(" ")}'>"
                if title != null then
                        var lvl = hlvl
-                       add "<h{lvl}>"
+                       if lvl == 2 then title_classes.add "well well-sm"
+                       add "<h{lvl} class='{title_classes.join(" ")}'>"
                        add title.as(not null)
                        add "</h{lvl}>"
                end
@@ -462,9 +463,6 @@ class TplArticle
                self.content = content
        end
 
-       # CSS classes to apply on the article title heading element
-       var title_classes = new Array[String]
-
        redef fun render_summary(parent) do
                if is_empty then return
                var title = summary_title
@@ -476,9 +474,10 @@ class TplArticle
 
        redef fun rendering do
                if is_empty then return
-               add "<article id='{id}'>"
+               add "<article id='{id}' class='{css_classes.join(" ")}'>"
                if title != null then
                        var lvl = hlvl
+                       if lvl == 2 then title_classes.add "well well-sm"
                        add "<h{lvl} class='{title_classes.join(" ")}'>"
                        add title.as(not null)
                        add "</h{lvl}>"