Skip to content

Commit 5c55e4c

Browse files
committed
Attach documentation comments to Parsetree
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16189 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1 parent a90f0e4 commit 5c55e4c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1180
-395
lines changed

.depend

+16-7
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ utils/terminfo.cmx : utils/terminfo.cmi
2525
utils/warnings.cmo : utils/warnings.cmi
2626
utils/warnings.cmx : utils/warnings.cmi
2727
parsing/ast_helper.cmi : parsing/parsetree.cmi parsing/longident.cmi \
28-
parsing/location.cmi parsing/asttypes.cmi
28+
parsing/location.cmi parsing/docstrings.cmi parsing/asttypes.cmi
2929
parsing/ast_mapper.cmi : parsing/parsetree.cmi parsing/location.cmi
3030
parsing/asttypes.cmi : parsing/location.cmi
31+
parsing/docstrings.cmi : parsing/location.cmi parsing/parsetree.cmi
3132
parsing/lexer.cmi : parsing/parser.cmi parsing/location.cmi
3233
parsing/location.cmi : utils/warnings.cmi
3334
parsing/longident.cmi :
@@ -40,9 +41,11 @@ parsing/pprintast.cmi : parsing/parsetree.cmi parsing/longident.cmi \
4041
parsing/printast.cmi : parsing/parsetree.cmi
4142
parsing/syntaxerr.cmi : parsing/location.cmi
4243
parsing/ast_helper.cmo : parsing/parsetree.cmi parsing/longident.cmi \
43-
parsing/location.cmi parsing/asttypes.cmi parsing/ast_helper.cmi
44+
parsing/location.cmi parsing/docstrings.cmi parsing/asttypes.cmi \
45+
parsing/ast_helper.cmi
4446
parsing/ast_helper.cmx : parsing/parsetree.cmi parsing/longident.cmx \
45-
parsing/location.cmx parsing/asttypes.cmi parsing/ast_helper.cmi
47+
parsing/location.cmx parsing/docstrings.cmx parsing/asttypes.cmi \
48+
parsing/ast_helper.cmi
4649
parsing/ast_mapper.cmo : parsing/parsetree.cmi utils/misc.cmi \
4750
parsing/longident.cmi parsing/location.cmi utils/config.cmi \
4851
utils/clflags.cmi parsing/asttypes.cmi parsing/ast_helper.cmi \
@@ -51,20 +54,26 @@ parsing/ast_mapper.cmx : parsing/parsetree.cmi utils/misc.cmx \
5154
parsing/longident.cmx parsing/location.cmx utils/config.cmx \
5255
utils/clflags.cmx parsing/asttypes.cmi parsing/ast_helper.cmx \
5356
parsing/ast_mapper.cmi
57+
parsing/docstrings.cmo : utils/warnings.cmi parsing/location.cmi \
58+
parsing/docstrings.cmi
59+
parsing/docstrings.cmx : utils/warnings.cmx parsing/location.cmx \
60+
parsing/docstrings.cmi
5461
parsing/lexer.cmo : utils/warnings.cmi parsing/parser.cmi utils/misc.cmi \
55-
parsing/location.cmi parsing/lexer.cmi
62+
parsing/location.cmi parsing/docstrings.cmi parsing/lexer.cmi
5663
parsing/lexer.cmx : utils/warnings.cmx parsing/parser.cmx utils/misc.cmx \
57-
parsing/location.cmx parsing/lexer.cmi
64+
parsing/location.cmx parsing/docstrings.cmx parsing/lexer.cmi
5865
parsing/location.cmo : utils/warnings.cmi utils/terminfo.cmi \
5966
parsing/location.cmi
6067
parsing/location.cmx : utils/warnings.cmx utils/terminfo.cmx \
6168
parsing/location.cmi
6269
parsing/longident.cmo : utils/misc.cmi parsing/longident.cmi
6370
parsing/longident.cmx : utils/misc.cmx parsing/longident.cmi
6471
parsing/parse.cmo : parsing/syntaxerr.cmi parsing/parser.cmi \
65-
parsing/location.cmi parsing/lexer.cmi parsing/parse.cmi
72+
parsing/location.cmi parsing/lexer.cmi parsing/docstrings.cmi \
73+
parsing/parse.cmi
6674
parsing/parse.cmx : parsing/syntaxerr.cmx parsing/parser.cmx \
67-
parsing/location.cmx parsing/lexer.cmx parsing/parse.cmi
75+
parsing/location.cmx parsing/lexer.cmx parsing/docstrings.cmx \
76+
parsing/parse.cmi
6877
parsing/parser.cmo : parsing/syntaxerr.cmi parsing/parsetree.cmi \
6978
parsing/longident.cmi parsing/location.cmi utils/clflags.cmi \
7079
parsing/asttypes.cmi parsing/ast_helper.cmi parsing/parser.cmi

