From 98f930742ca58742a9bc0a575e2d362ee2fa061e Mon Sep 17 00:00:00 2001 From: notin Date: Tue, 8 Apr 2008 07:18:13 +0000 Subject: Ajout d'options a coqdoc pour l'entete html git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@10764 85f007b7-540e-0410-9357-904b9bb8a0f7 --- tools/coqdoc/cdglobals.ml | 4 +++ tools/coqdoc/main.ml | 72 +++++++++++++++++++++++++++-------------------- tools/coqdoc/output.ml | 50 ++++++++++++++++++++++---------- 3 files changed, 80 insertions(+), 46 deletions(-) diff --git a/tools/coqdoc/cdglobals.ml b/tools/coqdoc/cdglobals.ml index eef598fdd5..44b9bd3ce0 100644 --- a/tools/coqdoc/cdglobals.ml +++ b/tools/coqdoc/cdglobals.ml @@ -33,6 +33,10 @@ let close_out_file () = close_out !out_channel let header_trailer = ref true +let header_file = ref "" +let header_file_spec = ref false +let footer_file = ref "" +let footer_file_spec = ref false let quiet = ref true let light = ref false let gallina = ref false diff --git a/tools/coqdoc/main.ml b/tools/coqdoc/main.ml index b00bcfcf96..b2d1eb9196 100644 --- a/tools/coqdoc/main.ml +++ b/tools/coqdoc/main.ml @@ -26,37 +26,39 @@ open Printf let usage () = prerr_endline ""; prerr_endline "Usage: coqdoc "; - prerr_endline " --html produce a HTML document (default)"; - prerr_endline " --latex produce a LaTeX document"; - prerr_endline " --texmacs produce a TeXmacs document"; - prerr_endline " --dvi output the DVI"; - prerr_endline " --ps output the PostScript"; - prerr_endline " --stdout write output to stdout"; - prerr_endline " -o write output in file "; - prerr_endline " -d output files into directory "; - prerr_endline " -g (gallina) skip proofs"; - prerr_endline " -s (short) no titles for files"; - prerr_endline " -l light mode (only defs and statements)"; - prerr_endline " -t give a title to the document"; - prerr_endline " --body-only suppress LaTeX/HTML header and trailer"; - prerr_endline " --no-index do not output the index"; - prerr_endline " --multi-index index split in multiple files"; - prerr_endline " --toc output a table of contents"; - prerr_endline " --vernac consider as a .v file"; - prerr_endline " --tex consider as a .tex file"; - prerr_endline " -p insert in LaTeX preamble"; - prerr_endline " --files-from read file names to process in "; - prerr_endline " --quiet quiet mode (default)"; - prerr_endline " --verbose verbose mode"; - prerr_endline " --no-externals no links to Coq standard library"; - prerr_endline " --coqlib set URL for Coq standard library"; - prerr_endline " (default is http://coq.inria.fr/library/)"; - prerr_endline " --coqlib_path set the path where Coq files are installed"; - prerr_endline " -R map physical dir to Coq dir"; - prerr_endline " --latin1 set ISO-8859-1 input language"; - prerr_endline " --utf8 set UTF-8 input language"; - prerr_endline " --charset set HTML charset"; - prerr_endline " --inputenc set LaTeX input encoding"; + prerr_endline " --html produce a HTML document (default)"; + prerr_endline " --latex produce a LaTeX document"; + prerr_endline " --texmacs produce a TeXmacs document"; + prerr_endline " --dvi output the DVI"; + prerr_endline " --ps output the PostScript"; + prerr_endline " --stdout write output to stdout"; + prerr_endline " -o write output in file "; + prerr_endline " -d output files into directory "; + prerr_endline " -g (gallina) skip proofs"; + prerr_endline " -s (short) no titles for files"; + prerr_endline " -l light mode (only defs and statements)"; + prerr_endline " -t give a title to the document"; + prerr_endline " --body-only suppress LaTeX/HTML header and trailer"; + prerr_endline " --with-header prepend as html reader"; + prerr_endline " --with-footer append as html footer"; + prerr_endline " --no-index do not output the index"; + prerr_endline " --multi-index index split in multiple files"; + prerr_endline " --toc output a table of contents"; + prerr_endline " --vernac consider as a .v file"; + prerr_endline " --tex consider as a .tex file"; + prerr_endline " -p insert in LaTeX preamble"; + prerr_endline " --files-from read file names to process in "; + prerr_endline " --quiet quiet mode (default)"; + prerr_endline " --verbose verbose mode"; + prerr_endline " --no-externals no links to Coq standard library"; + prerr_endline " --coqlib set URL for Coq standard library"; + prerr_endline " (default is http://coq.inria.fr/library/)"; + prerr_endline " --coqlib_path set the path where Coq files are installed"; + prerr_endline " -R map physical dir to Coq dir"; + prerr_endline " --latin1 set ISO-8859-1 input language"; + prerr_endline " --utf8 set UTF-8 input language"; + prerr_endline " --charset set HTML charset"; + prerr_endline " --inputenc set LaTeX input encoding"; prerr_endline ""; exit 1 @@ -201,6 +203,14 @@ let parse () = | ("-nopreamble" | "--nopreamble" | "--no-preamble" | "-bodyonly" | "--bodyonly" | "--body-only") :: rem -> header_trailer := false; parse_rec rem + | ("-with-header" | "--with-header") :: f ::rem -> + header_trailer := true; header_file_spec := true; header_file := f; parse_rec rem + | ("-with-header" | "--with-header") :: [] -> + usage () + | ("-with-footer" | "--with-footer") :: f ::rem -> + header_trailer := true; footer_file_spec := true; footer_file := f; parse_rec rem + | ("-with-footer" | "--with-footer") :: [] -> + usage () | ("-p" | "--preamble") :: s :: rem -> Output.push_in_preamble s; parse_rec rem | ("-p" | "--preamble") :: [] -> diff --git a/tools/coqdoc/output.ml b/tools/coqdoc/output.ml index 5e37213867..fd8768fdf1 100644 --- a/tools/coqdoc/output.ml +++ b/tools/coqdoc/output.ml @@ -277,27 +277,47 @@ end module Html = struct let header () = - if !header_trailer then begin - printf "\n"; - printf "\n\n"; - printf "\n" !charset; - printf "\n"; - printf "%s\n\n\n" !page_title; - printf "\n\n
\n\n
\n
\n\n"; - printf "
\n\n" - end + if !header_trailer then + if !header_file_spec then + let cin = Pervasives.open_in !header_file in + try + while true do + let s = Pervasives.input_line cin in + printf "%s\n" s + done + with End_of_file -> Pervasives.close_in cin + else + begin + printf "\n"; + printf "\n\n"; + printf "\n" !charset; + printf "\n"; + printf "%s\n\n\n" !page_title; + printf "\n\n
\n\n
\n
\n\n"; + printf "
\n\n" + end let self = "http://coq.inria.fr" let trailer () = if !index && !current_module <> "Index" then printf "
\n\n
\n
Index"; - if !header_trailer then begin - printf "
This page has been generated by "; - printf "coqdoc\n" self; - printf "
\n\n
\n\n\n" - end + if !header_trailer then + if !footer_file_spec then + let cin = Pervasives.open_in !footer_file in + try + while true do + let s = Pervasives.input_line cin in + printf "%s\n" s + done + with End_of_file -> Pervasives.close_in cin + else + begin + printf "
This page has been generated by "; + printf "coqdoc\n" self; + printf "
\n\n
\n\n\n" + end let start_module () = if not !short then begin -- cgit v1.2.3