Skip to content

Commit

Permalink
Update readme from code (#1188)
Browse files Browse the repository at this point in the history
### What
Update readme using make target and add a CI job to check its updated.

### Why
Noticed our readme is out of date with the code it is generated from.
  • Loading branch information
leighmcculloch authored Dec 18, 2023
1 parent 5667787 commit 107cd79
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

complete:
if: always()
needs: [fmt, check-git-rev-deps, build-and-test, docs]
needs: [fmt, check-git-rev-deps, build-and-test, docs, readme]
runs-on: ubuntu-latest
steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
Expand Down Expand Up @@ -132,6 +132,15 @@ jobs:
- run: rustup install nightly
- run: make doc

readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup install nightly
- run: make readme
- run: git add -N . && git diff HEAD --exit-code

publish-dry-run:
if: github.event_name == 'push' || startsWith(github.head_ref, 'release/')
strategy:
Expand Down
11 changes: 9 additions & 2 deletions soroban-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ See [soroban.stellar.org](https://soroban.stellar.org) for documentation.
### Examples

```rust
use soroban_sdk::{contractimpl, vec, BytesN, Env, Symbol, Vec};
use soroban_sdk::{contract, contractimpl, vec, symbol_short, BytesN, Env, Symbol, Vec};

#[contract]
pub struct HelloContract;

#[contractimpl]
Expand All @@ -21,6 +22,9 @@ impl HelloContract {

#[test]
fn test() {
# }
# #[cfg(feature = "testutils")]
# fn main() {
let env = Env::default();
let contract_id = env.register_contract(None, HelloContract);
let client = HelloContractClient::new(&env, &contract_id);
Expand All @@ -29,6 +33,9 @@ fn test() {

assert_eq!(words, vec![&env, symbol_short!("Hello"), symbol_short!("Dev"),]);
}
# #[cfg(not(feature = "testutils"))]
# fn main() { }
```

More examples are available at <https://soroban.stellar.org/docs/category/how-to-guides>.
More examples are available at <https://soroban.stellar.org/docs/category/basic-tutorials>
and <https://soroban.stellar.org/docs/category/advanced-tutorials>.

0 comments on commit 107cd79

Please sign in to comment.