Changes

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ Compilers:
182182
(Alain Frisch)
183183
- GPR#159: Better locations for structure/signature items
184184
(Leo White)
185+
- GPR#149: Attach documentation comments to parse tree (Leo White)
185186

186187
Toplevel and debugger:
187188
- PR#5958: generalized polymorphic #install_printer

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ include stdlib/StdlibModules
1717

1818
CAMLC=boot/ocamlrun boot/ocamlc -nostdlib -I boot
1919
CAMLOPT=boot/ocamlrun ./ocamlopt -nostdlib -I stdlib -I otherlibs/dynlink
20-
COMPFLAGS=-strict-sequence -w +33..39+48 -warn-error A -bin-annot \
20+
COMPFLAGS=-strict-sequence -w +33..39+48+50 -warn-error A -bin-annot \
2121
-safe-string $(INCLUDES)
2222
LINKFLAGS=
2323

@@ -43,7 +43,7 @@ UTILS=utils/misc.cmo utils/tbl.cmo utils/config.cmo \
4343
utils/consistbl.cmo
4444

4545
PARSING=parsing/location.cmo parsing/longident.cmo \
46-
parsing/ast_helper.cmo \
46+
parsing/docstrings.cmo parsing/ast_helper.cmo \
4747
parsing/syntaxerr.cmo parsing/parser.cmo \
4848
parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo \
4949
parsing/pprintast.cmo \

Makefile.nt

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ UTILS=utils/misc.cmo utils/tbl.cmo utils/config.cmo \
3939
utils/consistbl.cmo
4040

4141
PARSING=parsing/location.cmo parsing/longident.cmo \
42-
parsing/ast_helper.cmo \
42+
parsing/docstrings.cmo parsing/ast_helper.cmo \
4343
parsing/syntaxerr.cmo parsing/parser.cmo \
4444
parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo \
4545
parsing/pprintast.cmo \

debugger/Makefile.shared

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ OTHEROBJS=\
3232
$(UNIXDIR)/unix.cma \
3333
../utils/misc.cmo ../utils/config.cmo ../utils/tbl.cmo \
3434
../utils/clflags.cmo ../utils/consistbl.cmo ../utils/warnings.cmo \
35-
../parsing/location.cmo ../parsing/longident.cmo \
35+
../parsing/location.cmo ../parsing/longident.cmo ../parsing/docstrings.cmo \
3636
../parsing/ast_helper.cmo ../parsing/ast_mapper.cmo \
3737
../typing/ident.cmo ../typing/path.cmo ../typing/types.cmo \
3838
../typing/btype.cmo ../typing/primitive.cmo ../typing/typedtree.cmo \

driver/compenv.ml

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ let read_OCAMLPARAM ppf position =
175175
| "verbose" -> set "verbose" [ verbose ] v
176176
| "nopervasives" -> set "nopervasives" [ nopervasives ] v
177177
| "slash" -> set "slash" [ force_slash ] v (* for ocamldep *)
178+
| "keep-docs" -> set "keep-docs" [ Clflags.keep_docs ] v
178179
| "keep-locs" -> set "keep-locs" [ Clflags.keep_locs ] v
179180

180181
| "compact" -> clear "compact" [ optimize_for_speed ] v

