-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add location of invalid docstring in warning messages (#1529)
- Loading branch information
Showing
8 changed files
with
61 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(**************************************************************************) | ||
(* *) | ||
(* OCamlFormat *) | ||
(* *) | ||
(* Copyright (c) Facebook, Inc. and its affiliates. *) | ||
(* *) | ||
(* This source code is licensed under the MIT license found in *) | ||
(* the LICENSE file in the root directory of this source tree. *) | ||
(* *) | ||
(**************************************************************************) | ||
|
||
let parse ~loc text = | ||
let location = loc.Location.loc_start in | ||
let location = | ||
{ location with | ||
pos_cnum= location.pos_cnum + 3 (* Length of comment opening *) } | ||
in | ||
match Odoc_parser.parse_comment_raw ~location ~text with | ||
| exception _ -> | ||
let span = Migrate_ast.Location.to_span loc in | ||
Error [Odoc_model.Error.make "comment could not be parsed" span] | ||
| {value; warnings= []} -> Ok value | ||
| {warnings; _} -> Error warnings | ||
|
||
let warn fmt warning = | ||
Format.fprintf fmt "Warning: Invalid documentation comment:@,%s\n%!" | ||
(Odoc_model.Error.to_string warning) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(**************************************************************************) | ||
(* *) | ||
(* OCamlFormat *) | ||
(* *) | ||
(* Copyright (c) Facebook, Inc. and its affiliates. *) | ||
(* *) | ||
(* This source code is licensed under the MIT license found in *) | ||
(* the LICENSE file in the root directory of this source tree. *) | ||
(* *) | ||
(**************************************************************************) | ||
|
||
val parse : | ||
loc:Warnings.loc | ||
-> string | ||
-> (Odoc_parser.Ast.docs, Odoc_model.Error.t list) Result.t | ||
|
||
val warn : Format.formatter -> Odoc_model.Error.t -> unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Warning: Invalid documentation comment: | ||
File "invalid_docstring.ml", line 1, characters 0-7: | ||
comment could not be parsed | ||
(**{v*) |