Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
macalinao committed Jul 24, 2022
1 parent 89b8019 commit a49a4d7
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[workspace]
members = ["anchor-gen", "crates/*", "examples/*"]
members = ["crates/*", "examples/*"]
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# anchor-gen

Generates an Anchor CPI crate from a JSON IDL.
Generates a crate for cross-program invocations to an Anchor program from a JSON IDL.

## Usage

In a new crate, write:

```rust
anchor_gen::generate_cpi_crate!("src/idl.json");
anchor_gen::generate_cpi_crate!("../../examples/govern-cpi/idl.json");

declare_id!("GjphYQcbP1m3FuDyCTUJf2mUMxKPE3j6feWU1rxvC7Ps");
```

This will generate a fully functional Rust CPI client for your IDL.

## License
More examples can be found in the [examples/](https://github.com/saber-hq/anchor-gen/tree/master/examples) directory.

Apache 2.0
License: Apache-2.0
6 changes: 4 additions & 2 deletions anchor-gen/Cargo.toml → crates/anchor-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ authors = ["Ian Macalinao <[email protected]>"]
repository = "https://github.com/saber-hq/anchor-gen"
license = "Apache-2.0"
keywords = ["solana", "anchor"]
readme = "../README.md"
readme = "../../README.md"

[lib]
name = "anchor_gen"
path = "src/lib.rs"
proc-macro = true

[dependencies]
anchor-idl = { version = "0.2.0", path = "../crates/anchor-idl" }
anchor-idl = { version = "0.2.0", path = "../anchor-idl" }
serde_json = "1.0.81"
anchor-syn = { version = "0.24.2", features = ["idl"] }
syn = { version = "1", features = ["full"] }
Expand Down
18 changes: 16 additions & 2 deletions anchor-gen/src/lib.rs → crates/anchor-gen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
//! Generates an Anchor crate interface from a JSON IDL.
//! Generates a crate for cross-program invocations to an Anchor program from a JSON IDL.
//!
//! # Usage
//!
//! In a new crate, write:
//!
//! ```skip
//! anchor_gen::generate_cpi_crate!("../../examples/govern-cpi/idl.json");
//!
//! declare_id!("GjphYQcbP1m3FuDyCTUJf2mUMxKPE3j6feWU1rxvC7Ps");
//! ```
//!
//! This will generate a fully functional Rust CPI client for your IDL.
//!
//! More examples can be found in the [examples/](https://github.com/saber-hq/anchor-gen/tree/master/examples) directory.
use std::{env, fs, path::PathBuf};
use syn::{parse_macro_input, LitStr};
Expand All @@ -12,7 +26,7 @@ use syn::{parse_macro_input, LitStr};
/// # Examples
///
/// ```
/// anchor_gen::generate_cpi_crate!("../examples/govern-cpi/idl.json");
/// anchor_gen::generate_cpi_crate!("../../examples/govern-cpi/idl.json");
/// declare_id!("GjphYQcbP1m3FuDyCTUJf2mUMxKPE3j6feWU1rxvC7Ps");
/// # fn main() -> Result<()> {
/// let _my_governor = GovernanceParameters {
Expand Down
2 changes: 1 addition & 1 deletion examples/govern-cpi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ no-log-ix-name = []
cpi = ["no-entrypoint"]

[dependencies]
anchor-gen = { version = "0.2.0", path = "../../anchor-gen" }
anchor-gen = { version = "0.2.0", path = "../../crates/anchor-gen" }
anchor-lang = ">=0.20"
2 changes: 1 addition & 1 deletion examples/marinade-cpi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ no-log-ix-name = []
cpi = ["no-entrypoint"]

[dependencies]
anchor-gen = { version = "0.2.0", path = "../../anchor-gen" }
anchor-gen = { version = "0.2.0", path = "../../crates/anchor-gen" }
anchor-lang = ">=0.20"

0 comments on commit a49a4d7

Please sign in to comment.