loader: can load a markdown file as a MDoc
authorJean Privat <jean@pryen.org>
Sat, 14 Mar 2015 06:38:01 +0000 (13:38 +0700)
committerJean Privat <jean@pryen.org>
Wed, 18 Mar 2015 03:57:11 +0000 (10:57 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

src/loader.nit

index 3bd8404..8b6b56d 100644 (file)
@@ -385,11 +385,7 @@ redef class ModelBuilder
                var readme = dirpath2.join_path("README.md")
                if not readme.file_exists then readme = dirpath2.join_path("README")
                if readme.file_exists then
-                       var mdoc = new MDoc(new Location(new SourceFile.from_string(readme, ""),0,0,0,0))
-                       var s = new FileReader.open(readme)
-                       while not s.eof do
-                               mdoc.content.add(s.read_line)
-                       end
+                       var mdoc = load_markdown(readme)
                        mgroup.mdoc = mdoc
                        mdoc.original_mentity = mgroup
                end
@@ -398,6 +394,17 @@ redef class ModelBuilder
                return mgroup
        end
 
+       # Load a markdown file as a documentation object
+       fun load_markdown(filepath: String): MDoc
+       do
+               var mdoc = new MDoc(new Location(new SourceFile.from_string(filepath, ""),0,0,0,0))
+               var s = new FileReader.open(filepath)
+               while not s.eof do
+                       mdoc.content.add(s.read_line)
+               end
+               return mdoc
+       end
+
        # Force the identification of all ModulePath of the group and sub-groups.
        fun visit_group(mgroup: MGroup) do
                var p = mgroup.filepath