nitdoc: introduce `depth` service for DocComposite
authorAlexandre Terrasa <alexandre@moz-code.org>
Wed, 13 May 2015 23:08:45 +0000 (19:08 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 13 May 2015 23:08:45 +0000 (19:08 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/doc/doc_base.nit
src/doc/html_templates/html_templates.nit

index 64b2022..6cd6083 100644 (file)
@@ -88,6 +88,12 @@ abstract class DocComposite
                child.parent = self
                children.add child
        end
+
+       # Depth of `self` in the composite tree.
+       fun depth: Int do
+               if parent == null then return 0
+               return parent.depth + 1
+       end
 end
 
 # The `DocComposite` element that contains all the other.
index 83f6a36..7ffcdb0 100644 (file)
@@ -284,10 +284,7 @@ redef class DocComposite
        end
 
        # Level <hX> for HTML heading.
-       private fun hlvl: Int do
-               if parent == null then return 0
-               return parent.hlvl + 1
-       end
+       private fun hlvl: Int do return depth
 
        # Is `self` not displayed in the page.
        #