package stog

  1. Overview
  2. Docs

Rewrite engine.

module XR = Xtmpl.Rewrite
exception Cant_open_cache_file of string

Exception raised when a cache file of a loaded plugin could not be open.

type 'a level_fun =
  1. | Fun_stog of Types.stog XR.env -> Types.stog -> Types.Doc_set.t -> Types.stog
  2. | Fun_data of 'a XR.env -> (Types.stog * 'a) -> Types.Doc_set.t -> Types.stog * 'a
  3. | Fun_stog_data of (Types.stog * 'a) XR.env -> (Types.stog * 'a) -> Types.Doc_set.t -> Types.stog * 'a

A function associated to a level. All functions take in parameter the environment, the stog and structure and the list of documents to rewrite. They return the new stog structure. Some function (Fun_data, Fun_stog_data) also handle an additional data structure: the callbacks in the environment also handle it, and the function returns it with the stog structure.

type 'a modul = {
  1. mod_data : 'a;
  2. mod_levels : 'a level_fun Types.Int_map.t;
  3. mod_name : string;
}

A structure containing data and functions associated to levels. Contains also the module name.

module type Module = sig ... end

A module.

type stog_state = {
  1. st_stog : Types.stog;
  2. st_modules : (module Module) list;
  3. st_docs : Types.Doc_set.t;
}
val run : ?use_cache:bool -> ?default_style:XR.tree list -> stog_state -> stog_state
val generate : ?use_cache:bool -> ?gen_cache:bool -> ?default_style:XR.tree list -> ?only_docs:string list -> Types.stog -> (module Module) list -> unit

Generate the target files, with the following steps:

  • create the output directory,
  • build the base environment from the site global attributes,
  • compute by-topic, by-keyword and by-month documents,
  • compute documents,
  • for each level, for each document, apply level functions on the document
  • output Types.doc.doc_out field in the destination file. @use_cache reuse documents from cache, default is true @gen_cache update cache, default is true
val doc_dst_file : Types.stog -> Types.doc -> string

Build the final file where the given document will be generated.

val doc_url : Types.stog -> Types.doc -> Url.t

Build the final url of the given document.

val env_of_defs : ?env:'a XR.env -> Types.def list -> 'a XR.env
val env_of_used_mods : Types.stog -> ?env:'a XR.env -> Types.Str_set.t -> 'a XR.env
type 'a stog_doc_rules = Types.stog -> Types.doc_id -> (XR.name * 'a XR.callback) list
val get_in_env : 'a -> 'a XR.env -> Stog.Types.Xml.name -> 'a * XR.tree list
val opt_in_env : 'a -> 'a XR.env -> Stog.Types.Xml.name -> 'a * XR.tree list option
val get_in_args_or_env : 'a -> 'a XR.env -> XR.attributes -> Stog.Types.Xml.name -> 'a * XR.tree list

get_in_args_or_env env args s returns the value associated to s in args of else return the result of get_in_env env s.

val get_path : 'a -> 'a XR.env -> 'a * Path.path

get_path env returns the path associated to "doc-path" in env.

  • raises Path.Invalid

    if "doc-path" is not found in the environment or is not a valid path.

val get_path_in_args_or_env : 'a -> 'a XR.env -> XR.attributes -> 'a * Path.path

Same as get_path but first looks for "doc-path" attribute in the given args.

val doc_env : 'a -> 'a XR.env -> Types.stog -> Types.doc -> 'a * 'a XR.env
val apply_stog_env_doc : Types.stog -> Types.stog XR.env -> Types.doc_id -> Types.stog
val apply_stog_data_env_doc : (Types.stog * 'a) -> (Types.stog * 'a) XR.env -> Types.doc_id -> Types.stog * 'a
val apply_data_env_doc : (Types.stog * 'a) -> 'a XR.env -> Types.doc_id -> Types.stog * 'a
val fun_apply_stog_doc_rules : Types.stog stog_doc_rules -> 'a level_fun
val fun_apply_stog_data_doc_rules : (Types.stog * 'a) stog_doc_rules -> 'a level_fun
val fun_apply_data_doc_rules : 'a stog_doc_rules -> 'a level_fun
val get_languages : 'a -> 'a XR.env -> 'a * string list

Registering modules

type module_fun = Types.stog -> (module Module)
val modules : unit -> (string * module_fun) list
val register_module : string -> module_fun -> unit
val module_by_name : string -> module_fun option