Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.

Commit d1c2fa7

Browse files
authored
Fix highlighting in Sylvia examples (#210)
2 parents 5f8664e + ebef5ae commit d1c2fa7

File tree

15 files changed

+150
-65
lines changed

15 files changed

+150
-65
lines changed

docs-test-gen/templates/sylvia/cw_storage_contract.tpl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#![allow(unexpected_cfgs, dead_code, unused_variables, unused_imports, clippy::new_without_default)]
22

3-
use sylvia::cw_std::{Addr, Binary, Coin, entry_point, Reply, SubMsg, WasmMsg, to_json_binary, DepsMut, Empty, Env, IbcChannelOpenMsg, IbcChannelOpenResponse, Response, StdError, StdResult, SubMsgResult};
3+
use sylvia::cw_std::{Addr, Binary, Coin, entry_point, MessageInfo, Reply, SubMsg, WasmMsg, to_json_binary, DepsMut, Empty, Env, IbcChannelOpenMsg, IbcChannelOpenResponse, Response, StdError, StdResult, SubMsgResult};
44
use sylvia::{contract, entry_points, interface};
5-
use sylvia::types::Remote;
5+
use sylvia::types::{Remote, CustomMsg, CustomQuery};
66
use sylvia::ctx::{InstantiateCtx, QueryCtx, ExecCtx, ReplyCtx, SudoCtx, MigrateCtx};
77
use sylvia::cw_schema::cw_serde;
88
use cw_utils::MsgInstantiateContractResponse;
99
use cw_storage_plus::Item;
10+
use std::marker::PhantomData;
1011

1112
pub mod external_contract {
1213
use super::*;
@@ -38,6 +39,11 @@ pub enum ExternalQueryMsg {
3839
#[cw_serde]
3940
pub struct ExternalResponse {}
4041

42+
#[cw_serde]
43+
pub struct SomeResponse;
44+
45+
pub type SomeResult = StdResult<SomeResponse>;
46+
4147
#[test]
4248
fn doctest() {
4349
pub mod contract_code {

docs-test-gen/templates/sylvia/empty.tpl

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
#![allow(unexpected_cfgs, dead_code, unused_variables, unused_imports, clippy::new_without_default)]
22

3-
use sylvia::cw_std::{Addr, Binary, Coin, entry_point, Reply, SubMsg, WasmMsg, to_json_binary, DepsMut, Empty, Env, IbcChannelOpenMsg, IbcChannelOpenResponse, Response, StdError, StdResult, SubMsgResult};
3+
use sylvia::cw_std::{Addr, Binary, Coin, entry_point, MessageInfo, Reply, SubMsg, WasmMsg, to_json_binary, DepsMut, Empty, Env, IbcChannelOpenMsg, IbcChannelOpenResponse, Response, StdError, StdResult, SubMsgResult};
44
use sylvia::{contract, entry_points, interface};
5-
use sylvia::types::Remote;
5+
use sylvia::types::{Remote, CustomMsg, CustomQuery};
66
use sylvia::ctx::{InstantiateCtx, QueryCtx, ExecCtx, ReplyCtx, SudoCtx, MigrateCtx};
77
use sylvia::cw_schema::cw_serde;
88
use cw_utils::MsgInstantiateContractResponse;
99
use cw_storey::CwStorage;
1010
use external_contract::ExternalContract;
11+
use std::marker::PhantomData;
12+
use external_interface::SomeInterface;
13+
use serde::{Deserialize, Serialize};
14+
use serde::de::DeserializeOwned;
1115

1216
pub mod external_contract {
1317
use sylvia::contract;
@@ -44,6 +48,20 @@ pub enum ExternalQueryMsg {
4448
Count {}
4549
}
4650

51+
#[cw_serde]
52+
pub struct ExampleMsg {}
53+
54+
#[cw_serde]
55+
pub struct ExampleQuery {}
56+
57+
impl sylvia::cw_std::CustomMsg for ExampleMsg {}
58+
59+
impl sylvia::cw_std::CustomQuery for ExampleQuery {}
60+
61+
#[cw_serde]
62+
pub struct SomeResponse;
63+
64+
4765
#[cw_serde]
4866
pub struct ExternalResponse {}
4967

docs-test-gen/templates/sylvia/storey_contract.tpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#![allow(unexpected_cfgs, dead_code, unused_variables, unused_imports, clippy::new_without_default)]
22

3-
use sylvia::cw_std::{Addr, Binary, Coin, entry_point, Reply, SubMsg, WasmMsg, to_json_binary, DepsMut, Empty, Env, IbcChannelOpenMsg, IbcChannelOpenResponse, Response, StdError, StdResult, SubMsgResult};
3+
use sylvia::cw_std::{Addr, Binary, Coin, entry_point, MessageInfo, Reply, SubMsg, WasmMsg, to_json_binary, DepsMut, Empty, Env, IbcChannelOpenMsg, IbcChannelOpenResponse, Response, StdError, StdResult, SubMsgResult};
44
use sylvia::{contract, entry_points, interface};
5-
use sylvia::types::Remote;
5+
use sylvia::types::{Remote, CustomMsg, CustomQuery};
66
use sylvia::ctx::{InstantiateCtx, QueryCtx, ExecCtx, ReplyCtx, SudoCtx, MigrateCtx};
77
use sylvia::cw_schema::cw_serde;
88
use cw_utils::MsgInstantiateContractResponse;
99
use cw_storey::CwStorage;
1010
use cw_storey::containers::Item;
11+
use std::marker::PhantomData;
1112

1213
pub mod external_contract {
1314
use super::*;

src/pages/sylvia/basics/contract-structure.mdx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ state and define a behavior.
1212
<Tabs items={['Storey', 'StoragePlus']}>
1313
<Tabs.Tab>
1414

15-
```rust, template="sylvia-empty"
15+
```rust template="sylvia-empty"
1616
use cw_storey::containers::Item;
1717

1818
pub struct CounterContract { pub count: Item<u64>, }
@@ -21,8 +21,8 @@ pub struct CounterContract { pub count: Item<u64>, }
2121
</Tabs.Tab>
2222
<Tabs.Tab>
2323

24-
```rust, template="sylvia-empty"
25-
use sylvia::cw_storage_plus::Item;
24+
```rust template="sylvia-empty"
25+
use cw_storage_plus::Item;
2626

2727
pub struct CounterContract { pub count: Item<u64>, }
2828
```
@@ -38,18 +38,23 @@ Let's take a look at the behavior implementation.
3838
<Tabs items={['Storey', 'StoragePlus']}>
3939
<Tabs.Tab>
4040

41-
```rust, template="sylvia-empty"
41+
```rust template="sylvia-empty"
4242
use cosmwasm_schema::cw_serde;
4343
use cw_storey::CwStorage;
44+
use cw_storey::containers::Item;
4445
use sylvia::contract;
4546
use sylvia::cw_std::{Response, StdError, StdResult};
46-
use sylvia::types::{ExecCtx, InstantiateCtx, QueryCtx};
47+
use sylvia::ctx::{ExecCtx, InstantiateCtx, QueryCtx};
4748

4849
#[cw_serde]
4950
pub struct CountResponse {
5051
pub count: u64,
5152
}
5253

54+
pub struct CounterContract {
55+
pub count: Item<u64>,
56+
}
57+
5358
#[cfg_attr(not(feature = "library"), sylvia::entry_points)]
5459
#[contract]
5560
impl CounterContract {
@@ -94,17 +99,22 @@ impl CounterContract {
9499
</Tabs.Tab>
95100
<Tabs.Tab>
96101

97-
```rust, template="sylvia-empty"
102+
```rust template="sylvia-empty"
103+
use cw_storage_plus::Item;
98104
use cosmwasm_schema::cw_serde;
99105
use sylvia::contract;
100106
use sylvia::cw_std::{Response, StdError, StdResult};
101-
use sylvia::types::{ExecCtx, InstantiateCtx, QueryCtx};
107+
use sylvia::ctx::{ExecCtx, InstantiateCtx, QueryCtx};
102108

103109
#[cw_serde]
104110
pub struct CountResponse {
105111
pub count: u64,
106112
}
107113

114+
pub struct CounterContract {
115+
pub count: Item<u64>,
116+
}
117+
108118
#[cfg_attr(not(feature = "library"), sylvia::entry_points)]
109119
#[contract]
110120
impl CounterContract {

src/pages/sylvia/basics/interoperability.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ type provides all the API as the MultiTest counterpart, exposing the underlying
241241
support for using the Sylvia-generated helpers. It can also be used to simulate the execution of
242242
standard CosmWasm contracts as well
243243

244-
```rust, template="sylvia-empty"
244+
```rust
245245
use sylvia::multitest::App;
246246
use sylvia::cw_multi_test::BasicMtApp;
247247

@@ -259,7 +259,7 @@ We can access the underlying
259259
[`store_code`](https://docs.rs/cw-multi-test/latest/cw_multi_test/struct.App.html#method.store_code)
260260
of the CosmWasm contract.
261261

262-
```rust, template="sylvia-empty"
262+
```rust
263263
fn cosmwasm_contract() -> Box<dyn Contract<Empty>> { ... }
264264

265265
let cosmwasm_code = app.app_mut().store_code(cosmwasm_contract());
@@ -268,7 +268,7 @@ let cosmwasm_code = app.app_mut().store_code(cosmwasm_contract());
268268
To instantiate the CosmWasm contract, we will also use the
269269
[`app_mut`](https://docs.rs/sylvia/latest/sylvia/multitest/struct.App.html#method.app_mut).
270270

271-
```rust, template="sylvia-empty"
271+
```rust
272272
let cosmwasm_contract = app
273273
.app_mut()
274274
.instantiate_contract(

src/pages/sylvia/macros/attributes/message.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ List of macros supporting the `sv::messages` attribute:
2121

2222
## Usage
2323

24-
```rust, template="sylvia-empty"
24+
```rust
2525
pub mod interface {
2626
use cosmwasm_schema::cw_serde;
2727
use sylvia::cw_std::{Response, StdError, StdResult};
2828
use sylvia::interface;
29-
use sylvia::types::{ExecCtx, QueryCtx};
29+
use sylvia::ctx::{ExecCtx, QueryCtx};
3030

3131
#[cw_serde]
3232
pub struct InterfaceQueryResp {}
@@ -47,9 +47,9 @@ pub mod contract {
4747
use cosmwasm_std::StdError;
4848
use sylvia::contract;
4949
use sylvia::cw_std::{Response, StdResult};
50-
use sylvia::types::{ExecCtx, InstantiateCtx, QueryCtx};
50+
use sylvia::ctx::{ExecCtx, InstantiateCtx, QueryCtx};
5151

52-
use crate::interface::{Interface, InterfaceQueryResp};
52+
use super::interface::{Interface, InterfaceQueryResp};
5353

5454
pub struct CounterContract;
5555

@@ -77,7 +77,7 @@ pub mod contract {
7777

7878
fn interface_query(&self, ctx: QueryCtx) -> StdResult<InterfaceQueryResp> {
7979
// Your logic here
80-
Ok(Response::new())
80+
Ok(InterfaceQueryResp {})
8181
}
8282
}
8383
}

src/pages/sylvia/macros/attributes/msg.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ requires however additional action. Due to
8383
macro derive on generated `query` message, we have to explicitly provide the return type, as the
8484
macro wouldn't be able to deduce that from the alias.
8585

86-
```rust, template="sylvia-cw-storage-contract"
86+
```rust template="sylvia-cw-storage-contract"
8787
#[sv::msg(query, resp=SomeResponse)]
8888
fn some_query(&self, ctx: QueryCtx) -> SomeResult {
8989
Ok(SomeResponse)

src/pages/sylvia/macros/attributes/override-entry-point.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ List of macros supporting the `sv::override_entry_point` attribute:
2525

2626
## Usage
2727

28-
```rust, template="sylvia-empty"
28+
```rust template="sylvia-empty"
2929
use self::sv::ContractExecMsg;
3030

3131
pub mod entrypoints {
@@ -81,7 +81,7 @@ that in the entry point.
8181

8282
An example of such an approach:
8383

84-
```rust, template="sylvia-empty"
84+
```rust template="sylvia-empty"
8585
use self::sv::ContractExecMsg;
8686

8787
pub mod entrypoints {

src/pages/sylvia/macros/contract.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ List of attributes supported by
3232

3333
## Usage
3434

35-
```rust, template="sylvia-empty"
35+
```rust template="sylvia-empty"
3636
pub struct Contract;
3737

3838
#[cw_serde]
@@ -94,7 +94,7 @@ functionality of one contract with another one. In such a case you might want to
9494
possibility for the user to use it with types that suits their purpose. You can do that by defining
9595
generics on your contract.
9696

97-
```rust, template="sylvia-empty"
97+
```rust template="sylvia-empty"
9898
use cw_storage_plus::Item;
9999

100100
pub struct Contract<ExecParamT, FieldT> {
@@ -178,7 +178,7 @@ it makes testing it in the [MultiTest](../../cw-multi-test) environment with dif
178178
messages tricky. We recommend that if your contract is meant to be chain agnostic, define it with a
179179
generic custom message and custom query.
180180

181-
```rust, template="sylvia-empty"
181+
```rust template="sylvia-empty"
182182
pub struct Contract<CMsgT, CQueryT> {
183183
_phantom: PhantomData<(CMsgT, CQueryT)>,
184184
}

src/pages/sylvia/macros/entry-points.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ List of attributes supported by `entry_points` macro:
2525

2626
## Usage
2727

28-
```rust, template="sylvia-empty"
28+
```rust template="sylvia-empty"
2929
#[cfg(not(feature = "library"))]
3030
use sylvia::entry_points;
3131

@@ -66,7 +66,7 @@ You can construct your entry points to work with some specific custom types with
6666
CosmWasm entry points cannot be generic. We are thus forced to provide concrete types to be used in
6767
place of generic types used in the contract.
6868

69-
```rust, template="sylvia-empty"
69+
```rust template="sylvia-empty"
7070
use cw_storage_plus::Item;
7171

7272
#[cfg(not(feature = "library"))]

0 commit comments

Comments
 (0)