summaryrefslogtreecommitdiff
path: root/ocamldoc
diff options
context:
space:
mode:
authorSergei Lebedev <superbobry@gmail.com>2014-04-08 22:49:54 +0400
committerSergei Lebedev <superbobry@gmail.com>2015-11-24 00:47:31 +0300
commit9dc2b25a0ecdb6e5cbe214380db0d710c43adae8 (patch)
tree5a64453b2a2e66dfd804925b68c5e56a5bbbc9f8 /ocamldoc
parent657e6be3dd15e20b7bbb51e72d584746e1b48904 (diff)
downloadocaml-9dc2b25a0ecdb6e5cbe214380db0d710c43adae8.tar.gz
PR#4518: change location format for reporting errors in ocamldoc
Diffstat (limited to 'ocamldoc')
-rw-r--r--ocamldoc/odoc_comments.ml27
-rw-r--r--ocamldoc/odoc_messages.ml8
2 files changed, 16 insertions, 19 deletions
diff --git a/ocamldoc/odoc_comments.ml b/ocamldoc/odoc_comments.ml
index c39cb51bf9..236d860a37 100644
--- a/ocamldoc/odoc_comments.ml
+++ b/ocamldoc/odoc_comments.ml
@@ -28,7 +28,7 @@ module type Texter =
module Info_retriever =
functor (MyTexter : Texter) ->
struct
- let create_see s =
+ let create_see file s =
try
let lexbuf = Lexing.from_string s in
let (see_ref, s) = Odoc_parser.see_info Odoc_see_lexer.main lexbuf in
@@ -64,7 +64,7 @@ module Info_retriever =
i_desc = (match desc with "" -> None | _ -> Some (MyTexter.text_of_string desc));
i_authors = !Odoc_comments_global.authors;
i_version = !Odoc_comments_global.version;
- i_sees = (List.map create_see !Odoc_comments_global.sees) ;
+ i_sees = (List.map (create_see file) !Odoc_comments_global.sees) ;
i_since = !Odoc_comments_global.since;
i_before = Odoc_merge.merge_before_tags
(List.map (fun (n, s) ->
@@ -87,19 +87,16 @@ module Info_retriever =
!Odoc_comments_global.customs)
}
)
- with
- Failure s ->
- incr Odoc_global.errors ;
- Printf.eprintf "File %S, line %d:\n%s\n%!" file (!Odoc_lexer.line_number + 1) s;
- (0, None)
- | Odoc_text.Text_syntax (l, c, s) ->
- incr Odoc_global.errors ;
- prerr_endline (file^" : "^(Odoc_messages.text_parse_error l c s));
- (0, None)
- | _ ->
- incr Odoc_global.errors ;
- prerr_endline (file^" : "^Odoc_messages.parse_error^"\n");
- (0, None)
+ with e ->
+ let (l, c, message) = match e with
+ | Failure s -> (!Odoc_lexer.line_number + 1, 0, s)
+ | Odoc_text.Text_syntax (l, c, s) -> (l, c, Odoc_messages.text_parse_error l c s)
+ | _other -> (0, 0, Odoc_messages.parse_error)
+ in begin
+ incr Odoc_global.errors;
+ prerr_endline (Odoc_messages.error_location file l c ^ message);
+ (0, None)
+ end
(** This function takes a string where a simple comment may has been found. It returns
false if there is a blank line or the first comment is a special one, or if there is
diff --git a/ocamldoc/odoc_messages.ml b/ocamldoc/odoc_messages.ml
index f2a6dbe6b5..cdfd4ff5a4 100644
--- a/ocamldoc/odoc_messages.ml
+++ b/ocamldoc/odoc_messages.ml
@@ -233,6 +233,9 @@ let help = " Display this list of options"
let warning = "Warning"
+let error_location file l c =
+ Printf.sprintf "File \"%s\", line %d, character %d:\n" file l c
+
let bad_magic_number =
"Bad magic number for this ocamldoc dump!\n"^
"This dump was not created by this version of OCamldoc."
@@ -244,10 +247,7 @@ let errors_occured n = (string_of_int n)^" error(s) encountered"
let parse_error = "Parse error"
let text_parse_error l c s =
let lines = Str.split (Str.regexp_string "\n") s in
- "Syntax error in text:\n"^s^"\n"^
- "line "^(string_of_int l)^", character "^(string_of_int c)^":\n"^
- (List.nth lines l)^"\n"^
- (String.make c ' ')^"^"
+ (List.nth lines l) ^ "\n" ^ (String.make c ' ') ^ "^"
let file_not_found_in_paths paths name =
Printf.sprintf "No file %s found in the load paths: \n%s"