+ (* Check long descriptions. *)
+ let () =
+ let cmds = List.map (fun (name, _, _, _, _, _, _) -> name) all_functions in
+
+ List.iter (
+ fun (name, style, _, _, _, _, longdesc) ->
+ let args = List.map name_of_argt (snd style) in
+
+ if longdesc = [] then
+ failwithf "%s has no long description" name;
+
+ let rec check_para = function
+ | Q str -> check_snippet (T str)
+ | P snips -> List.iter check_snippet snips
+ | ItemList xs ->
+ List.iter
+ (fun (snips, para) -> check_para (P snips); check_para para)
+ xs
+ | BulletList ps -> List.iter check_para ps
+ | QNote str -> check_snippet (T str)
+ | Note snips -> List.iter check_snippet snips
+ | Pre xs -> List.iter (fun str -> check_snippet (T str)) xs
+ | SeeAlso xs -> List.iter (fun cmd -> check_snippet (X cmd)) xs
+ and check_snippet = function
+ | T str | Em str ->
+ if str = "" then
+ failwithf "%s has empty string snippet (eg. T\"\")" name;
+ check_no_perldoc str
+ | C code ->
+ if List.mem code args then
+ failwithf "%s has C\"%s\", should be A\"%s\"" name code code;
+ if code = "NULL" || code = "non-NULL" then
+ failwithf "%s C\"%s\" should be NULL|NONNULL" name code;
+ | A arg ->
+ if not (List.mem arg args) then
+ failwithf "%s A\"%s\" refers to non-existent arg" name arg;
+ | X cmd | XA (cmd, _) ->
+ if not (List.mem cmd cmds) then
+ failwithf "%s X\"%s\" refers to non-existent command" name cmd;
+ | XU cmd ->
+ if List.mem cmd cmds then
+ failwithf "%s XU\"%s\" should be X\"%s\"" name cmd cmd;
+ | XW cmd -> ()
+ | Man ("guestfs", 3) -> ()
+ | Man ("guestfish", 1) -> ()
+ | Man (man, sect) ->
+ let prefix = sprintf "/usr/share/man/man%d/%s.%d" sect man sect in
+ if not (Sys.file_exists prefix) &&
+ not (Sys.file_exists (prefix ^ ".gz")) then
+ eprintf "warning: %s: refers to non-existent manpage %s(%d)\n"
+ name man sect
+ | URL _
+ | NULL | NONNULL -> ()
+ and check_no_perldoc str =
+ if find str "C<" >= 0 || find str "I<" >= 0
+ || find str "B<" >= 0 || find str "E<" >= 0
+ || find str "\n=" >= 0 then
+ failwithf "%s long description contains perldoc markup" name
+ in
+ List.iter check_para longdesc
+ ) all_functions in