Skip to content

Commit

Permalink
move examples to main repo so we can include_str them for publishing (#…
Browse files Browse the repository at this point in the history
…993)

* move exampels to main repo so we can include_str them for publishing

* update CI to not break examples
  • Loading branch information
jsdw authored Jun 1, 2023
1 parent 15a267c commit e40a862
Show file tree
Hide file tree
Showing 31 changed files with 31 additions and 55 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,16 @@ jobs:
crate: cargo-hack
version: 0.5

- name: Cargo check
run: cargo hack --exclude-all-features --each-feature check --all-targets --workspace
# A basic check over all targets together. This may lead to features being combined etc,
# and doesn't test combinations of different features.
- name: Cargo check all targets.
run: cargo check --all-targets

# Next, check each feature on its own and compile each crate separately. This is no good
# for subxt/examples, which expect default features to be enabled, hence the above check
# and why we don'#t do `--all-targets` for this one.
- name: Cargo hack; check each feature/crate on its own
run: cargo hack --exclude-all-features --each-feature check --workspace

fmt:
name: Cargo fmt
Expand Down
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
members = [
"cli",
"codegen",
"examples",
"testing/substrate-runner",
"testing/test-runtime",
"testing/integration-tests",
Expand Down
20 changes: 0 additions & 20 deletions examples/Cargo.toml

This file was deleted.

4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Subxt Examples

Take a look in the [examples](./examples) subfolder for various `subxt` usage examples.
Each folder here contains a complete example which makes use of subxt in some way.

All examples form part of the `subxt` documentation; there should be no examples without corresponding links from the docs.
For smaller single-file examples, see the `./subxt/examples` folder.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion subxt/src/book/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
//! accounts, Alice to Bob:
//!
//! ```rust,ignore
#![doc = include_str!("../../../examples/examples/tx_basic.rs")]
#![doc = include_str!("../../examples/tx_basic.rs")]
//! ```
//!
//! This example assumes that a Polkadot node is running locally (Subxt endeavors to support all
Expand Down
6 changes: 3 additions & 3 deletions subxt/src/book/setup/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@
//! Defining some custom config based off the default Substrate config:
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/setup_client_custom_config.rs")]
#![doc = include_str!("../../../examples/setup_client_custom_config.rs")]
//! ```
//!
//! Writing a custom [`crate::rpc::RpcClientT`] implementation:
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/setup_client_custom_rpc.rs")]
#![doc = include_str!("../../../examples/setup_client_custom_rpc.rs")]
//! ```
//!
//! Creating an [`crate::OfflineClient`]:
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/setup_client_offline.rs")]
#![doc = include_str!("../../../examples/setup_client_offline.rs")]
//! ```
//!
2 changes: 1 addition & 1 deletion subxt/src/book/usage/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
//! can decode the extrinsics and access various details, including the associated events:
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/blocks_subscribing.rs")]
#![doc = include_str!("../../../examples/blocks_subscribing.rs")]
//! ```
//!
4 changes: 2 additions & 2 deletions subxt/src/book/usage/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
//! Here's an example using a static query:
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/constants_static.rs")]
#![doc = include_str!("../../../examples/constants_static.rs")]
//! ```
//!
//! And here's one using a dynamic query:
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/constants_dynamic.rs")]
#![doc = include_str!("../../../examples/constants_dynamic.rs")]
//! ```
//!
2 changes: 1 addition & 1 deletion subxt/src/book/usage/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
//! Here's an example which puts this all together:
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/events.rs")]
#![doc = include_str!("../../../examples/events.rs")]
//! ```
//!
6 changes: 3 additions & 3 deletions subxt/src/book/usage/runtime_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
//! The easiest way to make a runtime API call is to use the statically generated interface.
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/runtime_apis_static.rs")]
#![doc = include_str!("../../../examples/runtime_apis_static.rs")]
//! ```
//!
//! ### Making a dynamic Runtime API call
Expand All @@ -67,7 +67,7 @@
//! [`crate::dynamic::runtime_api_call`] method.
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/runtime_apis_dynamic.rs")]
#![doc = include_str!("../../../examples/runtime_apis_dynamic.rs")]
//! ```
//!
//! ### Making a raw call
Expand All @@ -77,6 +77,6 @@
//! the argument bytes and manually provide a type for the response bytes to be decoded into.
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/runtime_apis_raw.rs")]
#![doc = include_str!("../../../examples/runtime_apis_raw.rs")]
//! ```
//!
8 changes: 4 additions & 4 deletions subxt/src/book/usage/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@
//! latter will only work for storage queries that have a default value when empty):
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/storage_fetch.rs")]
#![doc = include_str!("../../../examples/storage_fetch.rs")]
//! ```
//!
//! For completeness, below is an example using a dynamic query instead. The return type from a
//! dynamic query is a [`crate::dynamic::DecodedValueThunk`], which can be decoded into a
//! [`crate::dynamic::Value`], or else the raw bytes can be accessed instead.
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/storage_fetch_dynamic.rs")]
#![doc = include_str!("../../../examples/storage_fetch_dynamic.rs")]
//! ```
//!
//! ### Iterating storage entries
Expand All @@ -92,13 +92,13 @@
//! iterate over all of the values stored at that location:
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/storage_iterating.rs")]
#![doc = include_str!("../../../examples/storage_iterating.rs")]
//! ```
//!
//! Here's the same logic but using dynamically constructed values instead:
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/storage_iterating_dynamic.rs")]
#![doc = include_str!("../../../examples/storage_iterating_dynamic.rs")]
//! ```
//!
//! ### Advanced
Expand Down
6 changes: 3 additions & 3 deletions subxt/src/book/usage/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
//! inspection. This looks like:
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/tx_basic.rs")]
#![doc = include_str!("../../../examples/tx_basic.rs")]
//! ```
//!
//! ### Providing transaction parameters
Expand All @@ -156,7 +156,7 @@
//! [`crate::tx::TxClient::sign_and_submit_then_watch`] instead:
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/tx_with_params.rs")]
#![doc = include_str!("../../../examples/tx_with_params.rs")]
//! ```
//!
//! This example doesn't wait for the transaction to be included in a block; it just submits it and
Expand All @@ -168,7 +168,7 @@
//! the transaction, you can monitor them as they are emitted and react however you choose:
//!
//! ```rust,ignore
#![doc = include_str!("../../../../examples/examples/tx_status_stream.rs")]
#![doc = include_str!("../../../examples/tx_status_stream.rs")]
//! ```
//!
//! Take a look at the API docs for [`crate::tx::TxProgress`], [`crate::tx::TxStatus`] and
Expand Down
2 changes: 1 addition & 1 deletion subxt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! Subxt is a library for interacting with Substrate based nodes. Using it looks something like this:
//!
//! ```rust,ignore
#![doc = include_str!("../../examples/examples/tx_basic.rs")]
#![doc = include_str!("../examples/tx_basic.rs")]
//! ```
//!
//! Take a look at [the Subxt guide](book) to learn more about how to use Subxt.
Expand Down

0 comments on commit e40a862

Please sign in to comment.