driver/main.ml

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ module Options = Main_args.Make_bytecomp_options (struct
8989
let _impl = impl
9090
let _intf = intf
9191
let _intf_suffix s = Config.interface_suffix := s
92+
let _keep_docs = set keep_docs
9293
let _keep_locs = set keep_locs
9394
let _labels = unset classic
9495
let _linkall = set link_everything

driver/main_args.ml

+7
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ let mk_intf_suffix_2 f =
126126
"-intf_suffix", Arg.String f, "<string> (deprecated) same as -intf-suffix"
127127
;;
128128

129+
let mk_keep_docs f =
130+
"-keep-docs", Arg.Unit f, " Keep documentation strings in .cmi files"
131+
;;
132+
129133
let mk_keep_locs f =
130134
"-keep-locs", Arg.Unit f, " Keep locations in .cmi files"
131135
;;
@@ -524,6 +528,7 @@ module type Compiler_options = sig
524528
val _impl : string -> unit
525529
val _intf : string -> unit
526530
val _intf_suffix : string -> unit
531+
val _keep_docs : unit -> unit
527532
val _keep_locs : unit -> unit
528533
val _linkall : unit -> unit
529534
val _noautolink : unit -> unit
@@ -663,6 +668,7 @@ struct
663668
mk_intf F._intf;
664669
mk_intf_suffix F._intf_suffix;
665670
mk_intf_suffix_2 F._intf_suffix;
671+
mk_keep_docs F._keep_docs;
666672
mk_keep_locs F._keep_locs;
667673
mk_labels F._labels;
668674
mk_linkall F._linkall;
@@ -782,6 +788,7 @@ struct
782788
mk_inline F._inline;
783789
mk_intf F._intf;
784790
mk_intf_suffix F._intf_suffix;
791+
mk_keep_docs F._keep_docs;
785792
mk_keep_locs F._keep_locs;
786793
mk_labels F._labels;
787794
mk_linkall F._linkall;

driver/main_args.mli

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ module type Compiler_options = sig
6262
val _impl : string -> unit
6363
val _intf : string -> unit
6464
val _intf_suffix : string -> unit
65+
val _keep_docs : unit -> unit
6566
val _keep_locs : unit -> unit
6667
val _linkall : unit -> unit
6768
val _noautolink : unit -> unit

driver/optmain.ml

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ module Options = Main_args.Make_optcomp_options (struct
8989
let _inline n = inline_threshold := n * 8
9090
let _intf = intf
9191
let _intf_suffix s = Config.interface_suffix := s
92+
let _keep_docs = set keep_docs
9293
let _keep_locs = set keep_locs
9394
let _labels = clear classic
9495
let _linkall = set link_everything

man/ocamlc.m

+19-1
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ compiled interface files (.cmi), compiled object code files
374374
.I string
375375
as interface files (instead of the default .mli).
376376
.TP
377+
.B \-keep-docs
378+
Keep documentation strings in generated .cmi files.
379+
.TP
377380
.B \-keep-locs
378381
Keep locations in generated .cmi files.
379382
.TP
@@ -829,6 +832,21 @@ compilation in any way (even if it is fatal). If a warning is enabled,
829832
45
830833
\ \ Open statement shadows an already defined label or constructor.
831834

835+
46
836+
\ \ Error in environment variable.
837+
838+
47
839+
\ \ Illegal attribute payload.
840+
841+
48
842+
\ \ Implicit elimination of optional arguments.
843+
844+
49
845+
\ \ Missing cmi file when looking up module alias.
846+
847+
50
848+
\ \ Unexpected documentation comment.
849+
832850
The letters stand for the following sets of warnings. Any letter not
833851
mentioned here corresponds to the empty set.
834852

@@ -882,7 +900,7 @@ compilation in any way (even if it is fatal). If a warning is enabled,
882900

883901
.IP
884902
The default setting is
885-
.BR \-w\ +a\-4\-6\-7\-9\-27\-29\-32..39\-41..42\-44\-45 .
903+
.BR \-w\ +a\-4\-6\-7\-9\-27\-29\-32..39\-41\-42\-44\-45\-48\-50 .
886904
Note that warnings
887905
.BR 5 \ and \ 10
888906
are not always triggered, depending on the internals of the type checker.

man/ocamlopt.m

+3
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ and libraries (.cmxa). By default, the current directory is searched
304304
as interface files (instead of the default .mli).
305305
.TP
306306
.B \-keep-locs
307+
Keep documentation strings in generated .cmi files.
308+
.TP
309+
.B \-keep-locs
307310
Keep locations in generated .cmi files.
308311
.TP
309312
.B \-labels

ocamlbuild/ocaml_specific.ml

+1
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ flag ["ocaml"; "compile"; "no_alias_deps";] (A "-no-alias-deps");;
738738
flag ["ocaml"; "compile"; "strict_formats";] (A "-strict-formats");;
739739
flag ["ocaml"; "native"; "compile"; "opaque";] (A "-opaque");;
740740
flag ["ocaml"; "native"; "compile"; "no_float_const_prop";] (A "-no-float-const-prop");
741+
flag ["ocaml"; "compile"; "keep_docs";] (A "-keep-docs");
741742
flag ["ocaml"; "compile"; "keep_locs";] (A "-keep-locs");
742743
flag ["ocaml"; "absname"; "compile"] (A "-absname");;
743744
flag ["ocaml"; "absname"; "infer_interface"] (A "-absname");;

otherlibs/dynlink/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ COMPILEROBJS=\
3232
../../utils/terminfo.cmo ../../utils/warnings.cmo \
3333
../../parsing/asttypes.cmi \
3434
../../parsing/location.cmo ../../parsing/longident.cmo \
35-
../../parsing/ast_helper.cmo \
35+
../../parsing/docstrings.cmo ../../parsing/ast_helper.cmo \
3636
../../parsing/ast_mapper.cmo \
3737
../../typing/ident.cmo ../../typing/path.cmo \
3838
../../typing/primitive.cmo ../../typing/types.cmo \

0 commit comments

Comments
 (0)