Skip to content

Commit 9d9dd1b

Browse files
committed
better layout documentation string
1 parent 25451f2 commit 9d9dd1b

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

jscomp/bsb/bsb_arg.ml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,25 @@
7373
buf +> " ";
7474
buf +> key ;
7575
buf +> (String.make (!max_col - String.length key + 2 ) ' ');
76-
buf +> doc;
76+
let cur = ref 0 in
77+
let doc_length = String.length doc in
78+
while !cur < doc_length do
79+
match String.index_from_opt doc !cur '\n' with
80+
| None ->
81+
if !cur <> 0 then begin
82+
buf +> "\n";
83+
buf +> String.make (!max_col + 4) ' ' ;
84+
end;
85+
buf +> String.sub doc !cur (String.length doc - !cur );
86+
cur := doc_length
87+
| Some new_line_pos ->
88+
if !cur <> 0 then begin
89+
buf +> "\n";
90+
buf +> String.make (!max_col + 4) ' ' ;
91+
end;
92+
buf +> String.sub doc !cur (new_line_pos - !cur );
93+
cur := new_line_pos + 1
94+
done ;
7795
buf +> "\n"
7896
)
7997
;;

jscomp/main/bsb_main.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ let bsb_main_flags : (string * spec * string) list=
6262
"-install", unit_set_spec do_install,
6363
"Install public interface files into lib/ocaml";
6464
"-init", String (String_call (fun path -> generate_theme_with_path := Some path)),
65-
"Init sample project to get started. Note (`bsb -init sample` will create a sample project while `bsb -init .` will reuse current directory)";
65+
"Init sample project to get started. \n\
66+
Note (`bsb -init sample` will create a sample project while \n\
67+
`bsb -init .` will reuse current directory)";
6668
"-theme", String (String_set current_theme),
67-
"The theme for project initialization, default is basic(https://github.com/bucklescript/bucklescript/tree/master/jscomp/bsb/templates)";
69+
"The theme for project initialization. \n\
70+
default is basic:\n\
71+
https://github.com/bucklescript/bucklescript/tree/master/jscomp/bsb/templates";
6872

6973
"-regen", unit_set_spec force_regenerate,
7074
"(internal) Always regenerate build.ninja no matter bsconfig.json is changed or not (for debugging purpose)";
@@ -78,7 +82,10 @@ let bsb_main_flags : (string * spec * string) list=
7882
we make it at this time to make `bsb -help` easier
7983
*)
8084
"-ws", call_spec ignore,
81-
"[host:]port specify a websocket number (and optionally, a host). When a build finishes, we send a message to that port. For tools that listen on build completion." ;
85+
"[host:]port \n\
86+
specify a websocket number (and optionally, a host). \n\
87+
When a build finishes, we send a message to that port. \n\
88+
For tools that listen on build completion." ;
8289
#if BS_NATIVE then
8390
"-backend", String (String_call (fun s ->
8491
match s with

0 commit comments

Comments
 (0)