summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxence Guesdon <maxence.guesdon@inria.fr>2010-08-24 09:45:45 +0000
committerMaxence Guesdon <maxence.guesdon@inria.fr>2010-08-24 09:45:45 +0000
commit0936bb2811303dba3510d476253a3653903e9f58 (patch)
tree1c17a8df5ef96f4b786ade6cb0243ffbe25783fa
parent575555eecd11fcc745e0f1e88d090764b3291b63 (diff)
downloadocaml-0936bb2811303dba3510d476253a3653903e9f58.tar.gz
use first-class modules to allow composition of custom generators
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10652 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--ocamldoc/.depend96
-rw-r--r--ocamldoc/Makefile5
-rw-r--r--ocamldoc/generators/.gitignore0
-rw-r--r--ocamldoc/odoc.ml26
-rw-r--r--ocamldoc/odoc_analyse.ml32
-rw-r--r--ocamldoc/odoc_analyse.mli2
-rw-r--r--ocamldoc/odoc_args.ml300
-rw-r--r--ocamldoc/odoc_args.mli173
-rw-r--r--ocamldoc/odoc_ast.ml10
-rw-r--r--ocamldoc/odoc_cross.ml6
-rw-r--r--ocamldoc/odoc_dot.ml31
-rw-r--r--ocamldoc/odoc_gen.ml38
-rw-r--r--ocamldoc/odoc_gen.mli22
-rw-r--r--ocamldoc/odoc_global.ml71
-rw-r--r--ocamldoc/odoc_global.mli84
-rw-r--r--ocamldoc/odoc_html.ml75
-rw-r--r--ocamldoc/odoc_info.ml18
-rw-r--r--ocamldoc/odoc_info.mli159
-rw-r--r--ocamldoc/odoc_latex.ml69
-rw-r--r--ocamldoc/odoc_lexer.mll8
-rw-r--r--ocamldoc/odoc_man.ml37
-rw-r--r--ocamldoc/odoc_merge.ml28
-rw-r--r--ocamldoc/odoc_messages.ml3
-rw-r--r--ocamldoc/odoc_sig.ml10
-rw-r--r--ocamldoc/odoc_test.ml14
-rw-r--r--ocamldoc/odoc_texi.ml48
26 files changed, 639 insertions, 726 deletions
diff --git a/ocamldoc/.depend b/ocamldoc/.depend
index 355a0a2fc3..3292e5946b 100644
--- a/ocamldoc/.depend
+++ b/ocamldoc/.depend
@@ -14,10 +14,10 @@ odoc_analyse.cmo: ../utils/warnings.cmi ../typing/typetexp.cmi \
odoc_text.cmi odoc_sig.cmi odoc_module.cmo odoc_misc.cmi \
odoc_messages.cmo odoc_merge.cmi odoc_global.cmi odoc_dep.cmo \
odoc_cross.cmi odoc_comments.cmi odoc_class.cmo odoc_ast.cmi \
- odoc_args.cmi ../utils/misc.cmi ../parsing/location.cmi \
- ../parsing/lexer.cmi ../typing/includemod.cmi ../typing/env.cmi \
- ../typing/ctype.cmi ../utils/config.cmi ../utils/clflags.cmi \
- ../utils/ccomp.cmi odoc_analyse.cmi
+ ../utils/misc.cmi ../parsing/location.cmi ../parsing/lexer.cmi \
+ ../typing/includemod.cmi ../typing/env.cmi ../typing/ctype.cmi \
+ ../utils/config.cmi ../utils/clflags.cmi ../utils/ccomp.cmi \
+ odoc_analyse.cmi
odoc_analyse.cmx: ../utils/warnings.cmx ../typing/typetexp.cmx \
../typing/types.cmx ../typing/typemod.cmx ../typing/typedtree.cmx \
../typing/typedecl.cmx ../typing/typecore.cmx ../typing/typeclass.cmx \
@@ -26,30 +26,30 @@ odoc_analyse.cmx: ../utils/warnings.cmx ../typing/typetexp.cmx \
odoc_text.cmx odoc_sig.cmx odoc_module.cmx odoc_misc.cmx \
odoc_messages.cmx odoc_merge.cmx odoc_global.cmx odoc_dep.cmx \
odoc_cross.cmx odoc_comments.cmx odoc_class.cmx odoc_ast.cmx \
- odoc_args.cmx ../utils/misc.cmx ../parsing/location.cmx \
- ../parsing/lexer.cmx ../typing/includemod.cmx ../typing/env.cmx \
- ../typing/ctype.cmx ../utils/config.cmx ../utils/clflags.cmx \
- ../utils/ccomp.cmx odoc_analyse.cmi
-odoc_args.cmo: odoc_types.cmi odoc_module.cmo odoc_messages.cmo \
- odoc_global.cmi odoc_config.cmi ../utils/misc.cmi ../utils/config.cmi \
- ../utils/clflags.cmi odoc_args.cmi
-odoc_args.cmx: odoc_types.cmx odoc_module.cmx odoc_messages.cmx \
- odoc_global.cmx odoc_config.cmx ../utils/misc.cmx ../utils/config.cmx \
- ../utils/clflags.cmx odoc_args.cmi
+ ../utils/misc.cmx ../parsing/location.cmx ../parsing/lexer.cmx \
+ ../typing/includemod.cmx ../typing/env.cmx ../typing/ctype.cmx \
+ ../utils/config.cmx ../utils/clflags.cmx ../utils/ccomp.cmx \
+ odoc_analyse.cmi
+odoc_args.cmo: odoc_types.cmi odoc_texi.cmo odoc_messages.cmo odoc_man.cmo \
+ odoc_latex.cmo odoc_html.cmo odoc_global.cmi odoc_gen.cmi odoc_dot.cmo \
+ odoc_config.cmi ../utils/misc.cmi ../utils/config.cmi odoc_args.cmi
+odoc_args.cmx: odoc_types.cmx odoc_texi.cmx odoc_messages.cmx odoc_man.cmx \
+ odoc_latex.cmx odoc_html.cmx odoc_global.cmx odoc_gen.cmx odoc_dot.cmx \
+ odoc_config.cmx ../utils/misc.cmx ../utils/config.cmx odoc_args.cmi
odoc_ast.cmo: ../typing/types.cmi ../typing/typedtree.cmi \
../typing/predef.cmi ../typing/path.cmi ../parsing/parsetree.cmi \
odoc_value.cmo odoc_types.cmi odoc_type.cmo odoc_sig.cmi \
odoc_parameter.cmo odoc_name.cmi odoc_module.cmo odoc_messages.cmo \
odoc_global.cmi odoc_exception.cmo odoc_env.cmi odoc_class.cmo \
- odoc_args.cmi ../utils/misc.cmi ../parsing/location.cmi \
- ../typing/ident.cmi ../parsing/asttypes.cmi odoc_ast.cmi
+ ../utils/misc.cmi ../parsing/location.cmi ../typing/ident.cmi \
+ ../parsing/asttypes.cmi odoc_ast.cmi
odoc_ast.cmx: ../typing/types.cmx ../typing/typedtree.cmx \
../typing/predef.cmx ../typing/path.cmx ../parsing/parsetree.cmi \
odoc_value.cmx odoc_types.cmx odoc_type.cmx odoc_sig.cmx \
odoc_parameter.cmx odoc_name.cmx odoc_module.cmx odoc_messages.cmx \
odoc_global.cmx odoc_exception.cmx odoc_env.cmx odoc_class.cmx \
- odoc_args.cmx ../utils/misc.cmx ../parsing/location.cmx \
- ../typing/ident.cmx ../parsing/asttypes.cmi odoc_ast.cmi
+ ../utils/misc.cmx ../parsing/location.cmx ../typing/ident.cmx \
+ ../parsing/asttypes.cmi odoc_ast.cmi
odoc_class.cmo: ../typing/types.cmi odoc_value.cmo odoc_types.cmi \
odoc_parameter.cmo odoc_name.cmi
odoc_class.cmx: ../typing/types.cmx odoc_value.cmx odoc_types.cmx \
@@ -82,32 +82,38 @@ odoc_dep.cmo: ../parsing/parsetree.cmi odoc_type.cmo odoc_print.cmi \
odoc_module.cmo ../tools/depend.cmi
odoc_dep.cmx: ../parsing/parsetree.cmi odoc_type.cmx odoc_print.cmx \
odoc_module.cmx ../tools/depend.cmx
-odoc_dot.cmo: odoc_info.cmi
-odoc_dot.cmx: odoc_info.cmx
+odoc_dot.cmo: odoc_messages.cmo odoc_info.cmi
+odoc_dot.cmx: odoc_messages.cmx odoc_info.cmx
odoc_env.cmo: ../typing/types.cmi ../typing/printtyp.cmi ../typing/predef.cmi \
../typing/path.cmi odoc_name.cmi ../typing/btype.cmi odoc_env.cmi
odoc_env.cmx: ../typing/types.cmx ../typing/printtyp.cmx ../typing/predef.cmx \
../typing/path.cmx odoc_name.cmx ../typing/btype.cmx odoc_env.cmi
odoc_exception.cmo: ../typing/types.cmi odoc_types.cmi odoc_name.cmi
odoc_exception.cmx: ../typing/types.cmx odoc_types.cmx odoc_name.cmx
-odoc_global.cmo: ../utils/clflags.cmi odoc_global.cmi
-odoc_global.cmx: ../utils/clflags.cmx odoc_global.cmi
+odoc_gen.cmo: odoc_texi.cmo odoc_module.cmo odoc_man.cmo odoc_latex.cmo \
+ odoc_html.cmo odoc_dot.cmo odoc_gen.cmi
+odoc_gen.cmx: odoc_texi.cmx odoc_module.cmx odoc_man.cmx odoc_latex.cmx \
+ odoc_html.cmx odoc_dot.cmx odoc_gen.cmi
+odoc_global.cmo: odoc_types.cmi odoc_messages.cmo ../utils/clflags.cmi \
+ odoc_global.cmi
+odoc_global.cmx: odoc_types.cmx odoc_messages.cmx ../utils/clflags.cmx \
+ odoc_global.cmi
odoc_html.cmo: odoc_text.cmi odoc_ocamlhtml.cmo odoc_messages.cmo \
- odoc_info.cmi odoc_dag2html.cmi odoc_args.cmi ../parsing/asttypes.cmi
+ odoc_info.cmi odoc_global.cmi odoc_dag2html.cmi ../parsing/asttypes.cmi
odoc_html.cmx: odoc_text.cmx odoc_ocamlhtml.cmx odoc_messages.cmx \
- odoc_info.cmx odoc_dag2html.cmx odoc_args.cmx ../parsing/asttypes.cmi
+ odoc_info.cmx odoc_global.cmx odoc_dag2html.cmx ../parsing/asttypes.cmi
odoc_info.cmo: ../typing/printtyp.cmi odoc_value.cmo odoc_types.cmi \
odoc_type.cmo odoc_text.cmi odoc_str.cmi odoc_search.cmi odoc_scan.cmo \
odoc_print.cmi odoc_parameter.cmo odoc_name.cmi odoc_module.cmo \
odoc_misc.cmi odoc_messages.cmo odoc_global.cmi odoc_exception.cmo \
odoc_dep.cmo odoc_config.cmi odoc_comments.cmi odoc_class.cmo \
- odoc_args.cmi odoc_analyse.cmi odoc_info.cmi
+ odoc_analyse.cmi odoc_info.cmi
odoc_info.cmx: ../typing/printtyp.cmx odoc_value.cmx odoc_types.cmx \
odoc_type.cmx odoc_text.cmx odoc_str.cmx odoc_search.cmx odoc_scan.cmx \
odoc_print.cmx odoc_parameter.cmx odoc_name.cmx odoc_module.cmx \
odoc_misc.cmx odoc_messages.cmx odoc_global.cmx odoc_exception.cmx \
odoc_dep.cmx odoc_config.cmx odoc_comments.cmx odoc_class.cmx \
- odoc_args.cmx odoc_analyse.cmx odoc_info.cmi
+ odoc_analyse.cmx odoc_info.cmi
odoc_inherit.cmo:
odoc_inherit.cmx:
odoc_latex.cmo: odoc_to_text.cmo odoc_messages.cmo odoc_latex_style.cmo \
@@ -116,20 +122,20 @@ odoc_latex.cmx: odoc_to_text.cmx odoc_messages.cmx odoc_latex_style.cmx \
odoc_info.cmx ../parsing/asttypes.cmi
odoc_latex_style.cmo:
odoc_latex_style.cmx:
-odoc_lexer.cmo: odoc_parser.cmi odoc_messages.cmo odoc_comments_global.cmi \
- odoc_args.cmi
-odoc_lexer.cmx: odoc_parser.cmx odoc_messages.cmx odoc_comments_global.cmx \
- odoc_args.cmx
+odoc_lexer.cmo: odoc_parser.cmi odoc_messages.cmo odoc_global.cmi \
+ odoc_comments_global.cmi
+odoc_lexer.cmx: odoc_parser.cmx odoc_messages.cmx odoc_global.cmx \
+ odoc_comments_global.cmx
odoc_man.cmo: odoc_str.cmi odoc_print.cmi odoc_misc.cmi odoc_messages.cmo \
- odoc_info.cmi odoc_args.cmi ../parsing/asttypes.cmi
+ odoc_info.cmi ../parsing/asttypes.cmi
odoc_man.cmx: odoc_str.cmx odoc_print.cmx odoc_misc.cmx odoc_messages.cmx \
- odoc_info.cmx odoc_args.cmx ../parsing/asttypes.cmi
+ odoc_info.cmx ../parsing/asttypes.cmi
odoc_merge.cmo: odoc_value.cmo odoc_types.cmi odoc_type.cmo \
odoc_parameter.cmo odoc_name.cmi odoc_module.cmo odoc_messages.cmo \
- odoc_exception.cmo odoc_class.cmo odoc_args.cmi odoc_merge.cmi
+ odoc_global.cmi odoc_exception.cmo odoc_class.cmo odoc_merge.cmi
odoc_merge.cmx: odoc_value.cmx odoc_types.cmx odoc_type.cmx \
odoc_parameter.cmx odoc_name.cmx odoc_module.cmx odoc_messages.cmx \
- odoc_exception.cmx odoc_class.cmx odoc_args.cmx odoc_merge.cmi
+ odoc_global.cmx odoc_exception.cmx odoc_class.cmx odoc_merge.cmi
odoc_messages.cmo: odoc_global.cmi odoc_config.cmi ../utils/config.cmi
odoc_messages.cmx: odoc_global.cmx odoc_config.cmx ../utils/config.cmx
odoc_misc.cmo: ../typing/types.cmi ../typing/predef.cmi ../typing/path.cmi \
@@ -170,16 +176,14 @@ odoc_sig.cmo: ../typing/types.cmi ../typing/typedtree.cmi ../typing/path.cmi \
../parsing/parsetree.cmi odoc_value.cmo odoc_types.cmi odoc_type.cmo \
odoc_parameter.cmo odoc_name.cmi odoc_module.cmo odoc_misc.cmi \
odoc_messages.cmo odoc_merge.cmi odoc_global.cmi odoc_exception.cmo \
- odoc_env.cmi odoc_class.cmo odoc_args.cmi ../utils/misc.cmi \
- ../parsing/location.cmi ../typing/btype.cmi ../parsing/asttypes.cmi \
- odoc_sig.cmi
+ odoc_env.cmi odoc_class.cmo ../utils/misc.cmi ../parsing/location.cmi \
+ ../typing/btype.cmi ../parsing/asttypes.cmi odoc_sig.cmi
odoc_sig.cmx: ../typing/types.cmx ../typing/typedtree.cmx ../typing/path.cmx \
../parsing/parsetree.cmi odoc_value.cmx odoc_types.cmx odoc_type.cmx \
odoc_parameter.cmx odoc_name.cmx odoc_module.cmx odoc_misc.cmx \
odoc_messages.cmx odoc_merge.cmx odoc_global.cmx odoc_exception.cmx \
- odoc_env.cmx odoc_class.cmx odoc_args.cmx ../utils/misc.cmx \
- ../parsing/location.cmx ../typing/btype.cmx ../parsing/asttypes.cmi \
- odoc_sig.cmi
+ odoc_env.cmx odoc_class.cmx ../utils/misc.cmx ../parsing/location.cmx \
+ ../typing/btype.cmx ../parsing/asttypes.cmi odoc_sig.cmi
odoc_str.cmo: ../typing/types.cmi ../typing/printtyp.cmi odoc_value.cmo \
odoc_type.cmo odoc_print.cmi odoc_name.cmi odoc_misc.cmi \
odoc_messages.cmo odoc_exception.cmo odoc_class.cmo \
@@ -214,8 +218,10 @@ odoc_value.cmo: ../typing/types.cmi ../typing/printtyp.cmi odoc_types.cmi \
odoc_parameter.cmo odoc_name.cmi
odoc_value.cmx: ../typing/types.cmx ../typing/printtyp.cmx odoc_types.cmx \
odoc_parameter.cmx odoc_name.cmx
-odoc_analyse.cmi: odoc_module.cmo odoc_args.cmi
-odoc_args.cmi: odoc_types.cmi odoc_module.cmo
+t.cmo:
+t.cmx:
+odoc_analyse.cmi: odoc_module.cmo odoc_global.cmi
+odoc_args.cmi: odoc_gen.cmi
odoc_ast.cmi: ../typing/types.cmi ../typing/typedtree.cmi ../typing/path.cmi \
../parsing/parsetree.cmi odoc_sig.cmi odoc_name.cmi odoc_module.cmo
odoc_comments.cmi: odoc_types.cmi odoc_module.cmo
@@ -224,10 +230,12 @@ odoc_config.cmi:
odoc_cross.cmi: odoc_types.cmi odoc_module.cmo
odoc_dag2html.cmi: odoc_info.cmi
odoc_env.cmi: ../typing/types.cmi odoc_name.cmi
-odoc_global.cmi:
+odoc_gen.cmi: odoc_texi.cmo odoc_module.cmo odoc_man.cmo odoc_latex.cmo \
+ odoc_html.cmo odoc_dot.cmo
+odoc_global.cmi: odoc_types.cmi
odoc_info.cmi: ../typing/types.cmi odoc_value.cmo odoc_types.cmi \
odoc_type.cmo odoc_search.cmi odoc_parameter.cmo odoc_module.cmo \
- odoc_exception.cmo odoc_class.cmo
+ odoc_global.cmi odoc_exception.cmo odoc_class.cmo
odoc_merge.cmi: odoc_types.cmi odoc_module.cmo
odoc_misc.cmi: ../typing/types.cmi odoc_types.cmi ../parsing/longident.cmi
odoc_name.cmi: ../typing/path.cmi ../parsing/longident.cmi \
diff --git a/ocamldoc/Makefile b/ocamldoc/Makefile
index 7ed30908df..198bbf8c8c 100644
--- a/ocamldoc/Makefile
+++ b/ocamldoc/Makefile
@@ -72,8 +72,8 @@ COMPFLAGS=$(INCLUDES) -warn-error A
LINKFLAGS=$(INCLUDES) -nostdlib
CMOFILES= odoc_config.cmo \
- odoc_global.cmo\
odoc_messages.cmo\
+ odoc_global.cmo\
odoc_types.cmo\
odoc_misc.cmo\
odoc_text_parser.cmo\
@@ -88,7 +88,6 @@ CMOFILES= odoc_config.cmo \
odoc_module.cmo\
odoc_print.cmo \
odoc_str.cmo\
- odoc_args.cmo\
odoc_comments_global.cmo\
odoc_parser.cmo\
odoc_lexer.cmo\
@@ -121,6 +120,8 @@ EXECMOFILES=$(CMOFILES) \
odoc_latex.cmo \
odoc_texi.cmo \
odoc_dot.cmo \
+ odoc_gen.cmo \
+ odoc_args.cmo\
odoc.cmo
EXECMXFILES= $(EXECMOFILES:.cmo=.cmx)
diff --git a/ocamldoc/generators/.gitignore b/ocamldoc/generators/.gitignore
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/ocamldoc/generators/.gitignore
diff --git a/ocamldoc/odoc.ml b/ocamldoc/odoc.ml
index 5ecf70515c..4410804c87 100644
--- a/ocamldoc/odoc.ml
+++ b/ocamldoc/odoc.ml
@@ -85,19 +85,9 @@ let _ =
prerr_endline (Odoc_messages.load_file_error file s);
exit 1
-let _ = print_DEBUG "Fin du chargement dynamique eventuel"
+let () = print_DEBUG "Fin du chargement dynamique eventuel"
-let default_html_generator = new Odoc_html.html
-let default_latex_generator = new Odoc_latex.latex
-let default_texi_generator = new Odoc_texi.texi
-let default_man_generator = new Odoc_man.man
-let default_dot_generator = new Odoc_dot.dot
-let _ = Odoc_args.parse
- (default_html_generator :> Odoc_args.doc_generator)
- (default_latex_generator :> Odoc_args.doc_generator)
- (default_texi_generator :> Odoc_args.doc_generator)
- (default_man_generator :> Odoc_args.doc_generator)
- (default_dot_generator :> Odoc_args.doc_generator)
+let () = Odoc_args.parse ()
let loaded_modules =
@@ -114,13 +104,13 @@ let loaded_modules =
incr Odoc_global.errors ;
[]
)
- !Odoc_args.load
+ !Odoc_global.load
)
-let modules = Odoc_analyse.analyse_files ~init: loaded_modules !Odoc_args.files
+let modules = Odoc_analyse.analyse_files ~init: loaded_modules !Odoc_global.files
let _ =
- match !Odoc_args.dump with
+ match !Odoc_global.dump with
None -> ()
| Some f ->
try Odoc_analyse.dump_modules f modules
@@ -128,13 +118,15 @@ let _ =
prerr_endline s ;
incr Odoc_global.errors
+
let _ =
- match !Odoc_args.doc_generator with
+ match !Odoc_args.current_generator with
None ->
()
| Some gen ->
+ let generator = Odoc_gen.get_minimal_generator gen in
Odoc_info.verbose Odoc_messages.generating_doc;
- gen#generate modules;
+ generator#generate modules;
Odoc_info.verbose Odoc_messages.ok
let _ =
diff --git a/ocamldoc/odoc_analyse.ml b/ocamldoc/odoc_analyse.ml
index 143da019d3..2091dd3967 100644
--- a/ocamldoc/odoc_analyse.ml
+++ b/ocamldoc/odoc_analyse.ml
@@ -203,18 +203,18 @@ let process_error exn =
(** Process the given file, according to its extension. Return the Module.t created, if any.*)
let process_file ppf sourcefile =
- if !Odoc_args.verbose then
+ if !Odoc_global.verbose then
(
let f = match sourcefile with
- Odoc_args.Impl_file f
- | Odoc_args.Intf_file f -> f
- | Odoc_args.Text_file f -> f
+ Odoc_global.Impl_file f
+ | Odoc_global.Intf_file f -> f
+ | Odoc_global.Text_file f -> f
in
print_string (Odoc_messages.analysing f) ;
print_newline ();
);
match sourcefile with
- Odoc_args.Impl_file file ->
+ Odoc_global.Impl_file file ->
(
Location.input_name := file;
try
@@ -228,7 +228,7 @@ let process_file ppf sourcefile =
in
file_module.Odoc_module.m_top_deps <- Odoc_dep.impl_dependencies parsetree ;
- if !Odoc_args.verbose then
+ if !Odoc_global.verbose then
(
print_string Odoc_messages.ok;
print_newline ()
@@ -246,7 +246,7 @@ let process_file ppf sourcefile =
incr Odoc_global.errors ;
None
)
- | Odoc_args.Intf_file file ->
+ | Odoc_global.Intf_file file ->
(
Location.input_name := file;
try
@@ -257,7 +257,7 @@ let process_file ppf sourcefile =
file_module.Odoc_module.m_top_deps <- Odoc_dep.intf_dependencies ast ;
- if !Odoc_args.verbose then
+ if !Odoc_global.verbose then
(
print_string Odoc_messages.ok;
print_newline ()
@@ -275,7 +275,7 @@ let process_file ppf sourcefile =
incr Odoc_global.errors ;
None
)
- | Odoc_args.Text_file file ->
+ | Odoc_global.Text_file file ->
Location.input_name := file;
try
let mod_name =
@@ -474,20 +474,20 @@ let analyse_files ?(init=[]) files =
in
(* Remove elements between the stop special comments, if needed. *)
let modules =
- if !Odoc_args.no_stop then
+ if !Odoc_global.no_stop then
modules_pre
else
remove_elements_between_stop modules_pre
in
- if !Odoc_args.verbose then
+ if !Odoc_global.verbose then
(
print_string Odoc_messages.merging;
print_newline ()
);
- let merged_modules = Odoc_merge.merge !Odoc_args.merge_options modules in
- if !Odoc_args.verbose then
+ let merged_modules = Odoc_merge.merge !Odoc_global.merge_options modules in
+ if !Odoc_global.verbose then
(
print_string Odoc_messages.ok;
print_newline ();
@@ -499,20 +499,20 @@ let analyse_files ?(init=[]) files =
merged_modules
)
in
- if !Odoc_args.verbose then
+ if !Odoc_global.verbose then
(
print_string Odoc_messages.cross_referencing;
print_newline ()
);
let _ = Odoc_cross.associate modules_list in
- if !Odoc_args.verbose then
+ if !Odoc_global.verbose then
(
print_string Odoc_messages.ok;
print_newline ();
);
- if !Odoc_args.sort_modules then
+ if !Odoc_global.sort_modules then
Sort.list (fun m1 -> fun m2 -> m1.Odoc_module.m_name < m2.Odoc_module.m_name) merged_modules
else
merged_modules
diff --git a/ocamldoc/odoc_analyse.mli b/ocamldoc/odoc_analyse.mli
index e9be5ba5b7..b927ad4a06 100644
--- a/ocamldoc/odoc_analyse.mli
+++ b/ocamldoc/odoc_analyse.mli
@@ -19,7 +19,7 @@
*)
val analyse_files :
?init: Odoc_module.t_module list ->
- Odoc_args.source_file list ->
+ Odoc_global.source_file list ->
Odoc_module.t_module list
(** Dump of a list of modules into a file.
diff --git a/ocamldoc/odoc_args.ml b/ocamldoc/odoc_args.ml
index 26af27d9f3..f3500f51d3 100644
--- a/ocamldoc/odoc_args.ml
+++ b/ocamldoc/odoc_args.ml
@@ -13,40 +13,9 @@
(** Command-line arguments. *)
-open Clflags
-
module M = Odoc_messages
-type source_file =
- Impl_file of string
- | Intf_file of string
- | Text_file of string
-
-let include_dirs = Clflags.include_dirs
-
-class type doc_generator =
- object
- method generate : Odoc_module.t_module list -> unit
- end
-
-let doc_generator = ref (None : doc_generator option)
-
-let merge_options = ref ([] : Odoc_types.merge_option list)
-
-let out_file = ref M.default_out_file
-
-let dot_include_all = ref false
-
-let dot_types = ref false
-
-let dot_reduce = ref false
-
-let dot_colors = ref (List.flatten M.default_dot_colors)
-
-let man_suffix = ref M.default_man_suffix
-let man_section = ref M.default_man_section
-
-let man_mini = ref false
+let current_generator = ref (None : Odoc_gen.generator option)
(** Analysis of a string defining options. Return the list of
options according to the list giving associations between
@@ -80,77 +49,6 @@ let analyse_merge_options s =
in
analyse_option_string l s
-let classic = Clflags.classic
-
-let dump = ref (None : string option)
-
-let load = ref ([] : string list)
-
-(** Allow arbitrary recursive types. *)
-let recursive_types = Clflags.recursive_types
-
-let verbose = ref false
-
-(** Optional preprocessor command. *)
-let preprocessor = Clflags.preprocessor
-
-let sort_modules = ref false
-
-let no_custom_tags = ref false
-
-let no_stop = ref false
-
-let remove_stars = ref false
-
-let keep_code = ref false
-
-let inverse_merge_ml_mli = ref false
-
-let filter_with_module_constraints = ref true
-
-let title = ref (None : string option)
-
-let intro_file = ref (None : string option)
-
-let with_parameter_list = ref false
-
-let hidden_modules = ref ([] : string list)
-
-let target_dir = ref Filename.current_dir_name
-
-let css_style = ref None
-
-let index_only = ref false
-
-let colorize_code = ref false
-
-let html_short_functors = ref false
-
-let with_header = ref true
-
-let with_trailer = ref true
-
-let separate_files = ref false
-
-let latex_titles = ref [
- 1, "section" ;
- 2, "subsection" ;
- 3, "subsubsection" ;
- 4, "paragraph" ;
- 5, "subparagraph" ;
-]
-
-let with_toc = ref true
-
-let with_index = ref true
-
-let esc_8bits = ref false
-
-let info_section = ref "Objective Caml"
-
-let info_entry = ref []
-
-let files = ref []
let f_latex_title s =
try
@@ -158,8 +56,8 @@ let f_latex_title s =
let n = int_of_string (String.sub s 0 pos) in
let len = String.length s in
let command = String.sub s (pos + 1) (len - pos - 1) in
- latex_titles := List.remove_assoc n !latex_titles ;
- latex_titles := (n, command) :: !latex_titles
+ Odoc_latex.latex_titles := List.remove_assoc n !Odoc_latex.latex_titles ;
+ Odoc_latex.latex_titles := (n, command) :: !Odoc_latex.latex_titles
with
Not_found
| Invalid_argument _ ->
@@ -175,83 +73,77 @@ let add_hidden_modules s =
"" -> ()
| _ ->
match name.[0] with
- 'A'..'Z' -> hidden_modules := name :: !hidden_modules
+ 'A'..'Z' -> Odoc_global.hidden_modules := name :: !Odoc_global.hidden_modules
| _ ->
incr Odoc_global.errors;
prerr_endline (M.not_a_module_name name)
)
l
-let latex_value_prefix = ref M.default_latex_value_prefix
-let latex_type_prefix = ref M.default_latex_type_prefix
-let latex_exception_prefix = ref M.default_latex_exception_prefix
-let latex_module_prefix = ref M.default_latex_module_prefix
-let latex_module_type_prefix = ref M.default_latex_module_type_prefix
-let latex_class_prefix = ref M.default_latex_class_prefix
-let latex_class_type_prefix = ref M.default_latex_class_type_prefix
-let latex_attribute_prefix = ref M.default_latex_attribute_prefix
-let latex_method_prefix = ref M.default_latex_method_prefix
-
-let set_doc_generator (dg_opt : doc_generator option) = doc_generator := dg_opt
-
-(** The default html generator. Initialized in the parse function, to be used during the command line analysis.*)
-let default_html_generator = ref (None : doc_generator option)
-
-(** The default latex generator. Initialized in the parse function, to be used during the command line analysis.*)
-let default_latex_generator = ref (None : doc_generator option)
-
-(** The default texinfo generator. Initialized in the parse function, to be used during the command line analysis.*)
-let default_texi_generator = ref (None : doc_generator option)
-
-(** The default man pages generator. Initialized in the parse function, to be used during the command line analysis.*)
-let default_man_generator = ref (None : doc_generator option)
-
-(** The default dot generator. Initialized in the parse function, to be used during the command line analysis.*)
-let default_dot_generator = ref (None : doc_generator option)
+let set_generator (g : Odoc_gen.generator) = current_generator := Some g
(** The default option list *)
let options = ref [
"-version", Arg.Unit (fun () -> print_string M.message_version ; print_newline () ; exit 0) , M.option_version ;
"-vnum", Arg.Unit (fun () -> print_string M.config_version ;
print_newline () ; exit 0) , M.option_version ;
- "-v", Arg.Unit (fun () -> verbose := true), M.verbose_mode ;
- "-I", Arg.String (fun s -> include_dirs := (Misc.expand_directory Config.standard_library s) :: !include_dirs), M.include_dirs ;
- "-pp", Arg.String (fun s -> preprocessor := Some s), M.preprocess ;
- "-impl", Arg.String (fun s -> files := !files @ [Impl_file s]), M.option_impl ;
- "-intf", Arg.String (fun s -> files := !files @ [Intf_file s]), M.option_intf ;
- "-text", Arg.String (fun s -> files := !files @ [Text_file s]), M.option_text ;
- "-rectypes", Arg.Set recursive_types, M.rectypes ;
- "-nolabels", Arg.Unit (fun () -> classic := true), M.nolabels ;
+ "-v", Arg.Unit (fun () -> Odoc_global.verbose := true), M.verbose_mode ;
+ "-I", Arg.String (fun s ->
+ Odoc_global.include_dirs :=
+ (Misc.expand_directory Config.standard_library s) :: !Odoc_global.include_dirs),
+ M.include_dirs ;
+ "-pp", Arg.String (fun s -> Odoc_global.preprocessor := Some s), M.preprocess ;
+ "-impl", Arg.String (fun s ->
+ Odoc_global.files := !Odoc_global.files @ [Odoc_global.Impl_file s]),
+ M.option_impl ;
+ "-intf", Arg.String (fun s ->
+ Odoc_global.files := !Odoc_global.files @ [Odoc_global.Intf_file s]),
+ M.option_intf ;
+ "-text", Arg.String (fun s ->
+ Odoc_global.files := !Odoc_global.files @ [Odoc_global.Text_file s]),
+ M.option_text ;
+ "-rectypes", Arg.Set Odoc_global.recursive_types, M.rectypes ;
+ "-nolabels", Arg.Unit (fun () -> Odoc_global.classic := true), M.nolabels ;
"-warn-error", Arg.Set Odoc_global.warn_error, M.werr ;
"-hide-warnings", Arg.Clear Odoc_config.print_warnings, M.hide_warnings ;
- "-o", Arg.String (fun s -> out_file := s), M.out_file ;
- "-d", Arg.String (fun s -> target_dir := s), M.target_dir ;
- "-sort", Arg.Unit (fun () -> sort_modules := true), M.sort_modules ;
- "-no-stop", Arg.Set no_stop, M.no_stop ;
- "-no-custom-tags", Arg.Set no_custom_tags, M.no_custom_tags ;
- "-stars", Arg.Set remove_stars, M.remove_stars ;
- "-inv-merge-ml-mli", Arg.Set inverse_merge_ml_mli, M.inverse_merge_ml_mli ;
- "-no-module-constraint-filter", Arg.Clear filter_with_module_constraints,
+ "-o", Arg.String (fun s -> Odoc_global.out_file := s), M.out_file ;
+ "-d", Arg.String (fun s -> Odoc_global.target_dir := s), M.target_dir ;
+ "-sort", Arg.Unit (fun () -> Odoc_global.sort_modules := true), M.sort_modules ;
+ "-no-stop", Arg.Set Odoc_global.no_stop, M.no_stop ;
+ "-no-custom-tags", Arg.Set Odoc_global.no_custom_tags, M.no_custom_tags ;
+ "-stars", Arg.Set Odoc_global.remove_stars, M.remove_stars ;
+ "-inv-merge-ml-mli", Arg.Set Odoc_global.inverse_merge_ml_mli, M.inverse_merge_ml_mli ;
+ "-no-module-constraint-filter", Arg.Clear Odoc_global.filter_with_module_constraints,
M.no_filter_with_module_constraints ;
- "-keep-code", Arg.Set keep_code, M.keep_code^"\n" ;
+ "-keep-code", Arg.Set Odoc_global.keep_code, M.keep_code^"\n" ;
- "-dump", Arg.String (fun s -> dump := Some s), M.dump ;
- "-load", Arg.String (fun s -> load := !load @ [s]), M.load^"\n" ;
+ "-dump", Arg.String (fun s -> Odoc_global.dump := Some s), M.dump ;
+ "-load", Arg.String (fun s -> Odoc_global.load := !Odoc_global.load @ [s]), M.load^"\n" ;
- "-t", Arg.String (fun s -> title := Some s), M.option_title ;
- "-intro", Arg.String (fun s -> intro_file := Some s), M.option_intro ;
+ "-t", Arg.String (fun s -> Odoc_global.title := Some s), M.option_title ;
+ "-intro", Arg.String (fun s -> Odoc_global.intro_file := Some s), M.option_intro ;
"-hide", Arg.String add_hidden_modules, M.hide_modules ;
- "-m", Arg.String (fun s -> merge_options := !merge_options @ (analyse_merge_options s)),
+ "-m", Arg.String (fun s -> Odoc_global.merge_options := !Odoc_global.merge_options @ (analyse_merge_options s)),
M.merge_options ^
"\n\n *** choosing a generator ***\n";
(* generators *)
- "-html", Arg.Unit (fun () -> set_doc_generator !default_html_generator), M.generate_html ;
- "-latex", Arg.Unit (fun () -> set_doc_generator !default_latex_generator), M.generate_latex ;
- "-texi", Arg.Unit (fun () -> set_doc_generator !default_texi_generator), M.generate_texinfo ;
- "-man", Arg.Unit (fun () -> set_doc_generator !default_man_generator), M.generate_man ;
- "-dot", Arg.Unit (fun () -> set_doc_generator !default_dot_generator), M.generate_dot ;
+ "-html", Arg.Unit (fun () -> set_generator
+ (Odoc_gen.Html (module Odoc_html.Generator : Odoc_html.Html_generator))),
+ M.generate_html ;
+ "-latex", Arg.Unit (fun () -> set_generator
+ (Odoc_gen.Latex (module Odoc_latex.Generator : Odoc_latex.Latex_generator))),
+ M.generate_latex ;
+ "-texi", Arg.Unit (fun () -> set_generator
+ (Odoc_gen.Texi (module Odoc_texi.Generator : Odoc_texi.Texi_generator))),
+ M.generate_texinfo ;
+ "-man", Arg.Unit (fun () -> set_generator
+ (Odoc_gen.Man (module Odoc_man.Generator : Odoc_man.Man_generator))),
+ M.generate_man ;
+ "-dot", Arg.Unit (fun () -> set_generator
+ (Odoc_gen.Dot (module Odoc_dot.Generator : Odoc_dot.Dot_generator))),
+ M.generate_dot ;
"-customdir", Arg.Unit (fun () -> Printf.printf "%s\n" Odoc_config.custom_generators_path; exit 0),
M.display_custom_generators_dir ;
"-i", Arg.String (fun s -> ()), M.add_load_dir ;
@@ -259,50 +151,58 @@ let options = ref [
"\n\n *** HTML options ***\n";
(* html only options *)
- "-all-params", Arg.Set with_parameter_list, M.with_parameter_list ;
- "-css-style", Arg.String (fun s -> css_style := Some s), M.css_style ;
- "-index-only", Arg.Set index_only, M.index_only ;
- "-colorize-code", Arg.Set colorize_code, M.colorize_code ;
- "-short-functors", Arg.Set html_short_functors, M.html_short_functors ^
+ "-all-params", Arg.Set Odoc_html.with_parameter_list, M.with_parameter_list ;
+ "-css-style", Arg.String (fun s -> Odoc_html.css_style := Some s), M.css_style ;
+ "-index-only", Arg.Set Odoc_html.index_only, M.index_only ;
+ "-colorize-code", Arg.Set Odoc_html.colorize_code, M.colorize_code ;
+ "-short-functors", Arg.Set Odoc_html.html_short_functors, M.html_short_functors ^
"\n\n *** LaTeX options ***\n";
(* latex only options *)
- "-noheader", Arg.Unit (fun () -> with_header := false), M.no_header ;
- "-notrailer", Arg.Unit (fun () -> with_trailer := false), M.no_trailer ;
- "-sepfiles", Arg.Set separate_files, M.separate_files ;
- "-latextitle", Arg.String f_latex_title, M.latex_title latex_titles ;
- "-latex-value-prefix", Arg.String (fun s -> latex_value_prefix := s), M.latex_value_prefix ;
- "-latex-type-prefix", Arg.String (fun s -> latex_type_prefix := s), M.latex_type_prefix ;
- "-latex-exception-prefix", Arg.String (fun s -> latex_exception_prefix := s), M.latex_exception_prefix ;
- "-latex-attribute-prefix", Arg.String (fun s -> latex_attribute_prefix := s), M.latex_attribute_prefix ;
- "-latex-method-prefix", Arg.String (fun s -> latex_method_prefix := s), M.latex_method_prefix ;
- "-latex-module-prefix", Arg.String (fun s -> latex_module_prefix := s), M.latex_module_prefix ;
- "-latex-module-type-prefix", Arg.String (fun s -> latex_module_type_prefix := s), M.latex_module_type_prefix ;
- "-latex-class-prefix", Arg.String (fun s -> latex_class_prefix := s), M.latex_class_prefix ;
- "-latex-class-type-prefix", Arg.String (fun s -> latex_class_type_prefix := s), M.latex_class_type_prefix ;
- "-notoc", Arg.Unit (fun () -> with_toc := false),
- M.no_toc ^
+ "-noheader", Arg.Unit (fun () -> Odoc_global.with_header := false), M.no_header ;
+ "-notrailer", Arg.Unit (fun () -> Odoc_global.with_trailer := false), M.no_trailer ;
+ "-sepfiles", Arg.Set Odoc_latex.separate_files, M.separate_files ;
+ "-latextitle", Arg.String f_latex_title, M.latex_title Odoc_latex.latex_titles ;
+ "-latex-value-prefix",
+ Arg.String (fun s -> Odoc_latex.latex_value_prefix := s), M.latex_value_prefix ;
+ "-latex-type-prefix",
+ Arg.String (fun s -> Odoc_latex.latex_type_prefix := s), M.latex_type_prefix ;
+ "-latex-exception-prefix",
+ Arg.String (fun s -> Odoc_latex.latex_exception_prefix := s), M.latex_exception_prefix ;
+ "-latex-attribute-prefix",
+ Arg.String (fun s -> Odoc_latex.latex_attribute_prefix := s), M.latex_attribute_prefix ;
+ "-latex-method-prefix",
+ Arg.String (fun s -> Odoc_latex.latex_method_prefix := s), M.latex_method_prefix ;
+ "-latex-module-prefix",
+ Arg.String (fun s -> Odoc_latex.latex_module_prefix := s), M.latex_module_prefix ;
+ "-latex-module-type-prefix",
+ Arg.String (fun s -> Odoc_latex.latex_module_type_prefix := s), M.latex_module_type_prefix ;
+ "-latex-class-prefix",
+ Arg.String (fun s -> Odoc_latex.latex_class_prefix := s), M.latex_class_prefix ;
+ "-latex-class-type-prefix",
+ Arg.String (fun s -> Odoc_latex.latex_class_type_prefix := s), M.latex_class_type_prefix ;
+ "-notoc", Arg.Unit (fun () -> Odoc_global.with_toc := false), M.no_toc ^
"\n\n *** texinfo options ***\n";
-(* tex only options *)
- "-noindex", Arg.Clear with_index, M.no_index ;
- "-esc8", Arg.Set esc_8bits, M.esc_8bits ;
- "-info-section", Arg.String ((:=) info_section), M.info_section ;
- "-info-entry", Arg.String (fun s -> info_entry := !info_entry @ [ s ]),
+(* texi only options *)
+ "-noindex", Arg.Clear Odoc_global.with_index, M.no_index ;
+ "-esc8", Arg.Set Odoc_texi.esc_8bits, M.esc_8bits ;
+ "-info-section", Arg.String ((:=) Odoc_texi.info_section), M.info_section ;
+ "-info-entry", Arg.String (fun s -> Odoc_texi.info_entry := !Odoc_texi.info_entry @ [ s ]),
M.info_entry ^
"\n\n *** dot options ***\n";
(* dot only options *)
- "-dot-colors", Arg.String (fun s -> dot_colors := Str.split (Str.regexp_string ",") s), M.dot_colors ;
- "-dot-include-all", Arg.Set dot_include_all, M.dot_include_all ;
- "-dot-types", Arg.Set dot_types, M.dot_types ;
- "-dot-reduce", Arg.Set dot_reduce, M.dot_reduce^
+ "-dot-colors", Arg.String (fun s -> Odoc_dot.dot_colors := Str.split (Str.regexp_string ",") s), M.dot_colors ;
+ "-dot-include-all", Arg.Set Odoc_dot.dot_include_all, M.dot_include_all ;
+ "-dot-types", Arg.Set Odoc_dot.dot_types, M.dot_types ;
+ "-dot-reduce", Arg.Set Odoc_dot.dot_reduce, M.dot_reduce^
"\n\n *** man pages options ***\n";
(* man only options *)
- "-man-mini", Arg.Set man_mini, M.man_mini ;
- "-man-suffix", Arg.String (fun s -> man_suffix := s), M.man_suffix ;
- "-man-section", Arg.String (fun s -> man_section := s), M.man_section ;
+ "-man-mini", Arg.Set Odoc_man.man_mini, M.man_mini ;
+ "-man-suffix", Arg.String (fun s -> Odoc_man.man_suffix := s), M.man_suffix ;
+ "-man-section", Arg.String (fun s -> Odoc_man.man_section := s), M.man_section ;
]
@@ -318,27 +218,22 @@ let add_option o =
in
options := iter !options
-let parse ~html_generator ~latex_generator ~texi_generator ~man_generator ~dot_generator =
+let parse () =
let anonymous f =
let sf =
if Filename.check_suffix f "ml" then
- Impl_file f
+ Odoc_global.Impl_file f
else
if Filename.check_suffix f "mli" then
- Intf_file f
+ Odoc_global.Intf_file f
else
if Filename.check_suffix f "txt" then
- Text_file f
+ Odoc_global.Text_file f
else
failwith (Odoc_messages.unknown_extension f)
in
- files := !files @ [sf]
+ Odoc_global.files := !Odoc_global.files @ [sf]
in
- default_html_generator := Some html_generator ;
- default_latex_generator := Some latex_generator ;
- default_texi_generator := Some texi_generator ;
- default_man_generator := Some man_generator ;
- default_dot_generator := Some dot_generator ;
let _ = Arg.parse !options
anonymous
(M.usage^M.options_are)
@@ -346,4 +241,5 @@ let parse ~html_generator ~latex_generator ~texi_generator ~man_generator ~dot_g
(* we sort the hidden modules by name, to be sure that for example,
A.B is before A, so we will match against A.B before A in
Odoc_name.hide_modules.*)
- hidden_modules := List.sort (fun a -> fun b -> - (compare a b)) !hidden_modules
+ Odoc_global.hidden_modules :=
+ List.sort (fun a -> fun b -> - (compare a b)) !Odoc_global.hidden_modules
diff --git a/ocamldoc/odoc_args.mli b/ocamldoc/odoc_args.mli
index 2e096ac367..2f190ef756 100644
--- a/ocamldoc/odoc_args.mli
+++ b/ocamldoc/odoc_args.mli
@@ -13,180 +13,15 @@
(** Analysis of the command line arguments. *)
-(** The kind of source file in arguments. *)
-type source_file =
- Impl_file of string
- | Intf_file of string
- | Text_file of string
-
-(** The include_dirs in the OCaml compiler. *)
-val include_dirs : string list ref
-
-(** The class type of documentation generators. *)
-class type doc_generator =
- object method generate : Odoc_module.t_module list -> unit end
-
-(** The function to be used to create a generator. *)
-val doc_generator : doc_generator option ref
-
-(** The merge options to be used. *)
-val merge_options : Odoc_types.merge_option list ref
-
-(** Classic mode or not. *)
-val classic : bool ref
-
-(** The file used by the generators outputting only one file. *)
-val out_file : string ref
-
-(** The optional file name to dump the collected information into.*)
-val dump : string option ref
-
-(** The list of information files to load. *)
-val load : string list ref
-
-(** Verbose mode or not. *)
-val verbose : bool ref
-
-(** We must sort the list of top modules or not.*)
-val sort_modules : bool ref
-
-(** We must not stop at the stop special comments. Default is false (we stop).*)
-val no_stop : bool ref
-
-(** We must raise an exception when we find an unknown @-tag. *)
-val no_custom_tags : bool ref
-
-(** We must remove the the first characters of each comment line, until the first asterisk '*'. *)
-val remove_stars : bool ref
-
-(** To keep the code while merging, when we have both .ml and .mli files for a module. *)
-val keep_code : bool ref
-
-(** To inverse implementation and interface files when merging. *)
-val inverse_merge_ml_mli : bool ref
-
-(** To filter module elements according to module type constraints. *)
-val filter_with_module_constraints : bool ref
-
-(** The optional title to use in the generated documentation. *)
-val title : string option ref
-
-(** The optional file whose content can be used as intro text. *)
-val intro_file : string option ref
-
-(** Flag to indicate whether we must display the complete list of parameters
- for functions and methods. *)
-val with_parameter_list : bool ref
-
-(** The list of module names to hide. *)
-val hidden_modules : string list ref
-
-(** The directory where files have to be generated. *)
-val target_dir : string ref
-
-(** An optional file to use where a CSS style is defined (for HTML). *)
-val css_style : string option ref
-
-(** Generate only index files. (for HTML). *)
-val index_only : bool ref
-
-(** To colorize code in HTML generated documentation pages, not code pages. *)
-val colorize_code : bool ref
-
-(** To display functors in short form rather than with "functor ... -> ",
- in HTML generated documentation. *)
-val html_short_functors : bool ref
-
-(** The flag which indicates if we must generate a header (for LaTeX). *)
-val with_header : bool ref
-
-(** The flag which indicates if we must generate a trailer (for LaTeX). *)
-val with_trailer : bool ref
-
-(** The flag to indicate if we must generate one file per module (for LaTeX). *)
-val separate_files : bool ref
-
-(** The list of pairs (title level, sectionning style). *)
-val latex_titles : (int * string) list ref
-
-(** The prefix to use for value labels in LaTeX. *)
-val latex_value_prefix : string ref
-
-(** The prefix to use for type labels in LaTeX. *)
-val latex_type_prefix : string ref
-
-(** The prefix to use for exception labels in LaTeX. *)
-val latex_exception_prefix : string ref
-
-(** The prefix to use for module labels in LaTeX. *)
-val latex_module_prefix : string ref
-
-(** The prefix to use for module type labels in LaTeX. *)
-val latex_module_type_prefix : string ref
-
-(** The prefix to use for class labels in LaTeX. *)
-val latex_class_prefix : string ref
-
-(** The prefix to use for class type labels in LaTeX. *)
-val latex_class_type_prefix : string ref
-
-(** The prefix to use for attribute labels in LaTeX. *)
-val latex_attribute_prefix : string ref
-
-(** The prefix to use for method labels in LaTeX. *)
-val latex_method_prefix : string ref
-
-(** The flag which indicates if we must generate a table of contents (for LaTeX). *)
-val with_toc : bool ref
-
-(** The flag which indicates if we must generate an index (for TeXinfo). *)
-val with_index : bool ref
-
-(** The flag which indicates if we must escape accentuated characters (for TeXinfo).*)
-val esc_8bits : bool ref
-
-(** The Info directory section *)
-val info_section : string ref
-
-(** The Info directory entries to insert *)
-val info_entry : string list ref
-
-(** Include all modules or only the ones on the command line, for the dot ouput. *)
-val dot_include_all : bool ref
-
-(** Generate dependency graph for types. *)
-val dot_types : bool ref
-
-(** Perform transitive reduction before dot output. *)
-val dot_reduce : bool ref
-
-(** The colors used in the dot output. *)
-val dot_colors : string list ref
-
-(** The suffix for man pages. *)
-val man_suffix : string ref
-
-(** The section for man pages. *)
-val man_section : string ref
-
-(** The flag to generate all man pages or only for modules and classes.*)
-val man_mini : bool ref
-
-(** The files to be analysed. *)
-val files : source_file list ref
+(** The current module defining the generator to use. *)
+val current_generator : Odoc_gen.generator option ref
(** To set the documentation generator. *)
-val set_doc_generator : doc_generator option -> unit
+val set_generator : Odoc_gen.generator -> unit
(** Add an option specification. *)
val add_option : string * Arg.spec * string -> unit
(** Parse the args.
[byte] indicate if we are in bytecode mode (default is [true]).*)
-val parse :
- html_generator:doc_generator ->
- latex_generator:doc_generator ->
- texi_generator:doc_generator ->
- man_generator:doc_generator ->
- dot_generator:doc_generator ->
- unit
+val parse : unit -> unit
diff --git a/ocamldoc/odoc_ast.ml b/ocamldoc/odoc_ast.ml
index 3456e14dea..bbeba47a84 100644
--- a/ocamldoc/odoc_ast.ml
+++ b/ocamldoc/odoc_ast.ml
@@ -1174,7 +1174,7 @@ module Analyser =
ty_loc = { loc_impl = Some (!file_name, loc_start) ; loc_inter = None } ;
ty_code =
(
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
Some (get_string_of_file loc_start new_end)
else
None
@@ -1214,7 +1214,7 @@ module Analyser =
ex_loc = { loc_impl = Some (!file_name, loc.Location.loc_start.Lexing.pos_cnum) ; loc_inter = None } ;
ex_code =
(
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
Some (get_string_of_file loc_start loc_end)
else
None
@@ -1260,7 +1260,7 @@ module Analyser =
tt_module_expr
in
let code =
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
let loc = module_expr.Parsetree.pmod_loc in
let st = loc.Location.loc_start.Lexing.pos_cnum in
let en = loc.Location.loc_end.Lexing.pos_cnum in
@@ -1622,7 +1622,7 @@ module Analyser =
p_modtype tt_modtype
in
let tt_modtype = Odoc_env.subst_module_type env tt_modtype in
- if !Odoc_args.filter_with_module_constraints then
+ if !Odoc_global.filter_with_module_constraints then
filter_module_with_module_type_constraint m_base2 tt_modtype;
{
m_base with
@@ -1725,7 +1725,7 @@ module Analyser =
m_kind = kind ;
m_loc = { loc_impl = Some (!file_name, 0) ; loc_inter = None } ;
m_top_deps = [] ;
- m_code = (if !Odoc_args.keep_code then Some !file else None) ;
+ m_code = (if !Odoc_global.keep_code then Some !file else None) ;
m_code_intf = None ;
m_text_only = false ;
}
diff --git a/ocamldoc/odoc_cross.ml b/ocamldoc/odoc_cross.ml
index 962da359eb..39965f83b2 100644
--- a/ocamldoc/odoc_cross.ml
+++ b/ocamldoc/odoc_cross.ml
@@ -684,7 +684,7 @@ let rec assoc_comments_text_elements parent_name module_list t_ele =
| (_, None) ->
match parent_name with
None ->
- Odoc_messages.pwarning (Odoc_messages.cross_element_not_found initial_name);
+ Odoc_global.pwarning (Odoc_messages.cross_element_not_found initial_name);
Ref (initial_name, None, text_option)
| Some p ->
let parent_name =
@@ -745,7 +745,7 @@ let rec assoc_comments_text_elements parent_name module_list t_ele =
| (_, None) ->
match parent_name with
None ->
- Odoc_messages.pwarning (not_found_of_kind kind initial_name);
+ Odoc_global.pwarning (not_found_of_kind kind initial_name);
Ref (initial_name, None, text_option)
| Some p ->
let parent_name =
@@ -987,7 +987,7 @@ let associate module_list =
| l ->
List.iter
(fun nf ->
- Odoc_messages.pwarning
+ Odoc_global.pwarning
(
match nf with
NF_m n -> Odoc_messages.cross_module_not_found n
diff --git a/ocamldoc/odoc_dot.ml b/ocamldoc/odoc_dot.ml
index 452bf2bfa7..8d4fa2f3c9 100644
--- a/ocamldoc/odoc_dot.ml
+++ b/ocamldoc/odoc_dot.ml
@@ -18,6 +18,17 @@ open Odoc_info
module F = Format
+let dot_include_all = ref false
+
+let dot_types = ref false
+
+let dot_reduce = ref false
+
+let dot_colors = ref (List.flatten Odoc_messages.default_dot_colors)
+
+module Generator =
+struct
+
(** This class generates a dot file showing the top modules dependencies. *)
class dot =
object (self)
@@ -29,7 +40,7 @@ class dot =
val mutable modules = []
(** Colors to use when finding new locations of modules. *)
- val mutable colors = !Args.dot_colors
+ val mutable colors = !dot_colors
(** Graph header. *)
method header =
@@ -73,7 +84,7 @@ class dot =
method generate_for_module fmt m =
let l = List.filter
(fun n ->
- !Args.dot_include_all or
+ !dot_include_all or
(List.exists (fun m -> m.Module.m_name = n) modules))
m.Module.m_top_deps
in
@@ -88,11 +99,11 @@ class dot =
method generate_types types =
try
- let oc = open_out !Args.out_file in
+ let oc = open_out !Global.out_file in
let fmt = F.formatter_of_out_channel oc in
F.fprintf fmt "%s" self#header;
let graph = Odoc_info.Dep.deps_of_types
- ~kernel: !Args.dot_reduce
+ ~kernel: !dot_reduce
types
in
List.iter (self#generate_for_type fmt) graph;
@@ -106,11 +117,11 @@ class dot =
method generate_modules modules_list =
try
modules <- modules_list ;
- let oc = open_out !Args.out_file in
+ let oc = open_out !Global.out_file in
let fmt = F.formatter_of_out_channel oc in
F.fprintf fmt "%s" self#header;
- if !Args.dot_reduce then
+ if !dot_reduce then
Odoc_info.Dep.kernel_deps_of_modules modules_list;
List.iter (self#generate_for_module fmt) modules_list;
@@ -123,9 +134,13 @@ class dot =
(** Generate the dot code in the file {!Odoc_info.Args.out_file}. *)
method generate (modules_list : Odoc_info.Module.t_module list) =
- colors <- !Args.dot_colors;
- if !Args.dot_types then
+ colors <- !dot_colors;
+ if !dot_types then
self#generate_types (Odoc_info.Search.types modules_list)
else
self#generate_modules modules_list
end
+end
+
+module type Dot_generator = module type of Generator
+
diff --git a/ocamldoc/odoc_gen.ml b/ocamldoc/odoc_gen.ml
new file mode 100644
index 0000000000..260aed4df4
--- /dev/null
+++ b/ocamldoc/odoc_gen.ml
@@ -0,0 +1,38 @@
+(** *)
+
+class type doc_generator =
+ object method generate : Odoc_module.t_module list -> unit end;;
+
+module type Base = sig
+ class generator : doc_generator
+ end;;
+
+type generator =
+ | Html of (module Odoc_html.Html_generator)
+ | Latex of (module Odoc_latex.Latex_generator)
+ | Texi of (module Odoc_texi.Texi_generator)
+ | Man of (module Odoc_man.Man_generator)
+ | Dot of (module Odoc_dot.Dot_generator)
+ | Other of (module Base)
+;;
+
+let get_minimal_generator = function
+ Html m ->
+ let module M = (val m : Odoc_html.Html_generator) in
+ (new M.html :> doc_generator)
+| Latex m ->
+ let module M = (val m : Odoc_latex.Latex_generator) in
+ (new M.latex :> doc_generator)
+| Man m ->
+ let module M = (val m : Odoc_man.Man_generator) in
+ (new M.man :> doc_generator)
+| Texi m ->
+ let module M = (val m : Odoc_texi.Texi_generator) in
+ (new M.texi :> doc_generator)
+| Dot m ->
+ let module M = (val m : Odoc_dot.Dot_generator) in
+ (new M.dot :> doc_generator)
+| Other m ->
+ let module M = (val m : Base) in
+ new M.generator
+ ;; \ No newline at end of file
diff --git a/ocamldoc/odoc_gen.mli b/ocamldoc/odoc_gen.mli
new file mode 100644
index 0000000000..1200a7c420
--- /dev/null
+++ b/ocamldoc/odoc_gen.mli
@@ -0,0 +1,22 @@
+(** The types of generators. *)
+
+(** The minimal class type of documentation generators. *)
+class type doc_generator =
+ object method generate : Odoc_module.t_module list -> unit end;;
+
+(** The module type of minimal generators. *)
+module type Base = sig
+ class generator : doc_generator
+ end;;
+
+(** Various ways to create a generator. *)
+type generator =
+ | Html of (module Odoc_html.Html_generator)
+ | Latex of (module Odoc_latex.Latex_generator)
+ | Texi of (module Odoc_texi.Texi_generator)
+ | Man of (module Odoc_man.Man_generator)
+ | Dot of (module Odoc_dot.Dot_generator)
+ | Other of (module Base)
+;;
+
+val get_minimal_generator : generator -> doc_generator \ No newline at end of file
diff --git a/ocamldoc/odoc_global.ml b/ocamldoc/odoc_global.ml
index 4e08456617..0b2ab6a2bb 100644
--- a/ocamldoc/odoc_global.ml
+++ b/ocamldoc/odoc_global.ml
@@ -13,10 +13,77 @@
(** Global variables. *)
+(* Tell ocaml compiler not to generate files. *)
+let _ = Clflags.dont_write_files := true
+
+open Clflags
+
+type source_file =
+ Impl_file of string
+ | Intf_file of string
+ | Text_file of string
+
+let include_dirs = Clflags.include_dirs
+
let errors = ref 0
let warn_error = ref false
+let pwarning s =
+ if !Odoc_config.print_warnings then prerr_endline (Odoc_messages.warning^": "^s);
+ if !warn_error then incr errors
+
+let merge_options = ref ([] : Odoc_types.merge_option list)
+
+let classic = Clflags.classic
+
+let dump = ref (None : string option)
+
+let load = ref ([] : string list)
+
+(** Allow arbitrary recursive types. *)
+let recursive_types = Clflags.recursive_types
+
+(** Optional preprocessor command. *)
+let preprocessor = Clflags.preprocessor
+
+let sort_modules = ref false
+
+let no_custom_tags = ref false
+
+let no_stop = ref false
+
+let remove_stars = ref false
+
+let keep_code = ref false
+
+let inverse_merge_ml_mli = ref false
+
+let filter_with_module_constraints = ref true
+
+let hidden_modules = ref ([] : string list)
+
+let files = ref []
+
+
+
+let out_file = ref Odoc_messages.default_out_file
+
+let verbose = ref false
+
+let target_dir = ref Filename.current_dir_name
+
+let title = ref (None : string option)
+
+let intro_file = ref (None : string option)
+
+let with_header = ref true
+
+let with_trailer = ref true
+
+let with_toc = ref true
+
+let with_index = ref true
+
+
-(* Tell ocaml compiler not to generate files. *)
-let _ = Clflags.dont_write_files := true
diff --git a/ocamldoc/odoc_global.mli b/ocamldoc/odoc_global.mli
index 3a9eab6514..454bb8535b 100644
--- a/ocamldoc/odoc_global.mli
+++ b/ocamldoc/odoc_global.mli
@@ -13,8 +13,92 @@
(** Global variables. *)
+(** The kind of source file in arguments. *)
+type source_file =
+ Impl_file of string
+ | Intf_file of string
+ | Text_file of string
+
+(** The include_dirs in the OCaml compiler. *)
+val include_dirs : string list ref
+
+(** Optional preprocessor command to pass to ocaml compiler. *)
+val preprocessor : string option ref
+
+(** Recursive types flag to passe to ocaml compiler. *)
+val recursive_types : bool ref
+
+(** The merge options to be used. *)
+val merge_options : Odoc_types.merge_option list ref
+
+(** Classic mode or not. *)
+val classic : bool ref
+
+(** The optional file name to dump the collected information into.*)
+val dump : string option ref
+
+(** The list of information files to load. *)
+val load : string list ref
+
+(** We must sort the list of top modules or not.*)
+val sort_modules : bool ref
+
+(** We must not stop at the stop special comments. Default is false (we stop).*)
+val no_stop : bool ref
+
+(** We must raise an exception when we find an unknown @-tag. *)
+val no_custom_tags : bool ref
+
+(** We must remove the the first characters of each comment line, until the first asterisk '*'. *)
+val remove_stars : bool ref
+
+(** To keep the code while merging, when we have both .ml and .mli files for a module. *)
+val keep_code : bool ref
+
+(** To inverse implementation and interface files when merging. *)
+val inverse_merge_ml_mli : bool ref
+
+(** To filter module elements according to module type constraints. *)
+val filter_with_module_constraints : bool ref
+
+(** The list of module names to hide. *)
+val hidden_modules : string list ref
+
+(** The files to be analysed. *)
+val files : source_file list ref
(** A counter for errors. *)
val errors : int ref
(** Indicate if a warning is an error. *)
val warn_error : bool ref
+
+(** Print the given warning, adding it to the list of {!errors}
+if {!warn_error} is [true]. *)
+val pwarning : string -> unit
+
+(** The file used by the generators outputting only one file. *)
+val out_file : string ref
+
+(** Verbose mode or not. *)
+val verbose : bool ref
+
+(** The optional file whose content can be used as intro text. *)
+val intro_file : string option ref
+
+(** The optional title to use in the generated documentation. *)
+val title : string option ref
+
+(** The directory where files have to be generated. *)
+val target_dir : string ref
+
+(** The flag which indicates if we must generate a table of contents. *)
+val with_toc : bool ref
+
+(** The flag which indicates if we must generate an index. *)
+val with_index : bool ref
+
+(** The flag which indicates if we must generate a header.*)
+val with_header : bool ref
+
+(** The flag which indicates if we must generate a trailer.*)
+val with_trailer : bool ref
diff --git a/ocamldoc/odoc_html.ml b/ocamldoc/odoc_html.ml
index 7b9050fb0f..fecef08502 100644
--- a/ocamldoc/odoc_html.ml
+++ b/ocamldoc/odoc_html.ml
@@ -23,6 +23,12 @@ open Exception
open Class
open Module
+let with_parameter_list = ref false
+let css_style = ref None
+let index_only = ref false
+let colorize_code = ref false
+let html_short_functors = ref false
+
(** The functions used for naming files and html marks.*)
module Naming =
@@ -270,7 +276,7 @@ class virtual text =
method html_of_Raw b s = bs b (self#escape s)
method html_of_Code b s =
- if !Args.colorize_code then
+ if !colorize_code then
self#html_of_code b ~with_pre: false s
else
(
@@ -308,7 +314,7 @@ class virtual text =
| Some last -> String.sub s first ((last-first)+1)
in
fun b s ->
- if !Args.colorize_code then
+ if !colorize_code then
(
bs b "<pre></pre>";
self#html_of_code b (remove_useless_newlines s);
@@ -471,7 +477,7 @@ class virtual text =
self#html_of_info_first_sentence b m.m_info;
with
Not_found ->
- Odoc_messages.pwarning (Odoc_messages.cross_module_not_found name);
+ Odoc_global.pwarning (Odoc_messages.cross_module_not_found name);
bp b "%s</td><td>" name
);
bs b "</td></tr>\n"
@@ -718,6 +724,8 @@ let newline_to_indented_br s =
done;
Buffer.contents b
+module Generator =
+ struct
(** This class is used to create objects which can generate a simple html documentation. *)
class html =
object (self)
@@ -824,10 +832,10 @@ class html =
val mutable known_modules_names = StringSet.empty
method index_prefix =
- if !Odoc_args.out_file = Odoc_messages.default_out_file then
+ if !Odoc_global.out_file = Odoc_messages.default_out_file then
"index"
else
- Filename.basename !Odoc_args.out_file
+ Filename.basename !Odoc_global.out_file
(** The main file. *)
method index =
@@ -887,12 +895,12 @@ class html =
(** Init the style. *)
method init_style =
- (match !Args.css_style with
+ (match !css_style with
None ->
let default_style = String.concat "\n" default_style_options in
(
try
- let file = Filename.concat !Args.target_dir style_file in
+ let file = Filename.concat !Global.target_dir style_file in
if Sys.file_exists file then
Odoc_info.verbose (Odoc_messages.file_exists_dont_generate file)
else
@@ -914,7 +922,7 @@ class html =
style <- "<link rel=\"stylesheet\" href=\""^style_file^"\" type=\"text/css\">\n"
(** Get the title given by the user *)
- method title = match !Args.title with None -> "" | Some t -> self#escape t
+ method title = match !Global.title with None -> "" | Some t -> self#escape t
(** Get the title given by the user completed with the given subtitle. *)
method inner_title s =
@@ -1204,7 +1212,7 @@ class html =
bs b (self#create_fully_qualified_module_idents_links father a.ma_name);
bs b "</code>"
| Module_functor (p, k) ->
- if !Odoc_info.Args.html_short_functors then
+ if !html_short_functors then
bs b " "
else
bs b "<div class=\"sig_block\">";
@@ -1212,12 +1220,12 @@ class html =
(
match k with
Module_functor _ -> ()
- | _ when !Odoc_info.Args.html_short_functors ->
+ | _ when !html_short_functors ->
bs b ": "
| _ -> ()
);
self#html_of_module_kind b father ?modu k;
- if not !Odoc_info.Args.html_short_functors then
+ if not !html_short_functors then
bs b "</div>"
| Module_apply (k1, k2) ->
(* TODO: l'application n'est pas correcte dans un .mli.
@@ -1254,7 +1262,7 @@ class html =
method html_of_module_parameter b father p =
let (s_functor,s_arrow) =
- if !Odoc_info.Args.html_short_functors then
+ if !html_short_functors then
"", ""
else
"functor ", "-> "
@@ -1355,7 +1363,7 @@ class html =
None -> bs b (self#escape (Name.simple v.val_name))
| Some c ->
let file = Naming.file_code_value_complete_target v in
- self#output_code v.val_name (Filename.concat !Args.target_dir file) c;
+ self#output_code v.val_name (Filename.concat !Global.target_dir file) c;
bp b "<a href=\"%s\">%s</a>" file (self#escape (Name.simple v.val_name))
);
bs b "</span>";
@@ -1364,7 +1372,7 @@ class html =
bs b "</pre>";
self#html_of_info b v.val_info;
(
- if !Args.with_parameter_list then
+ if !with_parameter_list then
self#html_of_parameter_list b (Name.father v.val_name) v.val_parameters
else
self#html_of_described_parameter_list b (Name.father v.val_name) v.val_parameters
@@ -1544,7 +1552,7 @@ class html =
None -> bs b (Name.simple a.att_value.val_name)
| Some c ->
let file = Naming.file_code_attribute_complete_target a in
- self#output_code a.att_value.val_name (Filename.concat !Args.target_dir file) c;
+ self#output_code a.att_value.val_name (Filename.concat !Global.target_dir file) c;
bp b "<a href=\"%s\">%s</a>" file (Name.simple a.att_value.val_name);
);
bs b "</span>";
@@ -1567,7 +1575,7 @@ class html =
None -> bs b (Name.simple m.met_value.val_name)
| Some c ->
let file = Naming.file_code_method_complete_target m in
- self#output_code m.met_value.val_name (Filename.concat !Args.target_dir file) c;
+ self#output_code m.met_value.val_name (Filename.concat !Global.target_dir file) c;
bp b "<a href=\"%s\">%s</a>" file (Name.simple m.met_value.val_name);
);
bs b "</span>";
@@ -1576,7 +1584,7 @@ class html =
bs b "</pre>";
self#html_of_info b m.met_value.val_info;
(
- if !Args.with_parameter_list then
+ if !with_parameter_list then
self#html_of_parameter_list b
module_name m.met_value.val_parameters
else
@@ -1710,7 +1718,7 @@ class html =
);
(
match m.m_kind with
- Module_functor _ when !Odoc_info.Args.html_short_functors ->
+ Module_functor _ when !html_short_functors ->
()
| _ -> bs b ": "
);
@@ -2056,7 +2064,7 @@ class html =
('a -> string) -> string -> string -> unit =
fun elements name info target title simple_file ->
try
- let chanout = open_out (Filename.concat !Args.target_dir simple_file) in
+ let chanout = open_out (Filename.concat !Global.target_dir simple_file) in
let b = new_buf () in
bs b "<html>\n";
self#print_header b (self#inner_title title);
@@ -2122,7 +2130,7 @@ class html =
let (html_file, _) = Naming.html_files cl.cl_name in
let type_file = Naming.file_type_class_complete_target cl.cl_name in
try
- let chanout = open_out (Filename.concat !Args.target_dir html_file) in
+ let chanout = open_out (Filename.concat !Global.target_dir html_file) in
let b = new_buf () in
let pre_name = opt (fun c -> c.cl_name) pre in
let post_name = opt (fun c -> c.cl_name) post in
@@ -2157,7 +2165,7 @@ class html =
(* generate the file with the complete class type *)
self#output_class_type
cl.cl_name
- (Filename.concat !Args.target_dir type_file)
+ (Filename.concat !Global.target_dir type_file)
cl.cl_type
with
Sys_error s ->
@@ -2169,7 +2177,7 @@ class html =
let (html_file, _) = Naming.html_files clt.clt_name in
let type_file = Naming.file_type_class_complete_target clt.clt_name in
try
- let chanout = open_out (Filename.concat !Args.target_dir html_file) in
+ let chanout = open_out (Filename.concat !Global.target_dir html_file) in
let b = new_buf () in
let pre_name = opt (fun ct -> ct.clt_name) pre in
let post_name = opt (fun ct -> ct.clt_name) post in
@@ -2203,7 +2211,7 @@ class html =
(* generate the file with the complete class type *)
self#output_class_type
clt.clt_name
- (Filename.concat !Args.target_dir type_file)
+ (Filename.concat !Global.target_dir type_file)
clt.clt_type
with
Sys_error s ->
@@ -2215,7 +2223,7 @@ class html =
try
let (html_file, _) = Naming.html_files mt.mt_name in
let type_file = Naming.file_type_module_complete_target mt.mt_name in
- let chanout = open_out (Filename.concat !Args.target_dir html_file) in
+ let chanout = open_out (Filename.concat !Global.target_dir html_file) in
let b = new_buf () in
let pre_name = opt (fun mt -> mt.mt_name) pre in
let post_name = opt (fun mt -> mt.mt_name) post in
@@ -2268,7 +2276,7 @@ class html =
| Some mty ->
self#output_module_type
mt.mt_name
- (Filename.concat !Args.target_dir type_file)
+ (Filename.concat !Global.target_dir type_file)
mty
)
with
@@ -2283,7 +2291,7 @@ class html =
let (html_file, _) = Naming.html_files modu.m_name in
let type_file = Naming.file_type_module_complete_target modu.m_name in
let code_file = Naming.file_code_module_complete_target modu.m_name in
- let chanout = open_out (Filename.concat !Args.target_dir html_file) in
+ let chanout = open_out (Filename.concat !Global.target_dir html_file) in
let b = new_buf () in
let pre_name = opt (fun m -> m.m_name) pre in
let post_name = opt (fun m -> m.m_name) post in
@@ -2347,7 +2355,7 @@ class html =
(* generate the file with the complete module type *)
self#output_module_type
modu.m_name
- (Filename.concat !Args.target_dir type_file)
+ (Filename.concat !Global.target_dir type_file)
modu.m_type;
match modu.m_code with
@@ -2355,7 +2363,7 @@ class html =
| Some code ->
self#output_code
modu.m_name
- (Filename.concat !Args.target_dir code_file)
+ (Filename.concat !Global.target_dir code_file)
code
with
Sys_error s ->
@@ -2365,9 +2373,9 @@ class html =
@raise Failure if an error occurs.*)
method generate_index module_list =
try
- let chanout = open_out (Filename.concat !Args.target_dir self#index) in
+ let chanout = open_out (Filename.concat !Global.target_dir self#index) in
let b = new_buf () in
- let title = match !Args.title with None -> "" | Some t -> self#escape t in
+ let title = match !Global.title with None -> "" | Some t -> self#escape t in
bs b doctype ;
bs b "<html>\n";
self#print_header b self#title;
@@ -2377,7 +2385,7 @@ class html =
bs b "</h1></center>\n" ;
let info = Odoc_info.apply_opt
(Odoc_info.info_of_comment_file module_list)
- !Odoc_info.Args.intro_file
+ !Odoc_info.Global.intro_file
in
(
match info with
@@ -2537,7 +2545,7 @@ class html =
known_modules_names
module_types ;
(* generate html for each module *)
- if not !Args.index_only then
+ if not !index_only then
self#generate_elements self#generate_for_module module_list ;
try
@@ -2564,3 +2572,6 @@ class html =
Buffer.contents b
)
end
+end
+
+module type Html_generator = module type of Generator
diff --git a/ocamldoc/odoc_info.ml b/ocamldoc/odoc_info.ml
index fa3c585ed6..061d091f53 100644
--- a/ocamldoc/odoc_info.ml
+++ b/ocamldoc/odoc_info.ml
@@ -104,11 +104,11 @@ let analyse_files
?(no_stop=false)
?(init=[])
files =
- Odoc_args.merge_options := merge_options;
- Odoc_args.include_dirs := include_dirs;
- Odoc_args.classic := not labels;
- Odoc_args.sort_modules := sort_modules;
- Odoc_args.no_stop := no_stop;
+ Odoc_global.merge_options := merge_options;
+ Odoc_global.include_dirs := include_dirs;
+ Odoc_global.classic := not labels;
+ Odoc_global.sort_modules := sort_modules;
+ Odoc_global.no_stop := no_stop;
Odoc_analyse.analyse_files ~init: init files
let dump_modules = Odoc_analyse.dump_modules
@@ -168,15 +168,15 @@ let is_optional = Odoc_misc.is_optional
let label_name = Odoc_misc.label_name
let use_hidden_modules n =
- Odoc_name.hide_given_modules !Odoc_args.hidden_modules n
+ Odoc_name.hide_given_modules !Odoc_global.hidden_modules n
let verbose s =
- if !Odoc_args.verbose then
+ if !Odoc_global.verbose then
(print_string s ; print_newline ())
else
()
-let warning s = Odoc_messages.pwarning s
+let warning s = Odoc_global.pwarning s
let print_warnings = Odoc_config.print_warnings
let errors = Odoc_global.errors
@@ -320,4 +320,4 @@ module Dep =
let deps_of_types = Odoc_dep.deps_of_types
end
-module Args = Odoc_args
+module Global = Odoc_global
diff --git a/ocamldoc/odoc_info.mli b/ocamldoc/odoc_info.mli
index 7c6dc49120..c106b040b7 100644
--- a/ocamldoc/odoc_info.mli
+++ b/ocamldoc/odoc_info.mli
@@ -931,149 +931,40 @@ module Dep :
val deps_of_types : ?kernel: bool -> Type.t_type list -> (Type.t_type * (Name.t list)) list
end
-(** {2 Command line arguments} *)
+(** {2 Some global variables} *)
-(** You can use this module to create custom generators.*)
-module Args :
- sig
- (** The kind of source file in arguments. *)
- type source_file =
- Impl_file of string
- | Intf_file of string
- | Text_file of string
-
- (** The class type of documentation generators. *)
- class type doc_generator =
- object method generate : Module.t_module list -> unit end
-
- (** The file used by the generators outputting only one file. *)
- val out_file : string ref
-
- (** Verbose mode or not. *)
- val verbose : bool ref
-
- (** The optional title to use in the generated documentation. *)
- val title : string option ref
-
- (** To inverse [.ml] and [.mli] files while merging comments. *)
- val inverse_merge_ml_mli : bool ref
-
- (** To filter module elements according to module type constraints. *)
- val filter_with_module_constraints : bool ref
-
- (** To keep the code while merging, when we have both .ml and .mli files for a module. *)
- val keep_code : bool ref
-
- (** The optional file whose content can be used as intro text. *)
- val intro_file : string option ref
-
- (** Flag to indicate whether we must display the complete list of parameters
- for functions and methods. *)
- val with_parameter_list : bool ref
-
- (** The list of module names to hide. *)
- val hidden_modules : string list ref
-
- (** The directory where files have to be generated. *)
- val target_dir : string ref
-
- (** An optional file to use where a CSS style is defined (for HTML). *)
- val css_style : string option ref
-
- (** Generate only index files. (for HTML). *)
- val index_only : bool ref
-
- (** To colorize code in HTML generated documentation pages, not code pages. *)
- val colorize_code : bool ref
-
- (** To display functors in short form rather than with "functor ... -> ",
- in HTML generated documentation. *)
- val html_short_functors : bool ref
-
- (** The flag which indicates if we must generate a header (for LaTeX). *)
- val with_header : bool ref
-
- (** The flag which indicates if we must generate a trailer (for LaTeX). *)
- val with_trailer : bool ref
-
- (** The flag to indicate if we must generate one file per module (for LaTeX). *)
- val separate_files : bool ref
-
- (** The list of pairs (title level, sectionning style). *)
- val latex_titles : (int * string) list ref
-
- (** The prefix to use for value labels in LaTeX. *)
- val latex_value_prefix : string ref
-
- (** The prefix to use for type labels in LaTeX. *)
- val latex_type_prefix : string ref
-
- (** The prefix to use for exception labels in LaTeX. *)
- val latex_exception_prefix : string ref
-
- (** The prefix to use for module labels in LaTeX. *)
- val latex_module_prefix : string ref
-
- (** The prefix to use for module type labels in LaTeX. *)
- val latex_module_type_prefix : string ref
-
- (** The prefix to use for class labels in LaTeX. *)
- val latex_class_prefix : string ref
-
- (** The prefix to use for class type labels in LaTeX. *)
- val latex_class_type_prefix : string ref
-
- (** The prefix to use for attribute labels in LaTeX. *)
- val latex_attribute_prefix : string ref
-
- (** The prefix to use for method labels in LaTeX. *)
- val latex_method_prefix : string ref
-
- (** The flag which indicates if we must generate a table of contents (for LaTeX). *)
- val with_toc : bool ref
-
- (** The flag which indicates if we must generate an index (for TeXinfo). *)
- val with_index : bool ref
-
- (** The flag which indicates if we must escape accentuated characters (for TeXinfo).*)
- val esc_8bits : bool ref
-
- (** The Info directory section *)
- val info_section : string ref
-
- (** The Info directory entries to insert *)
- val info_entry : string list ref
-
- (** Include all modules or only the ones on the command line, for the dot ouput. *)
- val dot_include_all : bool ref
+module Global :
+ sig
+ val errors : int ref
+ val warn_error : bool ref
- (** Generate dependency graph for types. *)
- val dot_types : bool ref
+ (** The file used by the generators outputting only one file. *)
+ val out_file : string ref
- (** Perform transitive reduction before dot output. *)
- val dot_reduce : bool ref
+ (** Verbose mode or not. *)
+ val verbose : bool ref
- (** The colors used in the dot output. *)
- val dot_colors : string list ref
+ (** The directory where files have to be generated. *)
+ val target_dir : string ref
- (** The suffix for man pages. *)
- val man_suffix : string ref
+ (** The optional title to use in the generated documentation. *)
+ val title : string option ref
- (** The section for man pages. *)
- val man_section : string ref
+ (** The optional file whose content can be used as intro text. *)
+ val intro_file : string option ref
- (** The flag to generate all man pages or only for modules and classes.*)
- val man_mini : bool ref
+ (** The flag which indicates if we must generate a table of contents. *)
+ val with_toc : bool ref
- (** The files to be analysed. *)
- val files : source_file list ref
+ (** The flag which indicates if we must generate an index. *)
+ val with_index : bool ref
- (** To set the documentation generator. *)
- val set_doc_generator : doc_generator option -> unit
+ (** The flag which indicates if we must generate a header.*)
+ val with_header : bool ref
- (** Add an option specification. *)
- val add_option : string * Arg.spec * string -> unit
- end
+ (** The flag which indicates if we must generate a trailer.*)
+ val with_trailer : bool ref
+end
(** Analysis of the given source files.
@param init is the list of modules already known from a previous analysis.
@@ -1085,7 +976,7 @@ val analyse_files :
?sort_modules:bool ->
?no_stop:bool ->
?init: Odoc_module.t_module list ->
- Args.source_file list ->
+ Odoc_global.source_file list ->
Module.t_module list
(** Dump of a list of modules into a file.
diff --git a/ocamldoc/odoc_latex.ml b/ocamldoc/odoc_latex.ml
index 3750996a45..c20c344b51 100644
--- a/ocamldoc/odoc_latex.ml
+++ b/ocamldoc/odoc_latex.ml
@@ -23,6 +23,28 @@ open Exception
open Class
open Module
+
+
+let separate_files = ref false
+
+let latex_titles = ref [
+ 1, "section" ;
+ 2, "subsection" ;
+ 3, "subsubsection" ;
+ 4, "paragraph" ;
+ 5, "subparagraph" ;
+]
+
+let latex_value_prefix = ref Odoc_messages.default_latex_value_prefix
+let latex_type_prefix = ref Odoc_messages.default_latex_type_prefix
+let latex_exception_prefix = ref Odoc_messages.default_latex_exception_prefix
+let latex_module_prefix = ref Odoc_messages.default_latex_module_prefix
+let latex_module_type_prefix = ref Odoc_messages.default_latex_module_type_prefix
+let latex_class_prefix = ref Odoc_messages.default_latex_class_prefix
+let latex_class_type_prefix = ref Odoc_messages.default_latex_class_type_prefix
+let latex_attribute_prefix = ref Odoc_messages.default_latex_attribute_prefix
+let latex_method_prefix = ref Odoc_messages.default_latex_method_prefix
+
let new_buf () = Buffer.create 1024
let new_fmt () =
let b = new_buf () in
@@ -60,7 +82,7 @@ class text =
and with the given latex code. *)
method section_style level s =
try
- let sec = List.assoc level !Args.latex_titles in
+ let sec = List.assoc level !latex_titles in
"\\"^sec^"{"^s^"}\n"
with Not_found -> s
@@ -182,31 +204,31 @@ class text =
Buffer.contents buf
(** Make a correct label from a value name. *)
- method value_label ?no_ name = !Args.latex_value_prefix^(self#label ?no_ name)
+ method value_label ?no_ name = !latex_value_prefix^(self#label ?no_ name)
(** Make a correct label from an attribute name. *)
- method attribute_label ?no_ name = !Args.latex_attribute_prefix^(self#label ?no_ name)
+ method attribute_label ?no_ name = !latex_attribute_prefix^(self#label ?no_ name)
(** Make a correct label from a method name. *)
- method method_label ?no_ name = !Args.latex_method_prefix^(self#label ?no_ name)
+ method method_label ?no_ name = !latex_method_prefix^(self#label ?no_ name)
(** Make a correct label from a class name. *)
- method class_label ?no_ name = !Args.latex_class_prefix^(self#label ?no_ name)
+ method class_label ?no_ name = !latex_class_prefix^(self#label ?no_ name)
(** Make a correct label from a class type name. *)
- method class_type_label ?no_ name = !Args.latex_class_type_prefix^(self#label ?no_ name)
+ method class_type_label ?no_ name = !latex_class_type_prefix^(self#label ?no_ name)
(** Make a correct label from a module name. *)
- method module_label ?no_ name = !Args.latex_module_prefix^(self#label ?no_ name)
+ method module_label ?no_ name = !latex_module_prefix^(self#label ?no_ name)
(** Make a correct label from a module type name. *)
- method module_type_label ?no_ name = !Args.latex_module_type_prefix^(self#label ?no_ name)
+ method module_type_label ?no_ name = !latex_module_type_prefix^(self#label ?no_ name)
(** Make a correct label from an exception name. *)
- method exception_label ?no_ name = !Args.latex_exception_prefix^(self#label ?no_ name)
+ method exception_label ?no_ name = !latex_exception_prefix^(self#label ?no_ name)
(** Make a correct label from a type name. *)
- method type_label ?no_ name = !Args.latex_type_prefix^(self#label ?no_ name)
+ method type_label ?no_ name = !latex_type_prefix^(self#label ?no_ name)
(** Return latex code for the label of a given label. *)
method make_label label = "\\label{"^label^"}"
@@ -413,6 +435,8 @@ class virtual info =
(self#text_of_info ~block info_opt)
end
+module Generator =
+struct
(** This class is used to create objects which can generate a simple LaTeX documentation. *)
class latex =
object (self)
@@ -1082,7 +1106,7 @@ class latex =
ps fmt "\\usepackage{url} \n";
ps fmt "\\usepackage{ocamldoc}\n";
(
- match !Args.title with
+ match !Global.title with
None -> ()
| Some s ->
ps fmt "\\title{";
@@ -1090,15 +1114,15 @@ class latex =
ps fmt "}\n"
);
ps fmt "\\begin{document}\n";
- (match !Args.title with
+ (match !Global.title with
None -> () |
Some _ -> ps fmt "\\maketitle\n"
);
- if !Args.with_toc then ps fmt "\\tableofcontents\n";
+ if !Global.with_toc then ps fmt "\\tableofcontents\n";
(
let info = Odoc_info.apply_opt
(Odoc_info.info_of_comment_file module_list)
- !Odoc_info.Args.intro_file
+ !Odoc_info.Global.intro_file
in
(match info with None -> () | Some _ -> ps fmt "\\vspace{0.2cm}");
self#latex_of_info fmt info;
@@ -1109,7 +1133,7 @@ class latex =
(** Generate the LaTeX style file, if it does not exists. *)
method generate_style_file =
try
- let dir = Filename.dirname !Args.out_file in
+ let dir = Filename.dirname !Global.out_file in
let file = Filename.concat dir "ocamldoc.sty" in
if Sys.file_exists file then
Odoc_info.verbose (Odoc_messages.file_exists_dont_generate file)
@@ -1126,12 +1150,12 @@ class latex =
prerr_endline s ;
incr Odoc_info.errors ;
- (** Generate the LaTeX file from a module list, in the {!Odoc_info.Args.out_file} file. *)
+ (** Generate the LaTeX file from a module list, in the {!Odoc_info.Global.out_file} file. *)
method generate module_list =
self#generate_style_file ;
- let main_file = !Args.out_file in
+ let main_file = !Global.out_file in
let dir = Filename.dirname main_file in
- if !Args.separate_files then
+ if !separate_files then
(
let f m =
try
@@ -1154,16 +1178,16 @@ class latex =
try
let chanout = open_out main_file in
let fmt = Format.formatter_of_out_channel chanout in
- if !Args.with_header then self#latex_header fmt module_list;
+ if !Global.with_header then self#latex_header fmt module_list;
List.iter
(fun m ->
- if !Args.separate_files then
+ if !separate_files then
ps fmt ("\\input{"^((Name.simple m.m_name))^".tex}\n")
else
self#generate_for_top_module fmt m
)
module_list ;
- if !Args.with_trailer then ps fmt "\\end{document}";
+ if !Global.with_trailer then ps fmt "\\end{document}";
Format.pp_print_flush fmt ();
close_out chanout
with
@@ -1172,3 +1196,6 @@ class latex =
prerr_endline s ;
incr Odoc_info.errors
end
+end
+
+module type Latex_generator = module type of Generator
diff --git a/ocamldoc/odoc_lexer.mll b/ocamldoc/odoc_lexer.mll
index 7b34b36424..318a839fff 100644
--- a/ocamldoc/odoc_lexer.mll
+++ b/ocamldoc/odoc_lexer.mll
@@ -178,7 +178,7 @@ and special_comment = parse
let s2 = lecture_string () in
let s3 = remove_blanks s2 in
let s4 =
- if !Odoc_args.remove_stars then
+ if !Odoc_global.remove_stars then
remove_stars s3
else
s3
@@ -244,14 +244,14 @@ and special_comment_part2 = parse
if !comments_level = 1 then
(* finally we return the description we kept *)
let desc =
- if !Odoc_args.remove_stars then
+ if !Odoc_global.remove_stars then
remove_stars !description
else
!description
in
let remain = lecture_string () in
let remain2 =
- if !Odoc_args.remove_stars then
+ if !Odoc_global.remove_stars then
remove_stars remain
else
remain
@@ -322,7 +322,7 @@ and elements = parse
| "return" ->
T_RETURN
| s ->
- if !Odoc_args.no_custom_tags then
+ if !Odoc_global.no_custom_tags then
raise (Failure (Odoc_messages.not_a_valid_tag s))
else
T_CUSTOM s
diff --git a/ocamldoc/odoc_man.ml b/ocamldoc/odoc_man.ml
index eb6ec4d7d0..612bc11a02 100644
--- a/ocamldoc/odoc_man.ml
+++ b/ocamldoc/odoc_man.ml
@@ -21,6 +21,11 @@ open Class
open Module
open Search
+let man_suffix = ref Odoc_messages.default_man_suffix
+let man_section = ref Odoc_messages.default_man_section
+
+let man_mini = ref false
+
let new_buf () = Buffer.create 1024
let bp = Printf.bprintf
let bs = Buffer.add_string
@@ -202,6 +207,9 @@ class virtual info =
self#man_of_custom b info.M.i_custom
end
+module Generator =
+struct
+
(** This class is used to create objects which can generate a simple html documentation. *)
class man =
let re_slash = Str.regexp_string "/" in
@@ -210,7 +218,7 @@ class man =
(** Get a file name from a complete name. *)
method file_name name =
- let s = Printf.sprintf "%s.%s" name !Args.man_suffix in
+ let s = Printf.sprintf "%s.%s" name !man_suffix in
Str.global_replace re_slash "slash" s
(** Escape special sequences of characters in a string. *)
@@ -229,7 +237,7 @@ class man =
(** Open a file for output. Add the target directory.*)
method open_out file =
- let f = Filename.concat !Args.target_dir file in
+ let f = Filename.concat !Global.target_dir file in
open_out f
(** Print groff string for a text, without correction of blanks. *)
@@ -693,10 +701,10 @@ class man =
let chanout = self#open_out file in
let b = new_buf () in
bs b (".TH \""^cl.cl_name^"\" ");
- bs b !Odoc_args.man_section ;
+ bs b !man_section ;
bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
bs b "OCamldoc ";
- bs b ("\""^(match !Args.title with Some t -> t | None -> "")^"\"\n");
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
let abstract =
match cl.cl_info with
@@ -752,10 +760,10 @@ class man =
let chanout = self#open_out file in
let b = new_buf () in
bs b (".TH \""^ct.clt_name^"\" ");
- bs b !Odoc_args.man_section ;
+ bs b !man_section ;
bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
bs b "OCamldoc ";
- bs b ("\""^(match !Args.title with Some t -> t | None -> "")^"\"\n");
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
let abstract =
match ct.clt_info with
@@ -809,10 +817,10 @@ class man =
let chanout = self#open_out file in
let b = new_buf () in
bs b (".TH \""^mt.mt_name^"\" ");
- bs b !Odoc_args.man_section ;
+ bs b !man_section ;
bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
bs b "OCamldoc ";
- bs b ("\""^(match !Args.title with Some t -> t | None -> "")^"\"\n");
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
let abstract =
match mt.mt_info with
@@ -887,10 +895,10 @@ class man =
let chanout = self#open_out file in
let b = new_buf () in
bs b (".TH \""^m.m_name^"\" ");
- bs b !Odoc_args.man_section ;
+ bs b !man_section ;
bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
bs b "OCamldoc ";
- bs b ("\""^(match !Args.title with Some t -> t | None -> "")^"\"\n");
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
let abstract =
match m.m_info with
@@ -1014,10 +1022,10 @@ class man =
let chanout = self#open_out file in
let b = new_buf () in
bs b (".TH \""^name^"\" ");
- bs b !Odoc_args.man_section ;
+ bs b !man_section ;
bs b (" "^(Odoc_misc.string_of_date ~hour: false date)^" ");
bs b "OCamldoc ";
- bs b ("\""^(match !Args.title with Some t -> t | None -> "")^"\"\n");
+ bs b ("\""^(match !Global.title with Some t -> t | None -> "")^"\"\n");
bs b ".SH NAME\n";
bs b (name^" \\- all "^name^" elements\n\n");
@@ -1069,10 +1077,13 @@ class man =
| [Res_class cl] -> self#generate_for_class cl
| [Res_class_type ct] -> self#generate_for_class_type ct
| l ->
- if !Args.man_mini then
+ if !man_mini then
()
else
self#generate_for_group l
in
List.iter f groups
end
+end
+
+module type Man_generator = module type of Generator
diff --git a/ocamldoc/odoc_merge.ml b/ocamldoc/odoc_merge.ml
index 44804ba0b7..8d062f9e02 100644
--- a/ocamldoc/odoc_merge.ml
+++ b/ocamldoc/odoc_merge.ml
@@ -239,7 +239,7 @@ let merge_types merge_options mli ml =
cons.vc_text <- new_desc
with
Not_found ->
- if !Odoc_args.inverse_merge_ml_mli then
+ if !Odoc_global.inverse_merge_ml_mli then
()
else
raise (Failure (Odoc_messages.different_types mli.ty_name))
@@ -267,7 +267,7 @@ let merge_types merge_options mli ml =
record.rf_text <- new_desc
with
Not_found ->
- if !Odoc_args.inverse_merge_ml_mli then
+ if !Odoc_global.inverse_merge_ml_mli then
()
else
raise (Failure (Odoc_messages.different_types mli.ty_name))
@@ -275,7 +275,7 @@ let merge_types merge_options mli ml =
List.iter f l1
| _ ->
- if !Odoc_args.inverse_merge_ml_mli then
+ if !Odoc_global.inverse_merge_ml_mli then
()
else
raise (Failure (Odoc_messages.different_types mli.ty_name))
@@ -343,7 +343,7 @@ let merge_classes merge_options mli ml =
a.att_value.val_info <- merge_info_opt merge_options
a.att_value.val_info a2.att_value.val_info;
a.att_value.val_loc <- { a.att_value.val_loc with loc_impl = a2.att_value.val_loc.loc_impl } ;
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
a.att_value.val_code <- a2.att_value.val_code;
true
)
@@ -382,7 +382,7 @@ let merge_classes merge_options mli ml =
parameters because the associated comment of a parameter may have been changed by the merge.*)
Odoc_value.update_value_parameters_text m.met_value;
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
m.met_value.val_code <- m2.met_value.val_code;
true
@@ -420,7 +420,7 @@ let merge_class_types merge_options mli ml =
a.att_value.val_info <- merge_info_opt merge_options
a.att_value.val_info a2.att_value.val_info;
a.att_value.val_loc <- { a.att_value.val_loc with loc_impl = a2.att_value.val_loc.loc_impl } ;
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
a.att_value.val_code <- a2.att_value.val_code;
true
@@ -459,7 +459,7 @@ let merge_class_types merge_options mli ml =
parameters because the associated comment of a parameter may have been changed y the merge.*)
Odoc_value.update_value_parameters_text m.met_value;
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
m.met_value.val_code <- m2.met_value.val_code;
true
@@ -623,7 +623,7 @@ let rec merge_module_types merge_options mli ml =
parameters because the associated comment of a parameter may have been changed y the merge.*)
Odoc_value.update_value_parameters_text v;
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
v.val_code <- v2.val_code;
true
@@ -713,7 +713,7 @@ and merge_modules merge_options mli ml =
mli.m_top_deps <- remove_doubles mli.m_top_deps ml.m_top_deps ;
let code =
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
match mli.m_code, ml.m_code with
Some s, _ -> Some s
| _, Some s -> Some s
@@ -722,7 +722,7 @@ and merge_modules merge_options mli ml =
None
in
let code_intf =
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
match mli.m_code_intf, ml.m_code_intf with
Some s, _ -> Some s
| _, Some s -> Some s
@@ -869,7 +869,7 @@ and merge_modules merge_options mli ml =
parameters because the associated comment of a parameter may have been changed y the merge.*)
Odoc_value.update_value_parameters_text v;
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
v.val_code <- v2.val_code;
true
)
@@ -961,19 +961,19 @@ let merge merge_options modules_list =
(
(* we can merge m with m2 if there is an implementation
and an interface.*)
- let f b = if !Odoc_args.inverse_merge_ml_mli then not b else b in
+ let f b = if !Odoc_global.inverse_merge_ml_mli then not b else b in
match f m.m_is_interface, f m2.m_is_interface with
true, false -> (merge_modules merge_options m m2) :: (iter l_others)
| false, true -> (merge_modules merge_options m2 m) :: (iter l_others)
| false, false ->
- if !Odoc_args.inverse_merge_ml_mli then
+ if !Odoc_global.inverse_merge_ml_mli then
(* two Module.ts for the .mli ! *)
raise (Failure (Odoc_messages.two_interfaces m.m_name))
else
(* two Module.t for the .ml ! *)
raise (Failure (Odoc_messages.two_implementations m.m_name))
| true, true ->
- if !Odoc_args.inverse_merge_ml_mli then
+ if !Odoc_global.inverse_merge_ml_mli then
(* two Module.t for the .ml ! *)
raise (Failure (Odoc_messages.two_implementations m.m_name))
else
diff --git a/ocamldoc/odoc_messages.ml b/ocamldoc/odoc_messages.ml
index a55d022f4e..4d92c5d24f 100644
--- a/ocamldoc/odoc_messages.ml
+++ b/ocamldoc/odoc_messages.ml
@@ -211,9 +211,6 @@ let merge_options =
(** Error and warning messages *)
let warning = "Warning"
-let pwarning s =
- if !Odoc_config.print_warnings then prerr_endline (warning^": "^s);
- if !Odoc_global.warn_error then incr Odoc_global.errors
let bad_magic_number =
"Bad magic number for this ocamldoc dump!\n"^
diff --git a/ocamldoc/odoc_sig.ml b/ocamldoc/odoc_sig.ml
index 34a71e84e9..f8308d6c67 100644
--- a/ocamldoc/odoc_sig.ml
+++ b/ocamldoc/odoc_sig.ml
@@ -529,7 +529,7 @@ module Analyser =
ex_loc = { loc_impl = None ; loc_inter = Some (!file_name, pos_start_ele) } ;
ex_code =
(
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
Some (get_string_of_file pos_start_ele pos_end_ele)
else
None
@@ -617,7 +617,7 @@ module Analyser =
};
ty_code =
(
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
Some (get_string_of_file loc_start new_end)
else
None
@@ -660,7 +660,7 @@ module Analyser =
in
let module_kind = analyse_module_kind env complete_name module_type sig_module_type in
let code_intf =
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
let loc = module_type.Parsetree.pmty_loc in
let st = loc.Location.loc_start.Lexing.pos_cnum in
let en = loc.Location.loc_end.Lexing.pos_cnum in
@@ -751,7 +751,7 @@ module Analyser =
(* associate the comments to each constructor and build the [Type.t_type] *)
let module_kind = analyse_module_kind new_env complete_name modtype sig_module_type in
let code_intf =
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
let loc = modtype.Parsetree.pmty_loc in
let st = loc.Location.loc_start.Lexing.pos_cnum in
let en = loc.Location.loc_end.Lexing.pos_cnum in
@@ -1283,7 +1283,7 @@ module Analyser =
analyse_parsetree Odoc_env.empty signat mod_name len (String.length !file) ast
in
let code_intf =
- if !Odoc_args.keep_code then
+ if !Odoc_global.keep_code then
Some !file
else
None
diff --git a/ocamldoc/odoc_test.ml b/ocamldoc/odoc_test.ml
index a9868f6ef1..7b455f45bf 100644
--- a/ocamldoc/odoc_test.ml
+++ b/ocamldoc/odoc_test.ml
@@ -22,6 +22,8 @@ type test_kind =
let p = Format.fprintf
+module Generator =
+struct
class string_gen =
object(self)
inherit Odoc_info.Scan.scanner
@@ -88,7 +90,7 @@ class string_gen =
true
method generate (module_list: Odoc_info.Module.t_module list) =
- let oc = open_out !Odoc_info.Args.out_file in
+ let oc = open_out !Odoc_info.Global.out_file in
fmt <- Format.formatter_of_out_channel oc;
(
try
@@ -106,7 +108,11 @@ class string_gen =
close_out oc
end
+ class generator =
+ let g = new string_gen in
+ object
+ method generate = g#generate
+ end
+end;;
-let my_generator = new string_gen
-let _ = Odoc_info.Args.set_doc_generator
- (Some (my_generator :> Odoc_info.Args.doc_generator))
+let _ = Odoc_args.set_generator (Odoc_gen.Other (module Generator : Odoc_gen.Base))
diff --git a/ocamldoc/odoc_texi.ml b/ocamldoc/odoc_texi.ml
index a853c4f7a4..30ac53ce77 100644
--- a/ocamldoc/odoc_texi.ml
+++ b/ocamldoc/odoc_texi.ml
@@ -20,6 +20,12 @@ open Exception
open Class
open Module
+let esc_8bits = ref false
+
+let info_section = ref "Objective Caml"
+
+let info_entry = ref []
+
(** {2 Some small helper functions} *)
let puts_nl chan s =
@@ -140,7 +146,7 @@ struct
(Str.regexp "}", "@}") ;
(Str.regexp "\\.\\.\\.", "@dots{}") ;
] @
- (if !Args.esc_8bits
+ (if !esc_8bits
then [
(Str.regexp "à", "@`a") ;
(Str.regexp "â", "@^a") ;
@@ -381,6 +387,9 @@ class text =
exception Aliased_node
+module Generator =
+struct
+
(** This class is used to create objects which can generate a simple
Texinfo documentation. *)
class texi =
@@ -413,7 +422,7 @@ class texi =
method index (ind : indices) ent =
Verbatim
- (if !Args.with_index
+ (if !Global.with_index
then (assert(List.mem ind indices_to_build) ;
String.concat ""
[ "@" ; indices ind ; "index " ;
@@ -1055,7 +1064,7 @@ class texi =
(** Writes the header of the TeXinfo document. *)
method generate_texi_header chan texi_filename m_list =
- let title = match !Args.title with
+ let title = match !Global.title with
| None -> ""
| Some s -> self#escape s in
let filename =
@@ -1080,18 +1089,18 @@ class texi =
"@settitle " ^ title ;
"@c %**end of header" ; ] ;
- (if !Args.with_index then
+ (if !Global.with_index then
List.map
(fun ind ->
"@defcodeindex " ^ (indices ind))
indices_to_build
else []) ;
- [ Texi.dirsection !Args.info_section ] ;
+ [ Texi.dirsection !info_section ] ;
Texi.direntry
- (if !Args.info_entry <> []
- then !Args.info_entry
+ (if !info_entry <> []
+ then !info_entry
else [ Printf.sprintf "* %s: (%s)."
title
(Filename.chop_suffix filename ".info") ]) ;
@@ -1108,7 +1117,7 @@ class texi =
(* insert the intro file *)
begin
- match !Odoc_info.Args.intro_file with
+ match !Odoc_info.Global.intro_file with
| None when title <> "" ->
puts_nl chan "@ifinfo" ;
puts_nl chan ("Documentation for " ^ title) ;
@@ -1125,7 +1134,7 @@ class texi =
(* write a top menu *)
Texi.generate_menu chan
((List.map (fun m -> `Module m) m_list) @
- (if !Args.with_index then
+ (if !Global.with_index then
let indices_names_to_build = List.map indices indices_to_build in
List.rev
(List.fold_left
@@ -1142,7 +1151,7 @@ class texi =
(** Writes the trailer of the TeXinfo document. *)
method generate_texi_trailer chan =
nl chan ;
- if !Args.with_index
+ if !Global.with_index
then
let indices_names_to_build = List.map indices indices_to_build in
List.iter (puts_nl chan)
@@ -1155,7 +1164,7 @@ class texi =
"@printindex " ^ shortname ; ]
else [])
indices_names )) ;
- if !Args.with_toc
+ if !Global.with_toc
then puts_nl chan "@contents" ;
puts_nl chan "@bye"
@@ -1203,25 +1212,25 @@ class texi =
(** Generate the Texinfo file from a module list,
- in the {!Odoc_info.Args.out_file} file. *)
+ in the {!Odoc_info.Global.out_file} file. *)
method generate module_list =
Hashtbl.clear node_tbl ;
let filename =
- if !Args.out_file = Odoc_messages.default_out_file
+ if !Global.out_file = Odoc_messages.default_out_file
then "ocamldoc.texi"
- else !Args.out_file in
- if !Args.with_index
+ else !Global.out_file in
+ if !Global.with_index
then List.iter self#scan_for_index
(List.map (fun m -> `Module m) module_list) ;
try
let chanout = open_out
- (Filename.concat !Args.target_dir filename) in
- if !Args.with_header
+ (Filename.concat !Global.target_dir filename) in
+ if !Global.with_header
then self#generate_texi_header chanout filename module_list ;
List.iter
(self#generate_for_module chanout)
module_list ;
- if !Args.with_trailer
+ if !Global.with_trailer
then self#generate_texi_trailer chanout ;
close_out chanout
with
@@ -1230,3 +1239,6 @@ class texi =
prerr_endline s ;
incr Odoc_info.errors
end
+end
+
+module type Texi_generator = module type of Generator