• en

Module Cow

module Xml : sig
type encoding = TODO: a
The type for character encodings. For `UTF_16, endianness is determined from the BOM.
type dtd = string option
The type for the optional DTD.
type name = (string * string)
The type for attribute and element's expanded names (uri,local). An empty uri represents a name without a namespace name, i.e. an unprefixed name that is not under the scope of a default namespace.
type attribute = (name * string)
The type for attributes. Name and attribute data.
type tag = (name * attribute list)
The type for an element tag. Tag name and attribute list.
type signal = TODO: a
The type for signals. A well-formed sequence of signals belongs to the language of the doc grammar :
doc ::= `Dtd tree
tree ::= `El_start child `El_end
child ::= `Data | tree | epsilon
Input and output deal only with well-formed sequences or exceptions are raised.
val ns_xml : string
Namespace name value bound to the reserved "xml" prefix.
val ns_xmlns : string
Namespace name value bound to the reserved "xmlns" prefix.
type pos = (int * int)
The type for input positions. Line and column number, both start with 1.
type error = TODO: a
The type for input errors.
val error_message : error -> string
Converts the error to an english error message.
exception Error of pos * error
Raised on input errors.
type source = TODO: a
The type for input sources. For `String starts reading at the given integer position. For `Fun the function must return the next byte as an int and raise End_of_file if there is no such byte.
type input
The type for input abstractions.
val make_input : ?enc:encoding option -> ?strip:bool -> ?ns:string -> string option -> ?entity:string -> string option -> source -> input
Returns a new input abstraction reading from the given source.
  • enc, character encoding of the document, details. Defaults to None.
  • strip, strips whitespace in character data, details. Defaults to false.
  • ns is called to bind undeclared namespace prefixes, details. Default returns always None.
  • entity is called to resolve non predefined entity references, details. Default returns always None.
val input : input -> signal
Inputs a signal. Repeated invocation of the function with the same input abstraction will generate a well-formed sequence of signals or an Error is raised. Furthermore there will be no two consecutive `Data signals in the sequence and their string is always non empty.
Deprecated After a well-formed sequence was input another may be input, see eoi and details.
Raises Error on input errors.
val input_tree : el:tag -> 'a list -> 'a -> data:string -> 'a -> input -> 'a
If the next signal is a :
  • `Data signal, inputs it and invokes data with the character data.
  • `El_start signal, inputs the sequence of signals until its matching `El_end and invokes el and data as follows
    • el, is called on each `El_end signals with the corresponding `El_start tag and the result of the callback invocation for the element's children.
    • data, is called on each `Data signals with the character data. This function won't be called twice consecutively or with the empty string.
  • Other signals, raises Invalid_argument.

Raises Error on input errors and Invalid_argument if the next signal is not `El_start or `Data.
val input_doc_tree : el:tag -> 'a list -> 'a -> data:string -> 'a -> input -> (dtd * 'a)
Same as input_tree but reads a complete well-formed sequence of signals.
Raises Error on input errors and Invalid_argument if the next signal is not `Dtd.
val peek : input -> signal
Same as input but doesn't remove the signal from the sequence.
Raises Error on input errors.
val eoi : input -> bool
Returns true if the end of input is reached. See details.
Raises Error on input errors.
val pos : input -> pos
Current position in the input abstraction.
type 'a frag = TODO: b
The type for deconstructing data structures of type 'a.
type dest = TODO: a
The type for output destinations. For `Buffer, the buffer won't be cleared. For `Fun the function is called with the output bytes as ints.
type output
The type for output abstractions.
val make_output : ?decl:bool -> ?nl:bool -> ?indent:int option -> ?ns_prefix:string -> string option -> dest -> output
Returns a new output abstraction writing to the given destination.
  • decl, if true the XML declaration is output (defaults to true).
  • nl, if true a newline is output when the root's element `El_end signal is output. Defaults to false.
  • indent, identation behaviour, see details. Defaults to None.
  • ns_prefix, undeclared namespace prefix bindings, see details. Default returns always None.
