summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Guesdon <maxence.guesdon@inria.fr>2003-07-04 10:02:13 +0000
committerMaxence Guesdon <maxence.guesdon@inria.fr>2003-07-04 10:02:13 +0000
commite64970f29dbbce99f28e1d29028854b95ee69f53 (patch)
tree597eaade14d885e9d685ea35d4dcd26f9fae2a60
parenta1434b747088633bd2dac2a5ad14ff7ace84aa0b (diff)
Don't overwrite HTML and LateX style files, generate style file for LaTeX
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5656 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--Changes3
-rw-r--r--ocamldoc/Makefile3
-rw-r--r--ocamldoc/Makefile.nt3
-rw-r--r--ocamldoc/odoc_html.ml15
-rw-r--r--ocamldoc/odoc_latex.ml21
-rw-r--r--ocamldoc/odoc_latex_style.ml74
-rw-r--r--ocamldoc/odoc_messages.ml3
7 files changed, 115 insertions, 7 deletions
diff --git a/Changes b/Changes
index 1b752af23..f74158f99 100644
--- a/Changes
+++ b/Changes
@@ -132,7 +132,8 @@ OCamldoc:
- handling recursive modules
- handling private types
- some fixes in html generation
-
+- don't overwrite existing style.css file when generating HTML
+- create the ocamldoc.sty file when generating LaTeX (if it does not already exists)
Objective Caml 3.06:
--------------------
diff --git a/ocamldoc/Makefile b/ocamldoc/Makefile
index 9b2d26776..ab25a4a25 100644
--- a/ocamldoc/Makefile
+++ b/ocamldoc/Makefile
@@ -112,6 +112,7 @@ EXECMOFILES=$(CMOFILES)\
odoc_ocamlhtml.cmo\
odoc_html.cmo\
odoc_man.cmo\
+ odoc_latex_style.cmo \
odoc_latex.cmo\
odoc_texi.cmo\
odoc_dot.cmo
@@ -229,7 +230,7 @@ odoc_crc.ml: $(CMIFILES)
Odoc_sig Odoc_ast Odoc_control Odoc_inherit \
Odoc_search Odoc_cross Odoc_merge Odoc_analyse \
Odoc_dag2html Odoc_ocamlhtml Odoc_html Odoc_to_text \
- Odoc_latex Odoc_man Odoc_texi Odoc_scan > $@
+ Odoc_latex_style Odoc_latex Odoc_man Odoc_texi Odoc_scan > $@
# Parsers and lexers dependencies :
###################################
diff --git a/ocamldoc/Makefile.nt b/ocamldoc/Makefile.nt
index 270d77d68..53dc034c8 100644
--- a/ocamldoc/Makefile.nt
+++ b/ocamldoc/Makefile.nt
@@ -109,6 +109,7 @@ EXECMOFILES=$(CMOFILES)\
odoc_ocamlhtml.cmo\
odoc_html.cmo\
odoc_man.cmo\
+ odoc_latex_style.cmo \
odoc_latex.cmo\
odoc_texi.cmo\
odoc_dot.cmo\
@@ -266,7 +267,7 @@ odoc_crc.ml: $(CMIFILES)
Odoc_sig Odoc_ast Odoc_control Odoc_inherit\
Odoc_search Odoc_cross Odoc_merge Odoc_analyse\
Odoc_dag2html Odoc_ocamlhtml Odoc_html Odoc_to_text \
- Odoc_latex Odoc_man Odoc_texi Odoc_scan > $@
+ Odoc_latex_style Odoc_latex Odoc_man Odoc_texi Odoc_scan > $@
# generic rules :
#################
diff --git a/ocamldoc/odoc_html.ml b/ocamldoc/odoc_html.ml
index 4dbe44aeb..8b1480b54 100644
--- a/ocamldoc/odoc_html.ml
+++ b/ocamldoc/odoc_html.ml
@@ -582,10 +582,17 @@ class html =
let default_style = String.concat "\n" default_style_options in
(
try
- let chanout = open_out (Filename.concat !Args.target_dir style_file) in
- output_string chanout default_style ;
- flush chanout ;
- close_out chanout
+ let file = Filename.concat !Args.target_dir style_file in
+ if Sys.file_exists file then
+ Odoc_info.verbose (Odoc_messages.file_exists_dont_generate file)
+ else
+ (
+ let chanout = open_out file in
+ output_string chanout default_style ;
+ flush chanout ;
+ close_out chanout;
+ Odoc_info.verbose (Odoc_messages.file_generated file)
+ )
with
Sys_error s ->
prerr_endline s ;
diff --git a/ocamldoc/odoc_latex.ml b/ocamldoc/odoc_latex.ml
index 2985f89fe..c6f59f9bc 100644
--- a/ocamldoc/odoc_latex.ml
+++ b/ocamldoc/odoc_latex.ml
@@ -892,8 +892,29 @@ class latex =
(match !Args.title with None -> "" | Some _ -> "\\maketitle\n")^
(if !Args.with_toc then "\\tableofcontents\n" else "")
+ (** Generate the LaTeX style file, if it does not exists. *)
+ method generate_style_file =
+ try
+ let dir = Filename.dirname !Args.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)
+ else
+ (
+ let chanout = open_out file in
+ output_string chanout Odoc_latex_style.content ;
+ flush chanout ;
+ close_out chanout;
+ Odoc_info.verbose (Odoc_messages.file_generated file)
+ )
+ with
+ Sys_error s ->
+ prerr_endline s ;
+ incr Odoc_info.errors ;
+
(** Generate the LaTeX file from a module list, in the {!Odoc_info.Args.out_file} file. *)
method generate module_list =
+ self#generate_style_file ;
if !Args.separate_files then
(
let f m =
diff --git a/ocamldoc/odoc_latex_style.ml b/ocamldoc/odoc_latex_style.ml
new file mode 100644
index 000000000..34e81ffe0
--- /dev/null
+++ b/ocamldoc/odoc_latex_style.ml
@@ -0,0 +1,74 @@
+(***********************************************************************)
+(* OCamldoc *)
+(* *)
+(* Maxence Guesdon, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 2001 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
+(** The content of the LaTeX style to generate when generating LaTeX code. *)
+
+let content ="
+%% Support macros for LaTeX documentation generated by ocamldoc.
+%% This file is in the public domain; do what you want with it.
+
+\\NeedsTeXFormat{LaTeX2e}
+\\ProvidesPackage{ocamldoc}
+ [2001/12/04 v1.0 ocamldoc support]
+
+\\newenvironment{ocamldoccode}{%
+ \\bgroup
+ \\leftskip\\@totalleftmargin
+ \\rightskip\\z@skip
+ \\parindent\\z@
+ \\parfillskip\\@flushglue
+ \\parskip\\z@skip
+ %\\noindent
+ \\@@par\\smallskip
+ \\@tempswafalse
+ \\def\\par{%
+ \\if@tempswa
+ \\leavevmode\\null\\@@par\\penalty\\interlinepenalty
+ \\else
+ \\@tempswatrue
+ \\ifhmode\\@@par\\penalty\\interlinepenalty\\fi
+ \\fi}
+ \\obeylines
+ \\verbatim@font
+ \\let\\org@prime~%
+ \\@noligs
+ \\let\\org@dospecials\\dospecials
+ \\g@remfrom@specials{\\\\}
+ \\g@remfrom@specials{\\{}
+ \\g@remfrom@specials{\\}}
+ \\let\\do\\@makeother
+ \\dospecials
+ \\let\\dospecials\\org@dospecials
+ \\frenchspacing\\@vobeyspaces
+ \\everypar \\expandafter{\\the\\everypar \\unpenalty}}
+{\\egroup\\par}
+
+\\def\\g@remfrom@specials#1{%
+ \\def\\@new@specials{}
+ \\def\\@remove##1{%
+ \\ifx##1#1\\else
+ \\g@addto@macro\\@new@specials{\\do ##1}\\fi}
+ \\let\\do\\@remove\\dospecials
+ \\let\\dospecials\\@new@specials
+ }
+
+\\newenvironment{ocamldocdescription}
+{\\list{}{\\rightmargin0pt \\topsep0pt}\\raggedright\\item\\relax}
+{\\endlist\\medskip}
+
+\\newenvironment{ocamldoccomment}
+{\\list{}{\\leftmargin 2\\leftmargini \\rightmargin0pt \\topsep0pt}\\raggedright\\item\\relax}
+{\\endlist}
+
+\\let\\ocamldocvspace\\vspace
+\\endinput
+"
+
diff --git a/ocamldoc/odoc_messages.ml b/ocamldoc/odoc_messages.ml
index 2fcebc3b3..ff9c5b2ac 100644
--- a/ocamldoc/odoc_messages.ml
+++ b/ocamldoc/odoc_messages.ml
@@ -245,6 +245,9 @@ let merging = "Merging..."
let cross_referencing = "Cross referencing..."
let generating_doc = "Generating documentation..."
let loading f = "Loading "^f^"..."
+let file_generated f = "File "^f^" generated."
+let file_exists_dont_generate f =
+ "File "^f^" exists, we don't generate it."
(** Messages for documentation generation.*)