Merge: new `with` statement
[nit.git] / src / doc / doc_base.nit
index 56b57c2..64b2022 100644 (file)
@@ -16,7 +16,8 @@
 module doc_base
 
 import toolcontext
-import doc_model # FIXME maintain compatibility with old templates.
+import model_utils
+import model_ext
 
 # The model of a Nitdoc documentation.
 #
@@ -67,7 +68,7 @@ end
 abstract class DocComposite
 
        # Parent element.
-       var parent: nullable DocComposite = null
+       var parent: nullable DocComposite = null is writable
 
        # Does `self` have a `parent`?
        fun is_root: Bool do return parent == null
@@ -83,7 +84,10 @@ abstract class DocComposite
        # Add a `child` to `self`.
        #
        # Shortcut for `children.add`.
-       fun add(child: DocComposite) do children.add child
+       fun add_child(child: DocComposite) do
+               child.parent = self
+               children.add child
+       end
 end
 
 # The `DocComposite` element that contains all the other.
@@ -217,3 +221,16 @@ class PropertyGroup[E: MProperty]
        # The title of the group, as displayed to the user.
        var title: String
 end
+
+redef class MEntity
+       # Name displayed in console for debug and tests.
+       fun nitdoc_name: String do return name.html_escape
+end
+
+redef class MClassDef
+       redef fun nitdoc_name do return mclass.nitdoc_name
+end
+
+redef class MPropDef
+       redef fun nitdoc_name do return mproperty.nitdoc_name
+end