summaryrefslogtreecommitdiff
path: root/ocamldoc
diff options
context:
space:
mode:
authorSébastien Hinderer <Sebastien.Hinderer@inria.fr>2022-06-30 18:23:02 +0200
committerSébastien Hinderer <Sebastien.Hinderer@inria.fr>2022-06-30 18:23:02 +0200
commit2f8dba7b3e4c79a2ce2707d1c87706d874c34cbc (patch)
treea0505d98c3f9beaf4847f2bd17a3033af26e4c99 /ocamldoc
parent1f0393017fb6be9d591352bea741c60178b990f3 (diff)
downloadocaml-2f8dba7b3e4c79a2ce2707d1c87706d874c34cbc.tar.gz
Provide an interface for ocamldoc's odoc_ocamlhtml module
This commit also removes a few unused values, one unused type constructor and one exception from this module.
Diffstat (limited to 'ocamldoc')
-rw-r--r--ocamldoc/.depend9
-rw-r--r--ocamldoc/Makefile4
-rw-r--r--ocamldoc/odoc_ocamlhtml.mli24
-rw-r--r--ocamldoc/odoc_ocamlhtml.mll45
4 files changed, 32 insertions, 50 deletions
diff --git a/ocamldoc/.depend b/ocamldoc/.depend
index 53e9ed45f8..f590ecd38c 100644
--- a/ocamldoc/.depend
+++ b/ocamldoc/.depend
@@ -382,7 +382,7 @@ odoc_global.cmi : \
odoc_types.cmi
odoc_html.cmo : \
odoc_text.cmi \
- odoc_ocamlhtml.cmo \
+ odoc_ocamlhtml.cmi \
odoc_messages.cmi \
odoc_info.cmi \
odoc_global.cmi \
@@ -620,8 +620,11 @@ odoc_name.cmi : \
../typing/path.cmi \
../parsing/longident.cmi \
../typing/ident.cmi
-odoc_ocamlhtml.cmo :
-odoc_ocamlhtml.cmx :
+odoc_ocamlhtml.cmo : \
+ odoc_ocamlhtml.cmi
+odoc_ocamlhtml.cmx : \
+ odoc_ocamlhtml.cmi
+odoc_ocamlhtml.cmi :
odoc_parameter.cmo : \
../typing/types.cmi \
odoc_types.cmi \
diff --git a/ocamldoc/Makefile b/ocamldoc/Makefile
index e2a1bfca9e..53ad55a72b 100644
--- a/ocamldoc/Makefile
+++ b/ocamldoc/Makefile
@@ -36,8 +36,8 @@ OCAMLDOC_LIBA=odoc_info.$(A)
OCAMLDOC_LIBMLIS=$(addsuffix .mli,\
odoc_dep odoc_extension odoc_info odoc_latex odoc_latex_style odoc_man \
- odoc_messages odoc_parameter odoc_texi odoc_text_lexer odoc_to_text \
- odoc_type odoc_value)
+ odoc_messages odoc_ocamlhtml odoc_parameter odoc_texi odoc_text_lexer \
+ odoc_to_text odoc_type odoc_value)
OCAMLDOC_LIBCMIS=$(OCAMLDOC_LIBMLIS:.mli=.cmi)
OCAMLDOC_LIBCMTS=$(OCAMLDOC_LIBMLIS:.mli=.cmt) $(OCAMLDOC_LIBMLIS:.mli=.cmti)
diff --git a/ocamldoc/odoc_ocamlhtml.mli b/ocamldoc/odoc_ocamlhtml.mli
new file mode 100644
index 0000000000..b05c478b70
--- /dev/null
+++ b/ocamldoc/odoc_ocamlhtml.mli
@@ -0,0 +1,24 @@
+(**************************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Sebastien Hinderer, projet Cambium, INRIA Paris *)
+(* *)
+(* Copyright 2022 Institut National de Recherche en Informatique et *)
+(* en Automatique. *)
+(* *)
+(* All rights reserved. This file is distributed under the terms of *)
+(* the GNU Lesser General Public License version 2.1, with the *)
+(* special exception on linking described in the file LICENSE. *)
+(* *)
+(**************************************************************************)
+
+(** Generation of html code to display OCaml code. *)
+
+val escape_base : string -> string
+
+val html_of_comment : (string -> string) ref
+
+val code_class : string
+
+val html_of_code : Buffer.t -> ?with_pre:bool -> string -> unit
diff --git a/ocamldoc/odoc_ocamlhtml.mll b/ocamldoc/odoc_ocamlhtml.mll
index 813505b181..d808fef970 100644
--- a/ocamldoc/odoc_ocamlhtml.mll
+++ b/ocamldoc/odoc_ocamlhtml.mll
@@ -17,16 +17,10 @@
(** Generation of html code to display OCaml code. *)
open Lexing
-exception Fatal_error
-
-let fatal_error msg =
- prerr_string ">> Fatal error: "; prerr_endline msg; raise Fatal_error
-
type error =
| Illegal_character of char
| Unterminated_comment
| Unterminated_string
- | Unterminated_string_in_comment
| Keyword_as_label of string
exception Error of error * int * int
@@ -165,7 +159,6 @@ let margin = ref 0
let comment_buffer = Buffer.create 32
let reset_comment_buffer () = Buffer.reset comment_buffer
let store_comment_char = Buffer.add_char comment_buffer
-let add_comment_string = Buffer.add_string comment_buffer
let make_margin () =
let rec iter n =
@@ -208,47 +201,9 @@ let store_string_char = Buffer.add_char string_buffer
let get_stored_string () =
Buffer.contents string_buffer
-(** To translate escape sequences *)
-
-let char_for_backslash = function
- | 'n' -> '\010'
- | 'r' -> '\013'
- | 'b' -> '\008'
- | 't' -> '\009'
- | c -> c
-
-let char_for_decimal_code lexbuf i =
- let c = 100 * (Char.code(Lexing.lexeme_char lexbuf i) - 48) +
- 10 * (Char.code(Lexing.lexeme_char lexbuf (i+1)) - 48) +
- (Char.code(Lexing.lexeme_char lexbuf (i+2)) - 48) in
- Char.chr(c land 0xFF)
-
-let char_for_hexa_code lexbuf i =
- let c = 16 * (Char.code(Lexing.lexeme_char lexbuf i) - 48) +
- (Char.code(Lexing.lexeme_char lexbuf (i+1)) - 48) in
- Char.chr(c land 0xFF)
-
(** To store the position of the beginning of a string and comment *)
let string_start_pos = ref 0
let comment_start_pos = ref []
-let in_comment () = !comment_start_pos <> []
-
-(** Error report *)
-
-open Format
-
-let report_error ppf = function
- | Illegal_character c ->
- fprintf ppf "Illegal character (%s)" (Char.escaped c)
- | Unterminated_comment ->
- fprintf ppf "Comment not terminated"
- | Unterminated_string ->
- fprintf ppf "String literal not terminated"
- | Unterminated_string_in_comment ->
- fprintf ppf "This comment contains an unterminated string literal"
- | Keyword_as_label kwd ->
- fprintf ppf "`%s' is a keyword, it cannot be used as label name" kwd
-
}
let blank = [' ' '\010' '\013' '\009' '\012']