diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7495d2db2eac8dc465870cfca54103d482a2e39b..9171386375756a0996f8e03575815d9bd8fd35c7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,6 +1,6 @@
variables:
## Please update `scripts/version.sh` accordingly
- build_deps_image_version: b98d1114e1bafbe50f017e619cbfcede77df0149
+ build_deps_image_version: 0965ca9934ba0f86a18637984d23e4c0e8dc0100
build_deps_image_name: registry.gitlab.com/tezos/opam-repository
public_docker_image_name: docker.io/${CI_PROJECT_PATH}
GIT_STRATEGY: fetch
@@ -56,7 +56,7 @@ check_opam_lint:
check_linting:
<<: *build_definition
script:
- - dune build @runtest_lint
+ - src/tooling/lint.sh check.ci
build:
<<: *build_definition
diff --git a/Makefile b/Makefile
index 19f16eadb5db62514171d4e0669b3847bb7a0966..dd7fda758ec1b50f0ec083953d3e4c60674e1a64 100644
--- a/Makefile
+++ b/Makefile
@@ -97,8 +97,8 @@ test-lint:
@dune build @runtest_lint
make -C tests_python lint_all
-fix-lint:
- @src/tooling/lint.sh fix
+fmt:
+ @src/tooling/lint.sh format
build-deps:
@./scripts/install_build_deps.sh
diff --git a/docs/doc_gen/.ocamlformat b/docs/doc_gen/.ocamlformat
new file mode 100644
index 0000000000000000000000000000000000000000..9d2a5a5f36ace033597a4fade91b31f5d3e1ec47
--- /dev/null
+++ b/docs/doc_gen/.ocamlformat
@@ -0,0 +1,11 @@
+wrap-fun-args=false
+let-binding-spacing=compact
+field-space=loose
+break-separators=after-and-docked
+sequence-style=separator
+doc-comments=before
+margin=80
+module-item-spacing=sparse
+parens-tuple=always
+parens-tuple-patterns=always
+break-string-literals=newlines-and-wrap
diff --git a/docs/doc_gen/errors/.ocamlformat b/docs/doc_gen/errors/.ocamlformat
new file mode 100644
index 0000000000000000000000000000000000000000..9d2a5a5f36ace033597a4fade91b31f5d3e1ec47
--- /dev/null
+++ b/docs/doc_gen/errors/.ocamlformat
@@ -0,0 +1,11 @@
+wrap-fun-args=false
+let-binding-spacing=compact
+field-space=loose
+break-separators=after-and-docked
+sequence-style=separator
+doc-comments=before
+margin=80
+module-item-spacing=sparse
+parens-tuple=always
+parens-tuple-patterns=always
+break-string-literals=newlines-and-wrap
diff --git a/docs/doc_gen/errors/error_doc.ml b/docs/doc_gen/errors/error_doc.ml
index 9cf5c8d9e88a69bbeb1950eb3188e98b9349c3e5..c04ab374fa403bfea29cbbbf900435e8869319da 100644
--- a/docs/doc_gen/errors/error_doc.ml
+++ b/docs/doc_gen/errors/error_doc.ml
@@ -28,6 +28,7 @@ open Format
(* TODO: add section descriptions *)
let default_section_id = "default"
+
let default_section_title = "Miscellaneous"
(* Association list where keys are set of identifier's prefixes that
@@ -39,29 +40,34 @@ let default_section_title = "Miscellaneous"
bottom of the document. Unprefixed ids or unreferenced prefixes
will default to `Miscellaneous` *)
let section_titles =
- [ [ "proto.alpha" ], "Protocol Alpha";
- [ "distributed_db" ; "node" ; "raw_store" ; "validator" ; "worker" ], "Shell" ;
- [ "micheline" ; "michelson" ], "Michelson parsing/macros" ;
- [ "rpc_client" ], "Client" ;
- [ "cli"; "utils"; default_section_id ], default_section_title ;
- ]
+ [ (["proto.alpha"], "Protocol Alpha");
+ (["distributed_db"; "node"; "raw_store"; "validator"; "worker"], "Shell");
+ (["micheline"; "michelson"], "Michelson parsing/macros");
+ (["rpc_client"], "Client");
+ (["cli"; "utils"; default_section_id], default_section_title) ]
+
let pp_rst_title ~char ppf title =
let sub = String.map (fun _ -> char) title in
fprintf ppf "@[%s@\n@]@[%s@\n@\n@]" title sub
let pp_rst_h1 = pp_rst_title ~char:'#'
+
let pp_rst_h2 = pp_rst_title ~char:'*'
+
(* let pp_rst_h3 = pp_rst_title ~char:'='
* let pp_rst_h4 = pp_rst_title ~char:'`' *)
let string_of_err_category = function
- | `Branch -> "branch"
- | `Temporary -> "temporary"
- | `Permanent -> "permanent"
+ | `Branch ->
+ "branch"
+ | `Temporary ->
+ "temporary"
+ | `Permanent ->
+ "permanent"
let make_counter () =
let i = ref 1 in
- fun () -> incr i; !i
+ fun () -> incr i ; !i
let count = make_counter ()
@@ -69,80 +75,105 @@ let unique_label () =
let label = sprintf "ref%d" (count ()) in
label
-let pp_print_html_tab_button fmt ?(default=false) ~shortlabel ~content idref =
- fprintf fmt "@ "
+let pp_print_html_tab_button fmt ?(default = false) ~shortlabel ~content idref
+ =
+ fprintf
+ fmt
+ "@ "
(if default then " defaultOpen" else "")
- (idref ^ shortlabel) idref content
+ (idref ^ shortlabel)
+ idref
+ content
-let pp_print_html_tabs fmt { Error_monad.id ; category ; description ; schema ; _ } =
+let pp_print_html_tabs fmt {Error_monad.id; category; description; schema; _} =
let idref = unique_label () in
let descr_label = "descr" in
let schema_label = "schema" in
-
- fprintf fmt "@[.. raw:: html@ @ ";
- fprintf fmt "@[@ ";
-
- fprintf fmt "%a" (pp_print_html_tab_button ~default:true ~shortlabel:descr_label ~content:"Description") idref;
- fprintf fmt "%a" (pp_print_html_tab_button ~default:false ~shortlabel:schema_label ~content:"JSON Schema") idref;
- fprintf fmt "@
@ @]";
-
+ fprintf fmt "@[.. raw:: html@ @ " ;
+ fprintf fmt "@[@ " ;
+ fprintf
+ fmt
+ "%a"
+ (pp_print_html_tab_button
+ ~default:true
+ ~shortlabel:descr_label
+ ~content:"Description")
+ idref ;
+ fprintf
+ fmt
+ "%a"
+ (pp_print_html_tab_button
+ ~default:false
+ ~shortlabel:schema_label
+ ~content:"JSON Schema")
+ idref ;
+ fprintf fmt "@
@ @]" ;
let description_content =
- asprintf "%s
Id : %s
Category : %s
" description id (string_of_err_category category)
+ asprintf
+ "%s
Id : %s
Category : %s
"
+ description
+ id
+ (string_of_err_category category)
in
-
- open_vbox 2;
-
+ open_vbox 2 ;
(* Print description *)
- begin
- fprintf fmt "@ "
- (idref ^ descr_label) idref;
- fprintf fmt "%s@ " description_content;
- fprintf fmt "
@]";
- end;
-
+ fprintf
+ fmt
+ "@ "
+ (idref ^ descr_label)
+ idref ;
+ fprintf fmt "%s@ " description_content ;
+ fprintf fmt "
@]" ;
(* Print schema *)
- begin
- (* Hack: negative offset in order to reduce the 's content left-margin *)
- (* TODO: pretty-(html)-print the schema *)
- open_vbox (-8);
- fprintf fmt "@ "
- (idref ^ schema_label) idref;
- fprintf fmt "<%s>@ %a%s>@ " "pre" Json_schema.pp schema "pre";
- fprintf fmt "
";
- close_box ();
- end;
+ (* Hack: negative offset in order to reduce the 's content left-margin *)
+ (* TODO: pretty-(html)-print the schema *)
+ open_vbox (-8) ;
+ fprintf
+ fmt
+ "@ "
+ (idref ^ schema_label)
+ idref ;
+ fprintf fmt "<%s>@ %a%s>@ " "pre" Json_schema.pp schema "pre" ;
+ fprintf fmt "
" ;
+ close_box () ;
close_box ()
-let pp_info_to_rst
- ppf
- (Error_monad.{ title ; _ } as error_info) =
+let pp_info_to_rst ppf (Error_monad.{title; _} as error_info) =
let open Format in
+ fprintf ppf "**%s**@\n@\n" (if title = "" then "" else title) ;
+ fprintf ppf "@[%a@ @ @]" pp_print_html_tabs error_info
- fprintf ppf "**%s**@\n@\n" (if title = "" then "" else title);
- fprintf ppf "@[%a@ @ @]" pp_print_html_tabs error_info;
+module ErrorSet = Set.Make (struct
+ type t = Error_monad.error_info
-module ErrorSet = Set.Make(struct
- type t = Error_monad.error_info
- let compare { Error_monad.id ; _ } { Error_monad.id = id' ; _ } =
- String.compare id id'
- end)
+ let compare {Error_monad.id; _} {Error_monad.id = id'; _} =
+ String.compare id id'
+end)
module ErrorPartition = struct
- include Map.Make(struct
- include String
- let titles = List.map snd section_titles
-
- let compare s s' =
- let idx s =
- let rec loop acc = function
- | [] -> assert false
- | h::_ when h = s -> acc
- | _::t -> loop (acc + 1) t
- in loop 0 titles
+ include Map.Make (struct
+ include String
+
+ let titles = List.map snd section_titles
+
+ let compare s s' =
+ let idx s =
+ let rec loop acc = function
+ | [] ->
+ assert false
+ | h :: _ when h = s ->
+ acc
+ | _ :: t ->
+ loop (acc + 1) t
in
- Pervasives.compare (idx s) (idx s')
- end)
+ loop 0 titles
+ in
+ Pervasives.compare (idx s) (idx s')
+ end)
let add_error (id : key) (error : Error_monad.error_info) (map : 'a t) =
let title =
@@ -150,84 +181,45 @@ module ErrorPartition = struct
snd
(List.find
(fun (id_set, _) ->
- List.exists (fun pattern -> Stringext.find_from id ~pattern = Some 0) id_set)
+ List.exists
+ (fun pattern -> Stringext.find_from id ~pattern = Some 0)
+ id_set)
section_titles)
- with
- | Not_found -> default_section_title
- in
- let set =
- try find title map with Not_found -> ErrorSet.empty
+ with Not_found -> default_section_title
in
+ let set = try find title map with Not_found -> ErrorSet.empty in
add title (ErrorSet.add error set) map
end
let pp_error_map ppf (map : ErrorSet.t ErrorPartition.t) : unit =
let open Format in
- ErrorPartition.iter (fun section_title set ->
+ ErrorPartition.iter
+ (fun section_title set ->
fprintf ppf "%a" pp_rst_h2 section_title ;
-
ErrorSet.iter
(fun error_repr ->
- fprintf ppf "@[%a@]@\n@\n" pp_info_to_rst error_repr
- ) set
- ) map
+ fprintf ppf "@[%a@]@\n@\n" pp_info_to_rst error_repr)
+ set)
+ map
let script =
- ""
+ ""
let style =
- ""
+ ""
let print_script ppf =
(* HACK : show/hide JSON schemas + style *)
@@ -238,26 +230,22 @@ let print_script ppf =
let () =
let open Format in
let ppf = std_formatter in
-
(* Header *)
let title = "RPC Errors" in
fprintf ppf "%a" pp_rst_h1 title ;
-
print_script ppf ;
-
- fprintf ppf
- "This document references possible errors that can come \
- from RPC calls. It is generated from the OCaml source \
- code (master branch).@\n@\n" ;
-
+ fprintf
+ ppf
+ "This document references possible errors that can come from RPC calls. \
+ It is generated from the OCaml source code (master branch).@\n\
+ @\n" ;
(* Body *)
let map =
- let all_errors =
- Error_monad.get_registered_errors () in
+ let all_errors = Error_monad.get_registered_errors () in
List.fold_left
- (fun acc ( Error_monad.{ id ; _ } as error ) ->
- ErrorPartition.add_error id error acc
- ) ErrorPartition.empty all_errors
+ (fun acc (Error_monad.{id; _} as error) ->
+ ErrorPartition.add_error id error acc)
+ ErrorPartition.empty
+ all_errors
in
-
fprintf ppf "%a" pp_error_map map
diff --git a/docs/doc_gen/node_helpers.ml b/docs/doc_gen/node_helpers.ml
index 5fabb0fb88675201b16d0722e04af7c0fd4d06d0..a9e3416eb63bd35afc0c83a6a5a629ceb869e8f9 100644
--- a/docs/doc_gen/node_helpers.ml
+++ b/docs/doc_gen/node_helpers.ml
@@ -23,29 +23,31 @@
(* *)
(*****************************************************************************)
-let genesis : State.Chain.genesis = {
- time =
- Time.Protocol.of_notation_exn "2018-04-17T11:46:23Z" ;
- block =
- Block_hash.of_b58check_exn
- "BLockGenesisGenesisGenesisGenesisGenesisa52f8bUWPcg" ;
- protocol =
- Protocol_hash.of_b58check_exn
- "ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im" ;
-}
+let genesis : State.Chain.genesis =
+ {
+ time = Time.Protocol.of_notation_exn "2018-04-17T11:46:23Z";
+ block =
+ Block_hash.of_b58check_exn
+ "BLockGenesisGenesisGenesisGenesisGenesisa52f8bUWPcg";
+ protocol =
+ Protocol_hash.of_b58check_exn
+ "ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im";
+ }
let with_node f =
let run dir =
- let (/) = Filename.concat in
- let node_config : Node.config = {
- genesis ;
- patch_context = None ;
- store_root = dir / "store" ;
- context_root = dir / "context" ;
- p2p = None ;
- test_chain_max_tll = None ;
- checkpoint = None ;
- } in
+ let ( / ) = Filename.concat in
+ let node_config : Node.config =
+ {
+ genesis;
+ patch_context = None;
+ store_root = dir / "store";
+ context_root = dir / "context";
+ p2p = None;
+ test_chain_max_tll = None;
+ checkpoint = None;
+ }
+ in
Node.create
node_config
Node.default_peer_validator_limits
@@ -53,10 +55,10 @@ let with_node f =
Node.default_prevalidator_limits
Node.default_chain_validator_limits
None
- >>=? fun node ->
- f node >>=? fun () ->
- return () in
- Lwt_utils_unix.with_tempdir "tezos_rpcdoc_" run >>= function
+ >>=? fun node -> f node >>=? fun () -> return ()
+ in
+ Lwt_utils_unix.with_tempdir "tezos_rpcdoc_" run
+ >>= function
| Ok () ->
Lwt.return_unit
| Error err ->
diff --git a/docs/doc_gen/p2p_doc.ml b/docs/doc_gen/p2p_doc.ml
index 8925b2e7169db1d0236aa497e9a918f4c15789b7..f8322be7f20bd1f8acdba1e0330ea26d9d760f24 100644
--- a/docs/doc_gen/p2p_doc.ml
+++ b/docs/doc_gen/p2p_doc.ml
@@ -23,9 +23,8 @@
(* *)
(*****************************************************************************)
-let protocols = [
- "Alpha", "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK" ;
-]
+let protocols =
+ [("Alpha", "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK")]
let main _node =
(* Style : hack *)
@@ -37,34 +36,40 @@ let main _node =
(* include/copy usage.rst from input *)
let rec loop () =
let s = read_line () in
- Format.printf "%s@\n" s ;
- loop () in
- begin try loop () with End_of_file -> () end ;
+ Format.printf "%s@\n" s ; loop ()
+ in
+ (try loop () with End_of_file -> ()) ;
Format.printf "@\n" ;
(* Data *)
- Format.printf "%a@\n@\n%a@\n@."
- Rst.pp_h2 "Block header (shell)"
+ Format.printf
+ "%a@\n@\n%a@\n@."
+ Rst.pp_h2
+ "Block header (shell)"
Data_encoding.Binary_schema.pp
(Data_encoding.Binary.describe Block_header.encoding) ;
- Format.printf "%a@\n@\n%a@\n@."
- Rst.pp_h2 "Operation (shell)"
+ Format.printf
+ "%a@\n@\n%a@\n@."
+ Rst.pp_h2
+ "Operation (shell)"
Data_encoding.Binary_schema.pp
(Data_encoding.Binary.describe Operation.encoding) ;
List.iter
(fun (_name, hash) ->
- let hash = Protocol_hash.of_b58check_exn hash in
- let (module Proto) = Registered_protocol.get_exn hash in
- Format.printf "%a@\n@\n%a@\n@."
- Rst.pp_h2 "Block_header (alpha-specific)"
- Data_encoding.Binary_schema.pp
- (Data_encoding.Binary.describe Proto.block_header_data_encoding) ;
- Format.printf "%a@\n@\n%a@\n@."
- Rst.pp_h2 "Operation (alpha-specific)"
- Data_encoding.Binary_schema.pp
- (Data_encoding.Binary.describe Proto.operation_data_encoding) ;
- )
+ let hash = Protocol_hash.of_b58check_exn hash in
+ let (module Proto) = Registered_protocol.get_exn hash in
+ Format.printf
+ "%a@\n@\n%a@\n@."
+ Rst.pp_h2
+ "Block_header (alpha-specific)"
+ Data_encoding.Binary_schema.pp
+ (Data_encoding.Binary.describe Proto.block_header_data_encoding) ;
+ Format.printf
+ "%a@\n@\n%a@\n@."
+ Rst.pp_h2
+ "Operation (alpha-specific)"
+ Data_encoding.Binary_schema.pp
+ (Data_encoding.Binary.describe Proto.operation_data_encoding))
protocols ;
return ()
-let () =
- Lwt_main.run (Node_helpers.with_node main)
+let () = Lwt_main.run (Node_helpers.with_node main)
diff --git a/docs/doc_gen/rpc_doc.ml b/docs/doc_gen/rpc_doc.ml
index 81e6b8b2dd0de47c0753f83d4dfd22ecbe0c3a3a..203b96dfe8436ad701d3179fbcab7004481fe004 100644
--- a/docs/doc_gen/rpc_doc.ml
+++ b/docs/doc_gen/rpc_doc.ml
@@ -23,16 +23,18 @@
(* *)
(*****************************************************************************)
-let protocols = [
- "Alpha", "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK" ;
-]
+let protocols =
+ [("Alpha", "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK")]
let pp_name ppf = function
- | [] | [""] -> Format.pp_print_string ppf "/"
- | prefix -> Format.pp_print_string ppf (String.concat "/" prefix)
+ | [] | [""] ->
+ Format.pp_print_string ppf "/"
+ | prefix ->
+ Format.pp_print_string ppf (String.concat "/" prefix)
let ref_of_service (prefix, meth) =
- Format.asprintf "%s_%s"
+ Format.asprintf
+ "%s_%s"
(Resto.string_of_meth meth)
(Re.Str.global_replace
(Re.Str.regexp "<\\([^>]*\\)>")
@@ -40,131 +42,148 @@ let ref_of_service (prefix, meth) =
(String.concat "--" prefix))
module Index = struct
-
let rec pp prefix ppf dir =
let open Resto.Description in
match dir with
- | Empty -> Format.fprintf ppf "Empty"
- | Static { services ; subdirs = None } ->
+ | Empty ->
+ Format.fprintf ppf "Empty"
+ | Static {services; subdirs = None} ->
pp_services prefix ppf services
- | Static { services ; subdirs = Some (Suffixes map) } ->
- Format.fprintf ppf "@[%a@ @ %a@]"
- (pp_services prefix) services
+ | Static {services; subdirs = Some (Suffixes map)} ->
+ Format.fprintf
+ ppf
+ "@[%a@ @ %a@]"
+ (pp_services prefix)
+ services
(Format.pp_print_list
~pp_sep:(fun ppf () -> Format.fprintf ppf "@ @ ")
(pp_suffixes prefix))
(Resto.StringMap.bindings map)
- | Static { services ; subdirs = Some (Arg (arg, dir)) } ->
+ | Static {services; subdirs = Some (Arg (arg, dir))} ->
let name = Format.asprintf "<%s>" arg.name in
- Format.fprintf ppf "@[%a@ @ %a@]"
- (pp_services prefix) services
- (pp_suffixes prefix) (name, dir)
+ Format.fprintf
+ ppf
+ "@[%a@ @ %a@]"
+ (pp_services prefix)
+ services
+ (pp_suffixes prefix)
+ (name, dir)
| Dynamic _ ->
Format.fprintf ppf "* %a ()" pp_name prefix
- and pp_suffixes prefix ppf (name, dir) =
- pp (prefix @ [name]) ppf dir
+ and pp_suffixes prefix ppf (name, dir) = pp (prefix @ [name]) ppf dir
and pp_services prefix ppf services =
- match (Resto.MethMap.bindings services) with
+ match Resto.MethMap.bindings services with
| [] ->
Format.fprintf ppf "* %a" pp_name prefix
| _ :: _ as services ->
- Format.fprintf ppf "* %a (@[%a@])"
- pp_name prefix
+ Format.fprintf
+ ppf
+ "* %a (@[%a@])"
+ pp_name
+ prefix
(Format.pp_print_list
~pp_sep:Format.pp_print_space
- (pp_service_method prefix)) services
+ (pp_service_method prefix))
+ services
and pp_service_method prefix ppf (meth, _service) =
- Format.fprintf ppf "`%s <%s_>`_"
+ Format.fprintf
+ ppf
+ "`%s <%s_>`_"
(Resto.string_of_meth meth)
(ref_of_service (prefix, meth))
-
end
module Description = struct
-
module Query = struct
-
let pp_arg fmt =
let open RPC_arg in
- function { name ; _ } ->
- Format.fprintf fmt "<%s>" name
+ function {name; _} -> Format.fprintf fmt "<%s>" name
let pp_title_item ppf =
let open RPC_description in
- function {name ; kind ; _ } ->
- match kind with
- | Single arg | Optional arg ->
- Format.fprintf ppf "[%s=%a]" name pp_arg arg
- | Flag ->
- Format.fprintf ppf "[%s]" name
- | Multi arg ->
- Format.fprintf ppf "(%s=%a)\\*" name pp_arg arg
+ function
+ | {name; kind; _} -> (
+ match kind with
+ | Single arg | Optional arg ->
+ Format.fprintf ppf "[%s=%a]" name pp_arg arg
+ | Flag ->
+ Format.fprintf ppf "[%s]" name
+ | Multi arg ->
+ Format.fprintf ppf "(%s=%a)\\*" name pp_arg arg )
let pp_title ppf query =
- Format.fprintf ppf "%s%a"
+ Format.fprintf
+ ppf
+ "%s%a"
(if query = [] then "" else "?")
(Format.pp_print_list
~pp_sep:(fun ppf () -> Format.fprintf ppf "&")
- pp_title_item) query
+ pp_title_item)
+ query
let pp_html_arg fmt =
let open RPC_arg in
- function { name ; _ } ->
- Format.fprintf fmt "<%s>" name
+ function {name; _} -> Format.fprintf fmt "<%s>" name
let pp_item ppf =
let open RPC_description in
- function { name ; description ; kind } ->
- begin match kind with
- | Single arg
- | Optional arg
- | Multi arg ->
- Format.fprintf ppf
+ function
+ | {name; description; kind} -> (
+ ( match kind with
+ | Single arg | Optional arg | Multi arg ->
+ Format.fprintf
+ ppf
"%s = %a"
- name pp_html_arg arg
- | Flag ->
- Format.fprintf ppf
- "%s"
name
- end ;
- begin match description with
- | None -> ()
- | Some descr -> Format.fprintf ppf " : %s" descr
- end
+ pp_html_arg
+ arg
+ | Flag ->
+ Format.fprintf ppf "%s" name ) ;
+ match description with
+ | None ->
+ ()
+ | Some descr ->
+ Format.fprintf ppf " : %s" descr )
let pp ppf query =
match query with
- | [] -> ()
+ | [] ->
+ ()
| _ :: _ as query ->
- Format.fprintf ppf
+ Format.fprintf
+ ppf
"
Optional query arguments :
"
(Format.pp_print_list
~pp_sep:(fun ppf () -> Format.fprintf ppf "")
pp_item)
query
-
end
module Tabs = struct
-
let pp_tab_div ppf f =
- Format.fprintf ppf
+ Format.fprintf
+ ppf
"@[%a
@]"
- (fun ppf () -> f ppf) ()
+ (fun ppf () -> f ppf)
+ ()
let pp_tabcontent_div ~id ~class_ ppf f =
- Format.fprintf ppf
- "@[@ \
- %a@ \
- @]
@ "
- id class_ (fun ppf () -> f ppf) ()
-
- let pp_button ppf ?(default=false) ~shortlabel ~content target_ref =
- Format.fprintf ppf
- "@ "
+ Format.fprintf
+ ppf
+ "@[@ %a@ @]
@ "
+ id
+ class_
+ (fun ppf () -> f ppf)
+ ()
+
+ let pp_button ppf ?(default = false) ~shortlabel ~content target_ref =
+ Format.fprintf
+ ppf
+ "@ "
(if default then " defaultOpen" else "")
(target_ref ^ shortlabel)
target_ref
@@ -172,94 +191,133 @@ module Description = struct
let pp_content ppf ~tag ~shortlabel target_ref pp_content content =
pp_tabcontent_div
- ~id:(target_ref ^ shortlabel) ~class_:target_ref ppf
- begin fun ppf ->
- Format.fprintf ppf "<%s>@ %a%s>" tag pp_content content tag
- end
+ ~id:(target_ref ^ shortlabel)
+ ~class_:target_ref
+ ppf
+ (fun ppf ->
+ Format.fprintf ppf "<%s>@ %a%s>" tag pp_content content tag)
let pp_description ppf (service : _ RPC_description.service) =
let open RPC_description in
(* TODO collect and display arg description (in path and in query) *)
- Format.fprintf ppf "@[%a@]%a"
- Format.pp_print_text (Option.unopt ~default:"" service.description)
- Query.pp service.query
+ Format.fprintf
+ ppf
+ "@[%a@]%a"
+ Format.pp_print_text
+ (Option.unopt ~default:"" service.description)
+ Query.pp
+ service.query
let pp ppf prefix service =
let open RPC_description in
let target_ref = ref_of_service (prefix, service.meth) in
- Rst.pp_html ppf begin fun ppf ->
- pp_tab_div ppf begin fun ppf ->
- pp_button ppf
- ~default:true ~shortlabel:"descr" ~content:"Description"
- target_ref ;
- Option.iter service.input ~f: begin fun _ ->
- pp_button ppf
- ~default:false ~shortlabel:"input.json" ~content:"Json input"
- target_ref ;
- pp_button ppf
- ~default:false ~shortlabel:"input.bin" ~content:"Binary input"
- target_ref
- end ;
- pp_button ppf
- ~default:false ~shortlabel:"output.json" ~content:"Json output"
- target_ref ;
- pp_button ppf
- ~default:false ~shortlabel:"output.bin" ~content:"Binary output"
- target_ref ;
- end ;
- pp_content ppf
- ~tag:"p" ~shortlabel:"descr" target_ref
- pp_description service ;
- Option.iter service.input ~f: begin fun (schema, bin_schema) ->
- pp_content ppf
- ~tag:"pre" ~shortlabel:"input.json" target_ref
- Json_schema.pp schema ;
- pp_content ppf
- ~tag:"pre" ~shortlabel:"input.bin" target_ref
- Data_encoding.Binary_schema.pp bin_schema ;
- end ;
- pp_content ppf
- ~tag:"pre" ~shortlabel:"output.json" target_ref
- Json_schema.pp (fst service.output) ;
- pp_content ppf
- ~tag:"pre" ~shortlabel:"output.bin" target_ref
- Data_encoding.Binary_schema.pp (snd service.output) ;
- end
-
+ Rst.pp_html ppf (fun ppf ->
+ pp_tab_div ppf (fun ppf ->
+ pp_button
+ ppf
+ ~default:true
+ ~shortlabel:"descr"
+ ~content:"Description"
+ target_ref ;
+ Option.iter service.input ~f:(fun _ ->
+ pp_button
+ ppf
+ ~default:false
+ ~shortlabel:"input.json"
+ ~content:"Json input"
+ target_ref ;
+ pp_button
+ ppf
+ ~default:false
+ ~shortlabel:"input.bin"
+ ~content:"Binary input"
+ target_ref) ;
+ pp_button
+ ppf
+ ~default:false
+ ~shortlabel:"output.json"
+ ~content:"Json output"
+ target_ref ;
+ pp_button
+ ppf
+ ~default:false
+ ~shortlabel:"output.bin"
+ ~content:"Binary output"
+ target_ref) ;
+ pp_content
+ ppf
+ ~tag:"p"
+ ~shortlabel:"descr"
+ target_ref
+ pp_description
+ service ;
+ Option.iter service.input ~f:(fun (schema, bin_schema) ->
+ pp_content
+ ppf
+ ~tag:"pre"
+ ~shortlabel:"input.json"
+ target_ref
+ Json_schema.pp
+ schema ;
+ pp_content
+ ppf
+ ~tag:"pre"
+ ~shortlabel:"input.bin"
+ target_ref
+ Data_encoding.Binary_schema.pp
+ bin_schema) ;
+ pp_content
+ ppf
+ ~tag:"pre"
+ ~shortlabel:"output.json"
+ target_ref
+ Json_schema.pp
+ (fst service.output) ;
+ pp_content
+ ppf
+ ~tag:"pre"
+ ~shortlabel:"output.bin"
+ target_ref
+ Data_encoding.Binary_schema.pp
+ (snd service.output))
end
let rec pp prefix ppf dir =
let open Resto.Description in
match dir with
- | Empty -> ()
- | Static { services ; subdirs = None } ->
+ | Empty ->
+ ()
+ | Static {services; subdirs = None} ->
pp_services prefix ppf services
- | Static { services ; subdirs = Some (Suffixes map) } ->
+ | Static {services; subdirs = Some (Suffixes map)} ->
pp_services prefix ppf services ;
- Format.pp_print_list (pp_suffixes prefix)
- ppf (Resto.StringMap.bindings map)
- | Static { services ; subdirs = Some (Arg (arg, dir)) } ->
+ Format.pp_print_list
+ (pp_suffixes prefix)
+ ppf
+ (Resto.StringMap.bindings map)
+ | Static {services; subdirs = Some (Arg (arg, dir))} ->
let name = Format.asprintf "<%s>" arg.name in
pp_services prefix ppf services ;
pp_suffixes prefix ppf (name, dir)
- | Dynamic _ -> ()
+ | Dynamic _ ->
+ ()
- and pp_suffixes prefix ppf (name, dir) =
- pp (prefix @ [name]) ppf dir
+ and pp_suffixes prefix ppf (name, dir) = pp (prefix @ [name]) ppf dir
and pp_services prefix ppf services =
- List.iter
- (pp_service prefix ppf)
- (Resto.MethMap.bindings services)
+ List.iter (pp_service prefix ppf) (Resto.MethMap.bindings services)
and pp_service prefix ppf (meth, service) =
Rst.pp_ref ppf (ref_of_service (prefix, meth)) ;
- Format.fprintf ppf "**%s %a%a**@\n@\n"
+ Format.fprintf
+ ppf
+ "**%s %a%a**@\n@\n"
(Resto.string_of_meth meth)
- pp_name prefix
- Query.pp_title service.query ;
+ pp_name
+ prefix
+ Query.pp_title
+ service.query ;
Tabs.pp ppf prefix service
-
end
let pp_document ppf descriptions =
@@ -274,8 +332,8 @@ let pp_document ppf descriptions =
Rst.pp_h2 ppf "RPCs - Index" ;
List.iter
(fun (name, prefix, rpc_dir) ->
- Rst.pp_h3 ppf name ;
- Format.fprintf ppf "%a@\n@\n" (Index.pp prefix) rpc_dir)
+ Rst.pp_h3 ppf name ;
+ Format.fprintf ppf "%a@\n@\n" (Index.pp prefix) rpc_dir)
descriptions ;
(* Full description *)
Rst.pp_h2 ppf "RPCs - Full description" ;
@@ -284,8 +342,8 @@ let pp_document ppf descriptions =
Format.pp_set_max_indent ppf 76 ;
List.iter
(fun (name, prefix, rpc_dir) ->
- Rst.pp_h3 ppf name ;
- Format.fprintf ppf "%a@\n@\n" (Description.pp prefix) rpc_dir)
+ Rst.pp_h3 ppf name ;
+ Format.fprintf ppf "%a@\n@\n" (Description.pp prefix) rpc_dir)
descriptions
let main node =
@@ -293,22 +351,25 @@ let main node =
let protocol_dirs =
List.map
(fun (name, hash) ->
- let hash = Protocol_hash.of_b58check_exn hash in
- let (module Proto) = Registered_protocol.get_exn hash in
- "Protocol " ^ name,
- [".." ; ""] ,
- RPC_directory.map (fun () -> assert false) @@
- Block_directory.build_raw_rpc_directory (module Proto) (module Proto))
- protocols in
+ let hash = Protocol_hash.of_b58check_exn hash in
+ let (module Proto) = Registered_protocol.get_exn hash in
+ ( "Protocol " ^ name,
+ [".."; ""],
+ RPC_directory.map (fun () -> assert false)
+ @@ Block_directory.build_raw_rpc_directory
+ (module Proto)
+ (module Proto) ))
+ protocols
+ in
let dirs = ("Shell", [""], shell_dir) :: protocol_dirs in
Lwt_list.map_p
(fun (name, path, dir) ->
- RPC_directory.describe_directory ~recurse:true ~arg:() dir >>= fun dir ->
- Lwt.return (name, path, dir))
- dirs >>= fun descriptions ->
+ RPC_directory.describe_directory ~recurse:true ~arg:() dir
+ >>= fun dir -> Lwt.return (name, path, dir))
+ dirs
+ >>= fun descriptions ->
let ppf = Format.std_formatter in
pp_document ppf descriptions ;
return ()
-let () =
- Lwt_main.run (Node_helpers.with_node main)
+let () = Lwt_main.run (Node_helpers.with_node main)
diff --git a/docs/doc_gen/rst.ml b/docs/doc_gen/rst.ml
index 232a5397ae077216fa86d082cb36d2b81643861f..045d2a8b157af3cd318d816bab9fcd4dcb04d0f5 100644
--- a/docs/doc_gen/rst.ml
+++ b/docs/doc_gen/rst.ml
@@ -28,24 +28,30 @@ let pp_title ~char ppf title =
Format.fprintf ppf "@[%s@ %s@ @ @]" title sub
let pp_h1 = pp_title ~char:'#'
+
let pp_h2 = pp_title ~char:'*'
+
let pp_h3 = pp_title ~char:'='
+
let pp_h4 = pp_title ~char:'`'
let pp_raw_html ppf str =
- Format.fprintf ppf "@[.. raw:: html@ @ %s@ @ @]"
+ Format.fprintf
+ ppf
+ "@[.. raw:: html@ @ %s@ @ @]"
(Re.Str.global_replace (Re.Str.regexp "\n") "\n " str)
let pp_html ppf f =
- Format.fprintf ppf
+ Format.fprintf
+ ppf
"@[.. raw:: html@ @ %a@]@\n@\n"
- (fun ppf () -> f ppf) ()
+ (fun ppf () -> f ppf)
+ ()
let pp_ref ppf name = Format.fprintf ppf ".. _%s :@\n@\n" name
-
-
-let style = {css|
+let style =
+ {css|
|css}
-let script = {script|
+let script =
+ {script|