diff --git a/src/DiagnosticData.ml b/src/DiagnosticData.ml index 0f247eb..ebdb315 100644 --- a/src/DiagnosticData.ml +++ b/src/DiagnosticData.ml @@ -8,19 +8,6 @@ type severity = | Error | Bug -(** The signature of message code. An implementer should specify the message code used in their library or application. *) -module type Code = -sig - (** The type of all message codes. *) - type t - - (** The default severity of the code. The severity of a message is about whether the message is an error or a warning, etc. To clarify, it is about how serious the message is to the {i end user,} not whether the program should stop or continue. The severity may be overwritten at the time of issuing a message to the end user. *) - val default_severity : t -> severity - - (** A concise, ideally Google-able string representation of each message code. Detailed or long descriptions of code should be avoided. For example, [E001] works better than [type-checking error]. The shorter, the better. It will be assumed that the string representation only uses ASCII printable characters. *) - val to_string : t -> string -end - (** The type of text. When we render a diagnostic, the layout engine of the rendering backend should be the one making layout choices. Therefore, we cannot pass already formatted strings. Instead, a text is defined to be a function that takes a formatter and uses it to render the content. The following two conditions must be satisfied: diff --git a/src/GitHub.ml b/src/GitHub.ml index f943aa8..508268a 100644 --- a/src/GitHub.ml +++ b/src/GitHub.ml @@ -1,6 +1,6 @@ (** Diagnostic display for GitHub Actions. *) -module Make (Code : Diagnostic.Code) = struct +module Make (Code : Reporter.Code) = struct let command_of_severity = function | Diagnostic.Info -> "notice" diff --git a/src/GitHub.mli b/src/GitHub.mli index e1c26f1..2375253 100644 --- a/src/GitHub.mli +++ b/src/GitHub.mli @@ -5,7 +5,7 @@ ] (** The functor to create a printer for GitHub Actions workflow commands. *) -module Make (Code : Diagnostic.Code) : sig +module Make (Code : Reporter.Code) : sig (** Print a diagnostic as a GitHub Actions workflow command. Only the main message will be printed; backtraces and additional messages are ignored. Example output: diff --git a/src/Reporter.ml b/src/Reporter.ml index 17996ca..0c552fa 100644 --- a/src/Reporter.ml +++ b/src/Reporter.ml @@ -1,9 +1,9 @@ open Bwd open Bwd.Infix -module type S = ReporterSigs.S +include ReporterSigs -module Make (Code : Diagnostic.Code) : S with module Code := Code = +module Make (Code : Code) : S with module Code := Code = struct (* Backtraces *) diff --git a/src/Reporter.mli b/src/Reporter.mli index 953ad74..d632591 100644 --- a/src/Reporter.mli +++ b/src/Reporter.mli @@ -1,5 +1,7 @@ -(** The signature of a logger. *) -module type S = ReporterSigs.S +(** The signature of a logger. + + @inline *) +include module type of ReporterSigs (** The functor to generate a logger. *) -module Make (Code : Diagnostic.Code) : S with module Code := Code +module Make (Code : Code) : S with module Code := Code diff --git a/src/ReporterSigs.ml b/src/ReporterSigs.ml index 1bff162..7b9950b 100644 --- a/src/ReporterSigs.ml +++ b/src/ReporterSigs.ml @@ -1,6 +1,19 @@ +(** The signature of message code. An implementer should specify the message code used in their library or application. *) +module type Code = +sig + (** The type of all message codes. *) + type t + + (** The default severity of the code. The severity of a message is about whether the message is an error or a warning, etc. To clarify, it is about how serious the message is to the {i end user,} not whether the program should stop or continue. The severity may be overwritten at the time of issuing a message to the end user. *) + val default_severity : t -> Diagnostic.severity + + (** A concise, ideally Google-able string representation of each message code. Detailed or long descriptions of code should be avoided. For example, [E001] works better than [type-checking error]. The shorter, the better. It will be assumed that the string representation only uses ASCII printable characters. *) + val to_string : t -> string +end + module type S = sig - module Code : Diagnostic.Code + module Code : Code (** {2 Sending Messages} *) diff --git a/src/lsp/AsaiLsp.ml b/src/lsp/AsaiLsp.ml index a0e7332..6f40761 100644 --- a/src/lsp/AsaiLsp.ml +++ b/src/lsp/AsaiLsp.ml @@ -1,7 +1,7 @@ module L = Lsp.Types module RPC = Jsonrpc -module Make (Code : Diagnostic.Code) = +module Make (Code : Reporter.Code) = struct module Server = LspServer.Make(Code) open Server diff --git a/src/lsp/AsaiLsp.mli b/src/lsp/AsaiLsp.mli index dacafdf..679d382 100644 --- a/src/lsp/AsaiLsp.mli +++ b/src/lsp/AsaiLsp.mli @@ -11,7 +11,7 @@ Note: many features are missing and it does not handle [positionEncoding]. @canonical Asai.Lsp.Make *) -module Make (Code : Diagnostic.Code) : sig +module Make (Code : Reporter.Code) : sig val start : source:string option -> init:(root:string option -> unit) -> load_file:(display:(Code.t Diagnostic.t -> unit) -> string -> unit) diff --git a/src/lsp/LspServer.ml b/src/lsp/LspServer.ml index 98c4be6..24199cc 100644 --- a/src/lsp/LspServer.ml +++ b/src/lsp/LspServer.ml @@ -5,7 +5,7 @@ module Lsp_Diagnostic = Lsp.Types.Diagnostic module Request = Lsp.Client_request module Notification = Lsp.Client_notification -module Make (Code : Diagnostic.Code) = +module Make (Code : Reporter.Code) = struct type diagnostic = Code.t Diagnostic.t diff --git a/src/lsp/LspServer.mli b/src/lsp/LspServer.mli index 219b0b0..f570be5 100644 --- a/src/lsp/LspServer.mli +++ b/src/lsp/LspServer.mli @@ -1,7 +1,7 @@ module L := Lsp.Types module RPC := Jsonrpc -module Make (Code : Diagnostic.Code) : sig +module Make (Code : Reporter.Code) : sig type lsp_error = | DecodeError of string | HandshakeError of string diff --git a/src/tty/Tty.ml b/src/tty/Tty.ml index b2707b1..be9eb78 100644 --- a/src/tty/Tty.ml +++ b/src/tty/Tty.ml @@ -20,7 +20,7 @@ end module E = Explicator.Make(Style) -module Make (Code : Diagnostic.Code) = +module Make (Code : Reporter.Code) = struct (* ╭ diff --git a/src/tty/Tty.mli b/src/tty/Tty.mli index b90997e..01ec597 100644 --- a/src/tty/Tty.mli +++ b/src/tty/Tty.mli @@ -5,7 +5,7 @@ (** {1 Display} *) (** This module provides functions to display or interact with diagnostics in UNIX terminals. *) -module Make (Code : Diagnostic.Code) : sig +module Make (Code : Reporter.Code) : sig (** [display d] prints the diagnostic [d] to the standard output, using terminal control characters for formatting. A message will look like this: