Browse Source

minor doc improvments.

Nicolas Cannasse 18 years ago
parent
commit
cc41e0984a
2 changed files with 7 additions and 2 deletions
  1. 2 0
      main.ml
  2. 5 2
      parser.ml

+ 2 - 0
main.ml

@@ -141,6 +141,7 @@ try
 	Typer.check_override := false;
 	Typer.check_override := false;
 	Typer.forbidden_packages := ["js"; "neko"; "flash"];
 	Typer.forbidden_packages := ["js"; "neko"; "flash"];
 	Parser.display_error := parse_error;
 	Parser.display_error := parse_error;
+	Parser.use_doc := false;
 	(try
 	(try
 		let p = Sys.getenv "HAXE_LIBRARY_PATH" in
 		let p = Sys.getenv "HAXE_LIBRARY_PATH" in
 		let rec loop = function
 		let rec loop = function
@@ -201,6 +202,7 @@ try
 			target := Neko file
 			target := Neko file
 		),"<file> : compile code to Neko Binary");
 		),"<file> : compile code to Neko Binary");
 		("-xml",Arg.String (fun file ->
 		("-xml",Arg.String (fun file ->
+			Parser.use_doc := true;
 			xml_out := Some file
 			xml_out := Some file
 		),"<file> : generate XML types description");
 		),"<file> : generate XML types description");
 		("-main",Arg.String (fun cl ->
 		("-main",Arg.String (fun cl ->

+ 5 - 2
parser.ml

@@ -41,6 +41,7 @@ let display_error : (error_msg -> pos -> unit) ref = ref (fun _ _ -> assert fals
 
 
 let cache = ref (DynArray.create())
 let cache = ref (DynArray.create())
 let doc = ref None
 let doc = ref None
+let use_doc = ref false
 
 
 let last_token s =
 let last_token s =
 	let n = Stream.count s in
 	let n = Stream.count s in
@@ -536,8 +537,10 @@ let parse code file =
 	and process_token tk =
 	and process_token tk =
 		match fst tk with
 		match fst tk with
 		| Comment s ->
 		| Comment s ->
-			let l = String.length s in
-			if l > 2 && s.[0] = '*' && s.[l-1] = '*' then doc := Some (String.sub s 1 (l-2));
+			if !use_doc then begin
+				let l = String.length s in
+				if l > 0 && s.[0] = '*' then doc := Some (String.sub s 1 (l - (if l > 1 && s.[l-1] = '*' then 2 else 1)));
+			end;
 			next_token()
 			next_token()
 		| CommentLine s ->
 		| CommentLine s ->
 			next_token()
 			next_token()