Debian Codegraph @

tools/coqdoc/common.ml

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 (* Misc types **********************************************************************)
12 type target_language = LaTeX | HTML | TeXmacs | Raw
13 type output_t = StdOut | MultFiles | File of string
14 type coq_module = string
15 type file_t = Vernac_file of string * coq_module | Latex_file of string
16 type glob_source_t = NoGlob | DotGlob | GlobFile of string
17 type encoding_t = {
18 charset : string;
19 inputenc : string;
20 latin1 : bool;
21 utf8 : bool;
22 }
23 type otype = Dvi | Ps | Pdf
24 (* End misc types ******************************************************************)
25
26 (** User-setable options from command line [coqdoc] arugments **********************)
27 type t = {
28 targetlang : target_language;
29 coqlib : string option;
30 compile_targets : otype list;
31 out_to : output_t;
32 output_dir: string;
33 gallina: bool;
34 short : bool;
35 light : bool;
36 title : string;
37 header_trailer : bool;
38 header_file : string option;
39 footer_file : string option;
40 index: bool;
41 binder_index : bool;
42 multi_index : bool;
43 index_name : string;
44 toc: bool;
45 files : file_t list;
46 glob_source : glob_source_t;
47 quiet : bool;
48 externals : bool;
49 coqlib_url: string;
50 paths : (string * string) list;
51 encoding : encoding_t;
52 interpolate : bool;
53 raw_comments : bool;
54 parse_comments : bool;
55 plain_comments : bool;
56 toc_depth : int option;
57 lib_name : string;
58 lib_subtitles : bool;
59 inline_notmono : bool;
60 }
61
62 let default : t = {
63 targetlang = HTML;
64 coqlib = None;
65 compile_targets = [];
66 out_to = MultFiles;
67 output_dir = "";
68 gallina = false;
69 short = false;
70 light = false;
71 title = "";
72 header_trailer = true;
73 header_file = None;
74 footer_file = None;
75 index = true;
76 multi_index = false;
77 index_name = "index";
78 binder_index = false;
79 toc = false;
80 files = [];
81 glob_source = DotGlob;
82 quiet = true;
83 externals = true;
84 coqlib_url = Coq_config.wwwstdlib;
85 paths = [];
86 encoding = {
87 charset = "iso-8859-1";
88 inputenc = "";
89 latin1 = false;
90 utf8 = false;
91 };
92 interpolate = false;
93 raw_comments = false;
94 parse_comments = false;
95 plain_comments = false;
96 toc_depth = None;
97 lib_name = "Library";
98 lib_subtitles = false;
99 inline_notmono = false;
100 }
101
102 let prefs = ref default
103
104 (* Globals *************************************************************************)
105 let page_title = ref ""
106 let out_channel = ref stdout
107 (* End globals *********************************************************************)
108
109 (* Little helpers ******************************************************************)
110 let (/) = Filename.concat
111
112 let coqdoc_out f =
113 if !prefs.output_dir <> "" && Filename.is_relative f then
114 if not (Sys.file_exists !prefs.output_dir) then
115 (Printf.eprintf "No such directory: %s\n" !prefs.output_dir; exit 1)
116 else
117 !prefs.output_dir / f
118 else
119 f
120
121 let open_out_file f =
122 out_channel :=
123 try open_out (coqdoc_out f)
124 with Sys_error s -> Printf.eprintf "%s\n" s; exit 1
125
126 let close_out_file () = close_out !out_channel
127 (* End little helpers **************************************************************)