@@ -18,57 +18,9 @@ let make_ocamldoc_block = function
1818 List (("", "", "", plist), atoms)
1919*)
2020
21- open Printf
2221open Atd
2322open Indent
2423
25- let split_on_blank =
26- let rex = Re.Pcre. regexp {| [ \t]+| } in
27- fun str ->
28- Re.Pcre. split ~rex str
29-
30- (* Concatenate a list of strings ("words") into lines where the words
31- are separated by a single space character. Each line will not exceed
32- 'max_length' bytes unless a word is longer than this. *)
33- let concatenate_into_lines ~max_length (words : string list ) : string list =
34- let max_length = max 0 max_length in
35- let buf = Buffer. create max_length in
36- let finish_line () =
37- let line = Buffer. contents buf in
38- Buffer. clear buf;
39- line
40- in
41- let rec make_lines orig_words =
42- match orig_words with
43- | [] -> [finish_line () ]
44- | word :: words ->
45- let word_len = String. length word in
46- let len = Buffer. length buf in
47- if len = 0 then (
48- (* The word may be longer than 'max_length'. Putting it on its
49- own line is the best we can do without hyphenating it. *)
50- Buffer. add_string buf word;
51- make_lines words
52- )
53- else
54- (* Add the word to the current line only if it fits. *)
55- let new_len = len + 1 + word_len in
56- if new_len < = max_length then (
57- bprintf buf " %s" word;
58- make_lines words
59- )
60- else
61- (* The new word doesn't fit on the current line. Start a new one. *)
62- let line = finish_line () in
63- line :: make_lines orig_words
64- in
65- make_lines words
66-
67- let rewrap_paragraph ~max_length str =
68- str
69- |> split_on_blank
70- |> concatenate_into_lines ~max_length
71-
7224let docstring_escape str =
7325 (* TODO *)
7426 str
@@ -101,8 +53,7 @@ let translate_block ~max_length (block : Doc.block) : Indent.node list =
10153 | Paragraph elements ->
10254 elements
10355 |> List. map translate_inline_element
104- |> String. concat " "
105- |> rewrap_paragraph ~max_length
56+ |> Doc. rewrap_paragraph ~max_length
10657 |> List. map (fun line -> Line line)
10758
10859let make_unquoted_multiline_docstring
0 commit comments