Proposed documentation format for RPC methods. #3638
Replies: 5 comments 8 replies
-
I think that proposal is good. There are a few things that I'd suggest:
|
Beta Was this translation helpful? Give feedback.
-
I think all this suggestions are good and we should do them but i don't understand number 5. Do you think you can create a comment with the entire doc of |
Beta Was this translation helpful? Give feedback.
-
Should we have a spot for parameters in the documentation ? |
Beta Was this translation helpful? Give feedback.
-
This is in contradiction to what @jvff suggest and was accepted before, the suggestion was: "I think the Result section is unnecessary, it could link directly to the returned type. The user can then click on the return type link to see the fields." Also, for the parameters how do you want to be documented exactly (I will not like to work on this until a full example with everything is displayed in this discussion ) |
Beta Was this translation helpful? Give feedback.
-
Here is a draft of the documentation format, with all of the changes we discussed. Do we need to make any significant changes to this format? Feel free to post draft PRs with this format any time, so we can see if it works. Read method (no parameters): pub trait Rpc {
/// Returns software information from the RPC server, as a [`GetInfo`] JSON struct.
///
/// zcashd reference: [`getinfo`](https://zcash.github.io/rpc/getinfo.html)
///
/// # Notes
///
/// [The zcashd reference](https://zcash.github.io/rpc/getinfo.html) might not show some fields
/// in Zebra's [`GetInfo`]. Zebra uses the field names and formats from the
/// [zcashd code](https://github.com/zcash/zcash/blob/v4.6.0-1/src/rpc/misc.cpp#L86-L87).
///
/// Some fields from the zcashd reference are missing from Zebra's [`GetInfo`]. It only contains the fields
/// [required for lightwalletd support.](https://github.com/zcash/lightwalletd/blob/v0.4.9/common/common.go#L91-L95)
#[rpc(name = "getinfo")]
fn get_info(&self) -> Result<GetInfo>;
}
/// Response to a `getinfo` RPC request.
///
/// See the notes for the [`Rpc::get_info` method].
pub struct GetInfo {
/// Full application version.
build: String,
/// Zebra network user agent.
subversion: String,
} Write method with parameters: pub trait Rpc {
/// Sends the raw bytes of a signed transaction to the local node's mempool, if the transaction is valid.
/// Returns the [`SentTransactionHash`] for the transaction, as a JSON string.
///
/// zcashd reference: [`sendrawtransaction`](https://zcash.github.io/rpc/sendrawtransaction.html)
///
/// # Parameters
///
/// - `raw_transaction_hex`: (string, required) The hex-encoded raw transaction bytes.
///
/// # Notes
///
/// zcashd accepts an optional `allowhighfees` parameter. Zebra doesn't support this parameter,
/// because lightwalletd doesn't use it.
#[rpc(name = "sendrawtransaction")]
fn send_raw_transaction(
&self,
raw_transaction_hex: String,
) -> BoxFuture<Result<SentTransactionHash>>;
}
/// Response to a `sendrawtransaction` RPC request.
///
/// Contains the hex-encoded hash of the sent transaction.
///
/// Also see the notes for the [`Rpc::send_raw_transaction` method].
pub struct SentTransactionHash(String); |
Beta Was this translation helpful? Give feedback.
-
As we start adding RPC methods to zebra we should agree in a documentation format for each of them, similar to what zcashd does for their methods, for example:
https://github.com/zcash/zcash/blob/v4.6.0-1/src/rpc/misc.cpp#L49-L73 ends up being deployed as https://zcash.github.io/rpc/getinfo.html
I am proposing the following format for Zebra to kick off the discussion:
For exmple, in the context of #3142 i made the following doc for
getinfo
:Beta Was this translation helpful? Give feedback.
All reactions