From 2f271bd3c051dd3626916b4ed6b573dfa94c450d Mon Sep 17 00:00:00 2001
From: vbot
Date: Fri, 1 Jul 2022 17:14:19 +0200
Subject: [PATCH 1/3] Docs: add notes in rpc doc headers
---
docs/include/rpc_introduction.rst.inc | 10 +++++++++-
docs/shell/rpc_introduction.rst.inc | 12 ++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/docs/include/rpc_introduction.rst.inc b/docs/include/rpc_introduction.rst.inc
index 39a5b023dd20..0e566a2fb4d8 100644
--- a/docs/include/rpc_introduction.rst.inc
+++ b/docs/include/rpc_introduction.rst.inc
@@ -7,7 +7,10 @@ This page describes the RPCs specific to a particular version of the Tezos proto
.. warning::
- Some dynamic or plugin RPCs are not listed here due to a current limitation in the documentation generator. They are listed in the :doc:`../api/openapi` (search the ``.json`` files that are linked from that page).
+ This list could be missing RPC endpoints. The :doc:`OpenAPI
+ specification <../api/openapi>` may be used to retrieve the
+ complete list of protocol RPCs and their associated schemas
+ (search the ``.json`` files that are linked from that page).
RPCs - Index
************
@@ -16,6 +19,11 @@ Note that the RPCs served under a given prefix can also be listed using the clie
tezos-client rpc list /chains/main/blocks/head/context/constants
+Any RPC endpoint may also be described, using the ``describe`` RPC to
+retrieve all JSON and binary schemas, e.g.::
+
+ tezos-client rpc get /describe/chains/main/blocks/head/context/constants
+
Shell
=====
diff --git a/docs/shell/rpc_introduction.rst.inc b/docs/shell/rpc_introduction.rst.inc
index 028da9384517..acb6d7d76bf0 100644
--- a/docs/shell/rpc_introduction.rst.inc
+++ b/docs/shell/rpc_introduction.rst.inc
@@ -1,5 +1,12 @@
This page describes the RPCs built into the Octez shell, which are independent from a particular version of the Tezos protocol.
+.. warning::
+
+ This list could be missing RPC endpoints. The :doc:`OpenAPI
+ specification <../api/openapi>` can be used to retrieve the
+ complete list of protocol RPCs and their associated schemas
+ (search the ``.json`` files that are linked from that page).
+
RPCs - Index
************
@@ -7,6 +14,11 @@ Note that the RPCs served under a given prefix can also be listed using the clie
tezos-client rpc list /chains/main/levels
+Any RPC endpoint may also be described, using the ``describe`` RPC to
+retrieve all JSON and binary schemas, e.g.::
+
+ tezos-client rpc get /describe/chains/main/chain_id
+
Protocol
========
--
GitLab
From d57bc8d55797788e1fa7c21009f6fdec90d9f297 Mon Sep 17 00:00:00 2001
From: vbot
Date: Fri, 1 Jul 2022 17:14:44 +0200
Subject: [PATCH 2/3] Docs: fix typo in Makefile
---
docs/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/Makefile b/docs/Makefile
index 54841d6719eb..a108cbea7dd1 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -31,7 +31,7 @@ CHECKXREFS = $(SCRIPTSDIR)/check_proto_xrefs.py
# Build all documentation (with CLI manuals and odoc) but without old PROTOCOLS
all: odoc-lite
- # Html needs the API pages for Ocaml modules, generated by odoc, because of
+ # Html needs the API pages for OCaml modules, generated by odoc, because of
# the :package: custom roles in RST files; so run html *after* odoc
${MAKE} html
--
GitLab
From 5f743d6f935ec9346db835bdba927cd94f40258d Mon Sep 17 00:00:00 2001
From: vbot
Date: Fri, 1 Jul 2022 18:24:28 +0200
Subject: [PATCH 3/3] Docs: refactor RPCs doc and remove costly schemas
computation
---
docs/doc_gen/p2p_doc.ml | 2 -
docs/doc_gen/rpc_doc.ml | 287 +++++++++++++++-------------------------
docs/doc_gen/rst.ml | 106 +++++++--------
3 files changed, 155 insertions(+), 240 deletions(-)
diff --git a/docs/doc_gen/p2p_doc.ml b/docs/doc_gen/p2p_doc.ml
index dbe39a52365f..8229a263beaa 100644
--- a/docs/doc_gen/p2p_doc.ml
+++ b/docs/doc_gen/p2p_doc.ml
@@ -29,8 +29,6 @@ let protocols =
let main () =
(* Style : hack *)
Format.printf "%a@." Rst.pp_raw_html Rst.style ;
- (* Script : hack *)
- Format.printf "%a@." Rst.pp_raw_html Rst.script ;
(* Page title *)
Format.printf "%a" Rst.pp_h1 "P2P message format" ;
(* include/copy usage.rst from input *)
diff --git a/docs/doc_gen/rpc_doc.ml b/docs/doc_gen/rpc_doc.ml
index 5f0ac078a76d..fec3076302a1 100644
--- a/docs/doc_gen/rpc_doc.ml
+++ b/docs/doc_gen/rpc_doc.ml
@@ -2,6 +2,7 @@
(* *)
(* Open Source License *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *)
+(* Copyright (c) 2018-2022 Nomadic Labs, *)
(* *)
(* Permission is hereby granted, free of charge, to any person obtaining a *)
(* copy of this software and associated documentation files (the "Software"),*)
@@ -75,35 +76,25 @@ module Index = struct
| 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
- (Format.pp_print_list
- ~pp_sep:(fun ppf () -> Format.fprintf ppf "@ @ ")
- (pp_suffixes prefix))
- (Resto.StringMap.bindings map)
+ pp_services prefix ppf services ;
+ pp_suffixes prefix ppf (Resto.StringMap.bindings map)
| Static {services; subdirs = Some (Arg (arg, dir))} ->
+ pp_services prefix ppf services ;
let name = Format.asprintf "<%s>" arg.name in
- Format.fprintf
- ppf
- "@[%a@ @ %a@]"
- (pp_services prefix)
- services
- (pp_suffixes prefix)
- (name, dir)
- | Dynamic _ -> Format.fprintf ppf "* %a ()" pp_name prefix
+ pp_suffixes prefix ppf [(name, dir)]
+ | Dynamic _ ->
+ Format.fprintf ppf "@[* %a ()@]@\n" pp_name prefix
- and pp_suffixes prefix ppf (name, dir) = pp (prefix @ [name]) ppf dir
+ and pp_suffixes prefix ppf l =
+ List.iter (fun (name, dir) -> pp (prefix @ [name]) ppf dir) l
- and pp_services prefix ppf services =
- match Resto.MethMap.bindings services with
- | [] -> Format.fprintf ppf "* %a" pp_name prefix
- | _ :: _ as services ->
+ and pp_services prefix ppf service =
+ match Resto.MethMap.bindings service with
+ | [] -> ()
+ | services ->
Format.fprintf
ppf
- "* %a (@[%a@])"
+ "@[* %a (%a)@]@\n"
pp_name
prefix
(Format.pp_print_list
@@ -120,6 +111,10 @@ module Index = struct
end
module Description = struct
+ let pp_h ppf n content = Format.fprintf ppf "%s" n content n
+
+ let pp_p ppf content = Format.fprintf ppf "
%s
" content
+
module Query = struct
let pp_arg fmt =
let open RPC_arg in
@@ -133,7 +128,7 @@ module Description = struct
| 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)
+ | Multi arg -> Format.fprintf ppf "(%s=%a)*" name pp_arg arg)
let pp_title ppf query =
Format.fprintf
@@ -170,9 +165,10 @@ module Description = struct
match query with
| [] -> ()
| _ :: _ as query ->
+ pp_h ppf 6 "Optional query arguments:" ;
Format.fprintf
ppf
- "