Skip to content

Commit

Permalink
Add nightly build cfg for docs
Browse files Browse the repository at this point in the history
  • Loading branch information
howardwu committed Jul 26, 2020
1 parent a75fbc5 commit f9005f7
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 22 deletions.
12 changes: 12 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Detect the rustc channel
use rustc_version::{version_meta, Channel};

fn main() {
// Set cfg flags depending on release channel
match version_meta().unwrap().channel {
Channel::Stable => println!("cargo:rustc-cfg=stable"),
Channel::Beta => println!("cargo:rustc-cfg=beta"),
Channel::Nightly => println!("cargo:rustc-cfg=nightly"),
Channel::Dev => println!("cargo:rustc-cfg=rustc_dev"),
}
}
2 changes: 1 addition & 1 deletion rpc/documentation/general/overview.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

In Aleo, every full node includes a [JSON-RPC](https://www.jsonrpc.org/specification) server
In Aleo, full nodes run a [JSON-RPC](https://www.jsonrpc.org/specification) server
to enable API calls for fetching data and interacting with peers connected to the network.

## RPC Port
Expand Down
6 changes: 3 additions & 3 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#![warn(unused_extern_crates)]
#![forbid(unsafe_code)]
// Documentation
#![deny(missing_docs)]
#![feature(external_doc)]
#![doc(include = "../documentation/overview.md")]
#![cfg_attr(nightly, feature(doc_cfg, external_doc))]
#![cfg_attr(nightly, deny(missing_docs))]
#![cfg_attr(nightly, doc(include = "../documentation/general/overview.md"))]

pub mod rpc_impl;
#[doc(inline)]
Expand Down
1 change: 0 additions & 1 deletion rpc/src/rpc_impl_protected.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Implementation of private RPC endpoints that require authentication.
// #![doc(include = "../docs/private_endpoints/*.md")]
use crate::{rpc_trait::ProtectedRpcFunctions, rpc_types::*, RpcImpl};
use snarkos_dpc::base_dpc::{
Expand Down
40 changes: 23 additions & 17 deletions rpc/src/rpc_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,77 +8,83 @@ use jsonrpc_derive::rpc;
/// Definition of public RPC endpoints.
#[rpc]
pub trait RpcFunctions {
#[doc(include = "../documentation/public_endpoints/getblock.md")]
#[cfg_attr(nightly, doc(include = "../documentation/public_endpoints/getblock.md"))]
#[rpc(name = "getblock")]
fn get_block(&self, block_hash_string: String) -> Result<BlockInfo, RpcError>;

#[doc(include = "../documentation/public_endpoints/getblockcount.md")]
#[cfg_attr(nightly, doc(include = "../documentation/public_endpoints/getblockcount.md"))]
#[rpc(name = "getblockcount")]
fn get_block_count(&self) -> Result<u32, RpcError>;

#[doc(include = "../documentation/public_endpoints/getbestblockhash.md")]
#[cfg_attr(nightly, doc(include = "../documentation/public_endpoints/getbestblockhash.md"))]
#[rpc(name = "getbestblockhash")]
fn get_best_block_hash(&self) -> Result<String, RpcError>;

#[doc(include = "../documentation/public_endpoints/getblockhash.md")]
#[cfg_attr(nightly, doc(include = "../documentation/public_endpoints/getblockhash.md"))]
#[rpc(name = "getblockhash")]
fn get_block_hash(&self, block_height: u32) -> Result<String, RpcError>;

#[doc(include = "../documentation/public_endpoints/getrawtransaction.md")]
#[cfg_attr(nightly, doc(include = "../documentation/public_endpoints/getrawtransaction.md"))]
#[rpc(name = "getrawtransaction")]
fn get_raw_transaction(&self, transaction_id: String) -> Result<String, RpcError>;

#[doc(include = "../documentation/public_endpoints/gettransactioninfo.md")]
#[cfg_attr(nightly, doc(include = "../documentation/public_endpoints/gettransactioninfo.md"))]
#[rpc(name = "gettransactioninfo")]
fn get_transaction_info(&self, transaction_id: String) -> Result<TransactionInfo, RpcError>;

#[doc(include = "../documentation/public_endpoints/decoderawtransaction.md")]
#[cfg_attr(nightly, doc(include = "../documentation/public_endpoints/decoderawtransaction.md"))]
#[rpc(name = "decoderawtransaction")]
fn decode_raw_transaction(&self, transaction_bytes: String) -> Result<TransactionInfo, RpcError>;

#[doc(include = "../documentation/public_endpoints/sendtransaction.md")]
#[cfg_attr(nightly, doc(include = "../documentation/public_endpoints/sendtransaction.md"))]
#[rpc(name = "sendtransaction")]
fn send_raw_transaction(&self, transaction_bytes: String) -> Result<String, RpcError>;

#[doc(include = "../documentation/public_endpoints/validaterawtransaction.md")]
#[cfg_attr(
nightly,
doc(include = "../documentation/public_endpoints/validaterawtransaction.md")
)]
#[rpc(name = "validaterawtransaction")]
fn validate_raw_transaction(&self, transaction_bytes: String) -> Result<bool, RpcError>;

#[doc(include = "../documentation/public_endpoints/getconnectioncount.md")]
#[cfg_attr(nightly, doc(include = "../documentation/public_endpoints/getconnectioncount.md"))]
#[rpc(name = "getconnectioncount")]
fn get_connection_count(&self) -> Result<usize, RpcError>;

#[doc(include = "../documentation/public_endpoints/getpeerinfo.md")]
#[cfg_attr(nightly, doc(include = "../documentation/public_endpoints/getpeerinfo.md"))]
#[rpc(name = "getpeerinfo")]
fn get_peer_info(&self) -> Result<PeerInfo, RpcError>;

#[doc(include = "../documentation/public_endpoints/getblocktemplate.md")]
#[cfg_attr(nightly, doc(include = "../documentation/public_endpoints/getblocktemplate.md"))]
#[rpc(name = "getblocktemplate")]
fn get_block_template(&self) -> Result<BlockTemplate, RpcError>;

#[doc(include = "../documentation/public_endpoints/decoderecord.md")]
#[cfg_attr(nightly, doc(include = "../documentation/public_endpoints/decoderecord.md"))]
#[rpc(name = "decoderecord")]
fn decode_record(&self, record_bytes: String) -> Result<RecordInfo, RpcError>;
}

/// Definition of private RPC endpoints that require authentication.
pub trait ProtectedRpcFunctions {
/// Generate a new account private key and account address.
#[doc(include = "../documentation/private_endpoints/createaccount.md")]
#[cfg_attr(nightly, doc(include = "../documentation/private_endpoints/createaccount.md"))]
fn create_account(&self) -> Result<RpcAccount, RpcError>;

/// Create a transaction and return encoded transaction and output records.
#[doc(include = "../documentation/private_endpoints/createrawtransaction.md")]
#[cfg_attr(nightly, doc(include = "../documentation/private_endpoints/createrawtransaction.md"))]
fn create_raw_transaction(
&self,
transaction_input: TransactionInputs,
) -> Result<CreateRawTransactionOuput, RpcError>;

/// Fetches record commitments that are stored on the node.
#[doc(include = "../documentation/private_endpoints/fetchrecordcommitments.md")]
#[cfg_attr(
nightly,
doc(include = "../documentation/private_endpoints/fetchrecordcommitments.md")
)]
fn fetch_record_commitments(&self) -> Result<Vec<String>, RpcError>;

/// Returns hex encoded bytes of a record from its record commitment.
#[doc(include = "../documentation/private_endpoints/getrawrecord.md")]
#[cfg_attr(nightly, doc(include = "../documentation/private_endpoints/getrawrecord.md"))]
fn get_raw_record(&self, record_commitment: String) -> Result<String, RpcError>;
}

0 comments on commit f9005f7

Please sign in to comment.