val output : output -> signal -> unit
Outputs a signal.
Deprecated. After a well-formed sequence of signals was output a new well-formed sequence can be output.
Raises Invalid_argument if the resulting signal sequence on the output abstraction is not well-formed or if a namespace name could not be bound to a prefix.
val output_depth : output -> int
output_depth o is o's current element nesting level (undefined before the first `El_start and after the last `El_end).
val output_tree : 'a -> 'a frag -> output -> 'a -> unit
Outputs signals corresponding to a value by recursively applying the given value deconstructor.
Raises see output.
val output_doc_tree : 'a -> 'a frag -> output -> (dtd * 'a) -> unit
Same as output_tree but outputs a complete well-formed sequence of signals.
Raises see output.
type std_string = string
type std_buffer = Buffer.t
module type String = sig
Input signature for strings.
type t
The type for strings.
val empty : t
The empty string.
val length : t -> int
Returns the length of the string.
val append : t -> t -> t
Concatenates two strings.
val lowercase : t -> t
New string with uppercase letter translated to lowercase (correctness is only needed for ASCII code point).
val iter : int -> unit -> t -> unit
Iterates over the unicode code point of the given string.
val of_string : std_string -> t
String from an OCaml string.
val to_utf_8 : 'a -> std_string -> 'a -> 'a -> t -> 'a
to_utf_8 f v s, is f (... (f (f v s1) s2) ...) sn. Where the concatenation of s1, s2, ... sn is s as an UTF-8 stream.
val compare : t -> t -> int
String comparison. Binary comparison is sufficent.
end
module type Buffer = sig
Input signature for internal buffers.
type string
The type for strings.
type t
The type for buffers.
exception Full
Raised if the buffer cannot be grown.
val create : int -> t
Creates a buffer of the given size.
val add_uchar : t -> int -> unit
Adds the given (guaranteed valid) unicode code point to a buffer.
Raises Full if the buffer cannot be grown.
val clear : t -> unit
Clears the buffer.
val contents : t -> string
Returns the buffer contents.
val length : t -> int
Returns the number of characters contained in the buffer.
end
module type S = sig
Output signature of Make.
type string
type encoding = TODO: a
type dtd = string option
type name = (string * string)
type attribute = (name * string)
type tag = (name * attribute list)
type signal = TODO: a
val ns_xml : string
val ns_xmlns : string
type pos = (int * int)
type error = TODO: a
exception Error of pos * error
val error_message : error -> string
type source = TODO: a
type input
val make_input : ?enc:encoding option -> ?strip:bool -> ?ns:string -> string option -> ?entity:string -> string option -> source -> input
val input : input -> signal
val input_tree : el:tag -> 'a list -> 'a -> data:string -> 'a -> input -> 'a
val input_doc_tree : el:tag -> 'a list -> 'a -> data:string -> 'a -> input -> (dtd * 'a)
val peek : input -> signal
val eoi : input -> bool
val pos : input -> pos
type 'a frag = TODO: b
type dest = TODO: a
type output
val make_output : ?decl:bool -> ?nl:bool -> ?indent:int option -> ?ns_prefix:string -> string option -> dest -> output
val output_depth : output -> int
val output : output -> signal -> unit
val output_tree : 'a -> 'a frag -> output -> 'a -> unit
val output_doc_tree : 'a -> 'a frag -> output -> (dtd * 'a) -> unit
end
TODO: functor:cow.1.0.0/cow/Cow.Xml.Make
type t = TODO alias 'a frag a frag list
val to_string : ?decl:bool -> t -> string
val of_string : ?entity:string -> string option -> ?enc:encoding -> string -> t
end
module Xhtml : sig
val entities : (string * string) list
val entity : string -> string option
end
module Html : sig
type t = TODO alias 'a Xml.frag a Xml.frag list
val to_string : t -> string
val of_string : ?enc:Xml.encoding -> string -> t
val interleave : string array -> t list -> t list
val html_of_string : string -> t
val html_of_int : int -> t
val html_of_float : float -> t
type table = t array array
val html_of_table : ?headings:bool -> table -> t
val nil : t
end
module Css : sig
type elt =
| Str of string
| Fun of string * expr list
type expr = elt list
Expression: `.body a:hover`. No commas here.
type prop_decl =
| Prop of string * expr list
| Decl of expr list * prop_decl list
We allow nested declarations
type t =
| Props of prop_decl list
| Exprs of expr list
The type of CSS fragment
val to_string : t -> string
Print CSS to a string suitable for rendering
val expr : t -> expr
val exprs : t -> expr list
val props : t -> prop_decl list
val string : t -> string
val unroll : t -> t
transform a fragment with nested declarations into an equivalent fragment with only root declarations
val gradient : low:t -> high:t -> t
Emit a CSS gradient style that linearly interpolates between the low and high colors
val top_rounded : t
Emit a border style that rounds off the bottom border by 0.5em pixels.
val bottom_rounded : t
val rounded : t
val box_shadow : t
val text_shadow : t
val no_padding : t
val reset_padding : t
end
module Code : sig
val ocaml : string -> Html.t
val ocaml_fragment : string -> Html.t
Convert a string into an xHTML fragment, where keywords have been classified in different classes.
val ocaml_css : Css.t
CSS fragment to colorize the keywords, depending on their class
end
module Atom : sig
type author = {
name : string;
uri : string option;
email : string option;
}
type date = (int * int * int * int * int)
year, month, date, hour, minute
val compare : date -> date -> int
type meta = {
id : string;
title : string;
subtitle : string option;
author : author option;
rights : string option;
updated : date;
links : link list;
}
type summary = string option
type entry = {
entry : meta;
summary : summary;
content : Xml.t;
base : string option;
}
type feed = {
feed : meta;
entries : entry list;
}
val xml_of_feed : ?self:string -> feed -> Xml.t
end
module Markdown : sig
type t = Html.t
val to_string : t -> string
val of_string : string -> t
end
module Json : sig
type t = TODO: a
The type of JSON documents.
val from_channel : Pervasives.in_channel -> t
Read a JSON document from an input channel.
val from_string : string -> t
Read a JSON document from a string.
val from_src : Jsonm.src -> t
Low-level function to read directly from an Jsonm source.
val to_channel : ?minify:bool -> Pervasives.out_channel -> t -> unit
Write a JSON document to an output channel.
val to_dst : ?minify:bool -> Jsonm.dst -> t -> unit
Low-level function to write directly to a Jsonm destination.
val unit : t
Same as `Null.
val bool : bool -> t
Same as `Bool b.
val string : string -> t
Same as `String s.
val strings : string list -> t
Same as `A [`String s1; ..; `String sn].
val int : int -> t
Same as `Float (int_of_string i).
val float : float -> t
Some as `Float f.
val list : 'a -> t -> 'a list -> t
Build a list of values.
val option : 'a -> t -> 'a option -> t
Either `Null or a JSON value.
val dict : (string * t) list -> t
Build a dictionnary.
val pair : 'a -> t -> 'b -> t -> ('a * 'b) -> t
Build a pair.
exception Parse_error of t * string
All the following accessor functions expect the provided JSON document to be of a certain kind. In case this is not the case, Parse_error is raised.
val get_unit : t -> unit
Check that the JSON document is `Null.
val get_bool : t -> bool
Extract b from `Bool b.
val get_string : t -> string
Extract s from `String s.
val get_strings : t -> string list
Extract s1;..;sn from `A [`String s1; ...; `String sn].
val get_int : t -> int
Extract an integer.
val get_float : t -> float
Extract a float.
val get_list : t -> 'a -> t -> 'a list
Extract elements from a list document..
val get_option : t -> 'a -> t -> 'a option
Extract an optional document.
val get_dict : t -> (string * t) list
Extract the elements from a dictionnary document.
val get_pair : t -> 'a -> t -> 'b -> t -> ('a * 'b)
Extract the pairs.
val mem : t -> string list -> bool
Is the given path valid if the provided JSON document.
val find : t -> string list -> t
Find the sub-document adressed by the given path. Raise Not_found if the path is invalid.
val update : t -> string list -> t option -> t
Update the sub-document addressed by the given path. If the provided value is None, then removes the sub-document.
val map : t -> t option -> t -> string list -> t
Apply a given function to a subdocument.
val to_buffer : t -> Buffer.t -> unit
val to_string : t -> string
val to_buffer_hum : t -> Buffer.t -> unit
val to_string_hum : t -> string
val of_string : string -> t
exception Runtime_error of string * t
end