Skip to content

Commit

Permalink
conservation des textes des sections pour mettre de jolis texte pour …
Browse files Browse the repository at this point in the history
…les liens entre sections n html

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5091 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information
zoggy committed Aug 8, 2002
1 parent c8a0a1b commit eacc530
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 39 deletions.
2 changes: 1 addition & 1 deletion ocamldoc/odoc_cross.ml
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ let rec assoc_comments_text_elements module_list t_ele =
| Odoc_search.Res_exception _ -> RK_exception
| Odoc_search.Res_attribute _ -> RK_attribute
| Odoc_search.Res_method _ -> RK_method
| Odoc_search.Res_section _ -> RK_section
| Odoc_search.Res_section (_ ,t)-> RK_section t
in
Ref (name, Some kind)

Expand Down
41 changes: 24 additions & 17 deletions ocamldoc/odoc_html.ml
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,20 @@ class text =
done;
Buffer.contents buf

(** Return a label created from the first sentence of a text. *)
method label_of_text t=
let t2 = Odoc_info.first_sentence_of_text t in
let s = Odoc_info.string_of_text t2 in
let s2 = self#keep_alpha_num s in
s2

(** Create a label for the associated title.
If a label is given, use the label, or else create a mark
from the title level and the first sentence of the title.*)
Return the label specified by the user or a label created
from the title level and the first sentence of the title. *)
method create_title_label (n,label_opt,t) =
match label_opt with
Some s -> s
| None ->
let t2 = Odoc_info.first_sentence_of_text t in
let s = Odoc_info.string_of_text t2 in
let s2 = self#keep_alpha_num s in
Printf.sprintf "%d%s" n s2
| None -> Printf.sprintf "%d_%s" n (self#label_of_text t)

(** Return the html code corresponding to the [text] parameter. *)
method html_of_text t = String.concat "" (List.map self#html_of_text_element t)
Expand Down Expand Up @@ -227,8 +230,9 @@ class text =

method html_of_Title n label_opt t =
let css_class = "title"^(string_of_int n) in
let label1 = self#create_title_label (n, label_opt, t) in
"<br>\n"^
"<a name=\""^(Naming.label_target (self#create_title_label (n, label_opt, t)))^"\"></a>"^
"<a name=\""^(Naming.label_target label1)^"\"></a>\n"^
"<table cellpadding=5 cellspacing=5 width=\"100%\">\n"^
"<tr class=\""^css_class^"\"><td><div align=center>\n"^
"<span class=\""^css_class^"\">"^(self#html_of_text t)^"</span>\n"^
Expand All @@ -245,23 +249,26 @@ class text =
None ->
self#html_of_text_element (Odoc_info.Code name)
| Some kind ->
let target =
let h name = Odoc_info.Code (Odoc_info.use_hidden_modules name) in
let (target, text) =
match kind with
Odoc_info.RK_module
| Odoc_info.RK_module_type
| Odoc_info.RK_class
| Odoc_info.RK_class_type ->
let (html_file, _) = Naming.html_files name in
html_file
| Odoc_info.RK_value -> Naming.complete_target Naming.mark_value name
| Odoc_info.RK_type -> Naming.complete_target Naming.mark_type name
| Odoc_info.RK_exception -> Naming.complete_target Naming.mark_exception name
| Odoc_info.RK_attribute -> Naming.complete_target Naming.mark_attribute name
| Odoc_info.RK_method -> Naming.complete_target Naming.mark_method name
| Odoc_info.RK_section -> Naming.complete_label_target name
(html_file, h name)
| Odoc_info.RK_value -> (Naming.complete_target Naming.mark_value name, h name)
| Odoc_info.RK_type -> (Naming.complete_target Naming.mark_type name, h name)
| Odoc_info.RK_exception -> (Naming.complete_target Naming.mark_exception name, h name)
| Odoc_info.RK_attribute -> (Naming.complete_target Naming.mark_attribute name, h name)
| Odoc_info.RK_method -> (Naming.complete_target Naming.mark_method name, h name)
| Odoc_info.RK_section t -> (Naming.complete_label_target name,
Odoc_info.Italic [Raw (Odoc_info.string_of_text t)])
in
"<a href=\""^target^"\">"^
(self#html_of_text_element (Odoc_info.Code (Odoc_info.use_hidden_modules name)))^"</a>"
(self#html_of_text_element text)^
"</a>"

method html_of_Superscript t =
"<sup class=\"superscript\">"^(self#html_of_text t)^"</sup>"
Expand Down
6 changes: 3 additions & 3 deletions ocamldoc/odoc_info.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ type ref_kind = Odoc_types.ref_kind =
| RK_exception
| RK_attribute
| RK_method
| RK_section
| RK_section of text

type text_element = Odoc_types.text_element =
and text_element = Odoc_types.text_element =
| Raw of string
| Code of string
| CodePre of string
Expand Down Expand Up @@ -183,7 +183,7 @@ module Search =
| Res_exception of Exception.t_exception
| Res_attribute of Value.t_attribute
| Res_method of Value.t_method
| Res_section of string
| Res_section of string * text

type search_result = result_element list

Expand Down
6 changes: 3 additions & 3 deletions ocamldoc/odoc_info.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ type ref_kind = Odoc_types.ref_kind =
| RK_exception
| RK_attribute
| RK_method
| RK_section
| RK_section of text

type text_element = Odoc_types.text_element =
and text_element = Odoc_types.text_element =
| Raw of string (** Raw text. *)
| Code of string (** The string is source code. *)
| CodePre of string (** The string is pre-formatted source code. *)
Expand Down Expand Up @@ -708,7 +708,7 @@ module Search :
| Res_exception of Exception.t_exception
| Res_attribute of Value.t_attribute
| Res_method of Value.t_method
| Res_section of string
| Res_section of string * text

(** The type representing a research result.*)
type search_result = result_element list
Expand Down
4 changes: 2 additions & 2 deletions ocamldoc/odoc_latex.ml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class text =
None ->
self#latex_of_text_element
(Odoc_info.Code (Odoc_info.use_hidden_modules name))
| Some kind when kind = RK_section ->
| Some (RK_section _) ->
self#latex_of_text_element
(Latex ("["^(self#make_ref (self#label ~no_:false (Name.simple name)))^"]"))
| Some kind ->
Expand All @@ -279,7 +279,7 @@ class text =
| Odoc_info.RK_exception -> self#exception_label
| Odoc_info.RK_attribute -> self#attribute_label
| Odoc_info.RK_method -> self#method_label
| Odoc_info.RK_section -> assert false
| Odoc_info.RK_section _ -> assert false
in
(self#latex_of_text
[
Expand Down
4 changes: 2 additions & 2 deletions ocamldoc/odoc_man.ml
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ class man =
| Res_exception e -> Name.simple e.ex_name
| Res_attribute a -> Name.simple a.att_value.val_name
| Res_method m -> Name.simple m.met_value.val_name
| Res_section s -> assert false
| Res_section _ -> assert false
in
let all_items_pre = Odoc_info.Search.search_by_name module_list (Str.regexp ".*") in
let all_items = List.filter
Expand Down Expand Up @@ -809,7 +809,7 @@ class man =
| Res_exception e -> e.ex_name
| Res_attribute a -> a.att_value.val_name
| Res_method m -> m.met_value.val_name
| Res_section s -> s
| Res_section (s,_) -> s
)
in
let date = Unix.time () in
Expand Down
2 changes: 1 addition & 1 deletion ocamldoc/odoc_messages.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
let ok = "Ok"
let software = "OCamldoc"
let version = Config.version
let magic = version^"+0"
let magic = version^""
let message_version = software^" "^version

(** Messages for command line *)
Expand Down
6 changes: 3 additions & 3 deletions ocamldoc/odoc_search.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type result_element =
| Res_exception of t_exception
| Res_attribute of t_attribute
| Res_method of t_method
| Res_section of string
| Res_section of string * Odoc_types.text

type result = result_element list

Expand All @@ -52,7 +52,7 @@ module type Predicates =
module Search =
functor (P : Predicates) ->
struct
let search_section s v = if P.p_section s v then [Res_section s] else []
let search_section t s v = if P.p_section s v then [Res_section (s,t)] else []

let rec search_text root t v =
List.flatten (List.map (fun e -> search_text_ele root e v) t)
Expand Down Expand Up @@ -82,7 +82,7 @@ module Search =
| T.Title (n, l_opt, t) ->
(match l_opt with
None -> []
| Some s -> search_section (Name.concat root s) v) @
| Some s -> search_section t (Name.concat root s) v) @
(search_text root t v)

let search_value va v = if P.p_value va v then [Res_value va] else []
Expand Down
6 changes: 3 additions & 3 deletions ocamldoc/odoc_search.mli
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type result_element =
| Res_exception of Odoc_exception.t_exception
| Res_attribute of Odoc_value.t_attribute
| Res_method of Odoc_value.t_method
| Res_section of string
| Res_section of string * Odoc_types.text

(** The type representing a research result.*)
type result = result_element list
Expand Down Expand Up @@ -53,7 +53,7 @@ module Search :
functor (P : Predicates) ->
sig
(** search in a section title *)
val search_section : string -> P.t -> result_element list
val search_section : Odoc_types.text -> string -> P.t -> result_element list

(** search in a value *)
val search_value : Odoc_value.t_value -> P.t -> result_element list
Expand Down Expand Up @@ -110,7 +110,7 @@ module P_name :
(** A module to search elements by name. *)
module Search_by_name :
sig
val search_section : string -> P_name.t -> result_element list
val search_section : Odoc_types.text -> string -> P_name.t -> result_element list
val search_value : Odoc_value.t_value -> P_name.t -> result_element list
val search_type : Odoc_type.t_type -> P_name.t -> result_element list
val search_exception :
Expand Down
4 changes: 2 additions & 2 deletions ocamldoc/odoc_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ type ref_kind =
| RK_exception
| RK_attribute
| RK_method
| RK_section
| RK_section of text

type text_element =
and text_element =
| Raw of string
| Code of string
| CodePre of string
Expand Down
4 changes: 2 additions & 2 deletions ocamldoc/odoc_types.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ type ref_kind =
| RK_exception
| RK_attribute
| RK_method
| RK_section
| RK_section of text

type text_element =
and text_element =
| Raw of string (** Raw text. *)
| Code of string (** The string is source code. *)
| CodePre of string (** The string is pre-formatted source code. *)
Expand Down

0 comments on commit eacc530

Please sign in to comment.