Skip to content

Commit 7aaf4dc

Browse files
Michael MüllerRobbepop
Michael Müller
andauthored
Fix broken intra-doc links + add CI stage to test example docs (#606)
* Fix broken intra-doc links * Fix doc link * Add CI stage to test example docs * Revert me: Provoke doc failures in example * Remove intra-crate link to non-dependency * Remove `--all-features` * Revert "Revert me: Provoke doc failures in example" This reverts commit 563bfeb. * Prettify paragraph * Remove unnecessary imports * Revert "Remove unnecessary imports" This reverts commit 0520713. * Remove unnecessary imports * Remove `cfg(doc)` path resolution for doc comments * Improve language and formatting * Upgrade `scale` and `scale-info` for `rand-extension` * Make http link work * Remove `crate::` prefix from doc links * Apply suggestions from code review Co-authored-by: Hero Bird <[email protected]> Co-authored-by: Hero Bird <[email protected]>
1 parent ad89397 commit 7aaf4dc

File tree

15 files changed

+66
-46
lines changed

15 files changed

+66
-46
lines changed

.gitlab-ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,20 @@ examples-contract-build:
264264
popd;
265265
done
266266

267+
examples-docs:
268+
stage: examples
269+
<<: *docker-env
270+
variables:
271+
RUSTDOCFLAGS: -Dwarnings
272+
script:
273+
# `--document-private-items` needs to be in here because currently our contract macro
274+
# puts the contract functions in a private module.
275+
# Once https://github.com/paritytech/ink/issues/336 has been implemented we can get rid
276+
# of this flag.
277+
- for example in examples/*/; do
278+
cargo doc --manifest-path ${example}/Cargo.toml --document-private-items --verbose --no-deps;
279+
done
280+
267281
#### stage: publish
268282

269283
publish-docs:

crates/env/src/backend.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -169,84 +169,84 @@ pub trait TypedEnvBackend: EnvBackend {
169169
///
170170
/// # Note
171171
///
172-
/// For more details visit: [`ink_env::caller`]
172+
/// For more details visit: [`caller`][`crate::caller`]
173173
fn caller<T: Environment>(&mut self) -> Result<T::AccountId>;
174174

175175
/// Returns the transferred balance for the contract execution.
176176
///
177177
/// # Note
178178
///
179-
/// For more details visit: [`ink_env::transferred_balance`]
179+
/// For more details visit: [`transferred_balance`][`crate::transferred_balance`]
180180
fn transferred_balance<T: Environment>(&mut self) -> Result<T::Balance>;
181181

182182
/// Returns the price for the specified amount of gas.
183183
///
184184
/// # Note
185185
///
186-
/// For more details visit: [`ink_env::gas_price`]
186+
/// For more details visit: [`weight_to_fee`][`crate::weight_to_fee`]
187187
fn weight_to_fee<T: Environment>(&mut self, gas: u64) -> Result<T::Balance>;
188188

189189
/// Returns the amount of gas left for the contract execution.
190190
///
191191
/// # Note
192192
///
193-
/// For more details visit: [`ink_env::gas_left`]
193+
/// For more details visit: [`gas_left`][`crate::gas_left`]
194194
fn gas_left<T: Environment>(&mut self) -> Result<T::Balance>;
195195

196196
/// Returns the timestamp of the current block.
197197
///
198198
/// # Note
199199
///
200-
/// For more details visit: [`ink_env::block_timestamp`]
200+
/// For more details visit: [`block_timestamp`][`crate::block_timestamp`]
201201
fn block_timestamp<T: Environment>(&mut self) -> Result<T::Timestamp>;
202202

203203
/// Returns the address of the executed contract.
204204
///
205205
/// # Note
206206
///
207-
/// For more details visit: [`ink_env::account_id`]
207+
/// For more details visit: [`account_id`][`crate::account_id`]
208208
fn account_id<T: Environment>(&mut self) -> Result<T::AccountId>;
209209

210210
/// Returns the balance of the executed contract.
211211
///
212212
/// # Note
213213
///
214-
/// For more details visit: [`ink_env::balance`]
214+
/// For more details visit: [`balance`][`crate::balance`]
215215
fn balance<T: Environment>(&mut self) -> Result<T::Balance>;
216216

217217
/// Returns the current rent allowance for the executed contract.
218218
///
219219
/// # Note
220220
///
221-
/// For more details visit: [`ink_env::rent_allowance`]
221+
/// For more details visit: [`rent_allowance`][`crate::rent_allowance`]
222222
fn rent_allowance<T: Environment>(&mut self) -> Result<T::Balance>;
223223

224224
/// Returns the current block number.
225225
///
226226
/// # Note
227227
///
228-
/// For more details visit: [`ink_env::block_number`]
228+
/// For more details visit: [`block_number`][`crate::block_number`]
229229
fn block_number<T: Environment>(&mut self) -> Result<T::BlockNumber>;
230230

231231
/// Returns the minimum balance that is required for creating an account.
232232
///
233233
/// # Note
234234
///
235-
/// For more details visit: [`ink_env::minimum_balance`]
235+
/// For more details visit: [`minimum_balance`][`crate::minimum_balance`]
236236
fn minimum_balance<T: Environment>(&mut self) -> Result<T::Balance>;
237237

238238
/// Returns the tombstone deposit of the contract chain.
239239
///
240240
/// # Note
241241
///
242-
/// For more details visit: [`ink_env::tombstone_deposit`]
242+
/// For more details visit: [`tombstone_deposit`][`crate::tombstone_deposit`]
243243
fn tombstone_deposit<T: Environment>(&mut self) -> Result<T::Balance>;
244244

245245
/// Emits an event with the given event data.
246246
///
247247
/// # Note
248248
///
249-
/// For more details visit: [`ink_env::emit_event`]
249+
/// For more details visit: [`emit_event`][`crate::emit_event`]
250250
fn emit_event<T, Event>(&mut self, event: Event)
251251
where
252252
T: Environment,
@@ -256,7 +256,7 @@ pub trait TypedEnvBackend: EnvBackend {
256256
///
257257
/// # Note
258258
///
259-
/// For more details visit: [`ink_env::set_rent_allowance`]
259+
/// For more details visit: [`set_rent_allowance`][`crate::set_rent_allowance`]
260260
fn set_rent_allowance<T>(&mut self, new_value: T::Balance)
261261
where
262262
T: Environment;
@@ -265,7 +265,7 @@ pub trait TypedEnvBackend: EnvBackend {
265265
///
266266
/// # Note
267267
///
268-
/// For more details visit: [`ink_env::invoke_contract`]
268+
/// For more details visit: [`invoke_contract`][`crate::invoke_contract`]
269269
fn invoke_contract<T, Args>(
270270
&mut self,
271271
call_data: &CallParams<T, Args, ()>,
@@ -278,7 +278,7 @@ pub trait TypedEnvBackend: EnvBackend {
278278
///
279279
/// # Note
280280
///
281-
/// For more details visit: [`ink_env::eval_contract`]
281+
/// For more details visit: [`eval_contract`][`crate::eval_contract`]
282282
fn eval_contract<T, Args, R>(
283283
&mut self,
284284
call_data: &CallParams<T, Args, ReturnType<R>>,
@@ -292,7 +292,7 @@ pub trait TypedEnvBackend: EnvBackend {
292292
///
293293
/// # Note
294294
///
295-
/// For more details visit: [`ink_env::instantiate_contract`]
295+
/// For more details visit: [`instantiate_contract`][`crate::instantiate_contract`]
296296
fn instantiate_contract<T, Args, Salt, C>(
297297
&mut self,
298298
params: &CreateParams<T, Args, Salt, C>,
@@ -306,7 +306,7 @@ pub trait TypedEnvBackend: EnvBackend {
306306
///
307307
/// # Note
308308
///
309-
/// For more details visit: [`ink_env::restore_contract`]
309+
/// For more details visit: [`restore_contract`][`crate::restore_contract`]
310310
fn restore_contract<T>(
311311
&mut self,
312312
account_id: T::AccountId,
@@ -320,7 +320,7 @@ pub trait TypedEnvBackend: EnvBackend {
320320
///
321321
/// # Note
322322
///
323-
/// For more details visit: [`ink_env::terminate_contract`]
323+
/// For more details visit: [`terminate_contract`][`crate::terminate_contract`]
324324
fn terminate_contract<T>(&mut self, beneficiary: T::AccountId) -> !
325325
where
326326
T: Environment;
@@ -329,7 +329,7 @@ pub trait TypedEnvBackend: EnvBackend {
329329
///
330330
/// # Note
331331
///
332-
/// For more details visit: [`ink_env::transfer`]
332+
/// For more details visit: [`transfer`][`crate::transfer`]
333333
fn transfer<T>(&mut self, destination: T::AccountId, value: T::Balance) -> Result<()>
334334
where
335335
T: Environment;
@@ -338,7 +338,7 @@ pub trait TypedEnvBackend: EnvBackend {
338338
///
339339
/// # Note
340340
///
341-
/// For more details visit: [`ink_env::random`]
341+
/// For more details visit: [`random`][`crate::random`]
342342
fn random<T>(&mut self, subject: &[u8]) -> Result<T::Hash>
343343
where
344344
T: Environment;

crates/env/src/engine/off_chain/db/block.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct Block {
3434
/// # Note
3535
///
3636
/// - Can optionally be set for more control via
37-
/// [`crate::set_block_randomization_hash`].
37+
/// [`test::set_block_entropy`][`crate::test::set_block_entropy`].
3838
entropy: OffHash,
3939
}
4040

@@ -75,7 +75,7 @@ impl Block {
7575
///
7676
/// # Note
7777
///
78-
/// This is mainly used to control what [`crate::random`] returns
78+
/// This is mainly used to control what [`random`][`crate::random`] returns
7979
/// in the off-chain environment.
8080
pub fn set_entropy<T>(&mut self, new_entropy: T::Hash) -> Result<()>
8181
where
@@ -89,7 +89,7 @@ impl Block {
8989
/// # Note
9090
///
9191
/// - This is the off-chain environment implementation of
92-
/// [`crate::random`]. It provides the same behaviour in that it
92+
/// [`random`][`crate::random`]. It provides the same behaviour in that it
9393
/// will likely yield the same hash for the same subjects within the same
9494
/// block (or execution context).
9595
///

crates/env/src/engine/off_chain/test_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ where
194194
///
195195
/// # Note
196196
///
197-
/// This allows to control what [`crate::random`] returns.
197+
/// This allows to control what [`random`][`crate::random`] returns.
198198
pub fn set_block_entropy<T>(entropy: T::Hash) -> Result<()>
199199
where
200200
T: Environment,

crates/lang/codegen/src/generator/cross_calling.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl CrossCalling<'_> {
140140
}
141141
}
142142

143-
/// Builds up the [`ink_env::call::ArgumentList`] type structure for the given types.
143+
/// Builds up the `ink_env::call::utils::ArgumentList` type structure for the given types.
144144
fn generate_arg_list<'a, Args>(args: Args) -> TokenStream2
145145
where
146146
Args: IntoIterator<Item = &'a syn::Type>,

crates/storage/src/collections/bitstash/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ impl BitStash {
7171
/// in the `free` list.
7272
///
7373
/// Returns the bit position of the first bit in the 256-bit chunk and not
74-
/// the chunk position since that's what [`Bitvec::get_chunk`] expects.
74+
/// the chunk position since that's what
75+
/// [`Bitvec::get_chunk`][`crate::collections::Bitvec::get_chunk`]
76+
/// expects.
7577
///
7678
/// Also directly increases the count of the first found free bit chunk.
7779
fn position_first_zero(&mut self) -> Option<u64> {

crates/storage/src/collections/smallvec/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
//! A small storage vector that allows to store a limited amount of elements.
1616
//!
17-
//! Prefer using [`SmallVec`] over [`crate::Vec`] if you know up front
17+
//! Prefer using [`SmallVec`] over [`Vec`][`crate::Vec`] if you know up front
1818
//! the maximum amount of unique elements that have to be stored in the vector
1919
//! at the same time, given the number is fairly low: e.g. not exceeding several
2020
//! hundreds of elements.
@@ -89,7 +89,8 @@ where
8989
/// the contents of its associated storage region.
9090
///
9191
/// This API is used for the `Drop` implementation of [`Vec`] as well as
92-
/// for the [`SpreadLayout::clear_spread`] trait implementation.
92+
/// for the [`SpreadLayout::clear_spread`][`crate::traits::SpreadLayout::clear_spread`]
93+
/// trait implementation.
9394
fn clear_cells(&self) {
9495
if self.elems.key().is_none() {
9596
// We won't clear any storage if we are in lazy state since there

crates/storage/src/collections/stash/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ where
266266
/// the contents of its associated storage region.
267267
///
268268
/// This API is used for the `Drop` implementation of [`Vec`] as well as
269-
/// for the [`SpreadLayout::clear_spread`] trait implementation.
269+
/// for the [`SpreadLayout::clear_spread`][`crate::traits::SpreadLayout::clear_spread`]
270+
/// trait implementation.
270271
fn clear_cells(&self) {
271272
if self.entries.key().is_none() {
272273
// We won't clear any storage if we are in lazy state since there

crates/storage/src/collections/vec/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ where
109109
/// the contents of its associated storage region.
110110
///
111111
/// This API is used for the `Drop` implementation of [`Vec`] as well as
112-
/// for the [`SpreadLayout::clear_spread`] trait implementation.
112+
/// for the [`SpreadLayout::clear_spread`][`crate::traits::SpreadLayout::clear_spread`]
113+
/// trait implementation.
113114
fn clear_cells(&self) {
114115
if self.elems.key().is_none() {
115116
// We won't clear any storage if we are in lazy state since there

crates/storage/src/lazy/entry.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#[cfg(doc)]
16-
use crate::lazy::{
17-
LazyArray,
18-
LazyIndexMap,
19-
};
2015
use crate::traits::{
2116
clear_packed_root,
2217
clear_spread_root_opt,
@@ -187,7 +182,7 @@ where
187182
/// # Note
188183
///
189184
/// Mainly used by lazy storage abstractions that only allow operating on
190-
/// packed storage entities such as [`LazyCell`].
185+
/// packed storage entities such as [`LazyCell`][`crate::lazy::LazyCell`].
191186
pub fn pull_spread_root(root_key: &Key) -> Self {
192187
Self::new(pull_spread_root_opt::<T>(&root_key), EntryState::Preserved)
193188
}
@@ -197,7 +192,7 @@ where
197192
/// # Note
198193
///
199194
/// Mainly used by lazy storage abstractions that only allow operating on
200-
/// packed storage entities such as [`LazyCell`].
195+
/// packed storage entities such as [`LazyCell`][`crate::lazy::LazyCell`].
201196
pub fn push_spread_root(&self, root_key: &Key) {
202197
let old_state = self.replace_state(EntryState::Preserved);
203198
if old_state.is_mutated() {
@@ -210,7 +205,7 @@ where
210205
/// # Note
211206
///
212207
/// Mainly used by lazy storage abstractions that only allow operating on
213-
/// packed storage entities such as [`LazyCell`].
208+
/// packed storage entities such as [`LazyCell`][`crate::lazy::LazyCell`].
214209
pub fn clear_spread_root(&self, root_key: &Key) {
215210
clear_spread_root_opt::<T, _>(&root_key, || self.value().into());
216211
}
@@ -225,7 +220,8 @@ where
225220
/// # Note
226221
///
227222
/// Mainly used by lazy storage abstractions that only allow operating on
228-
/// packed storage entities such as [`LazyIndexMap`] or [`LazyArray`].
223+
/// packed storage entities such as [`LazyIndexMap`][`crate::lazy::LazyIndexMap`] or
224+
/// [`LazyArray`][`crate::lazy::LazyArray`].
229225
pub fn pull_packed_root(root_key: &Key) -> Self {
230226
Self::new(pull_packed_root_opt::<T>(root_key), EntryState::Preserved)
231227
}
@@ -235,7 +231,8 @@ where
235231
/// # Note
236232
///
237233
/// Mainly used by lazy storage abstractions that only allow operating on
238-
/// packed storage entities such as [`LazyIndexMap`] or [`LazyArray`].
234+
/// packed storage entities such as [`LazyIndexMap`][`crate::lazy::LazyIndexMap`]
235+
/// or [`LazyArray`][`crate::lazy::LazyArray`].
239236
pub fn push_packed_root(&self, root_key: &Key) {
240237
let old_state = self.replace_state(EntryState::Preserved);
241238
if old_state.is_mutated() {
@@ -248,7 +245,8 @@ where
248245
/// # Note
249246
///
250247
/// Mainly used by lazy storage abstractions that only allow operating on
251-
/// packed storage entities such as [`LazyIndexMap`] or [`LazyArray`].
248+
/// packed storage entities such as [`LazyIndexMap`][`crate::lazy::LazyIndexMap`]
249+
/// or [`LazyArray`][`crate::lazy::LazyArray`].
252250
pub fn clear_packed_root(&self, root_key: &Key) {
253251
clear_packed_root::<Option<T>>(self.value(), &root_key);
254252
}

crates/storage/src/lazy/lazy_hmap.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ where
361361
///
362362
/// This constructor is private and should never need to be called from
363363
/// outside this module. It is used to construct a lazy index map from a
364-
/// key that is only useful upon a contract call. Use [`LazyIndexMap::new`]
364+
/// key that is only useful upon a contract call. Use
365+
/// [`LazyIndexMap::new`][`crate::lazy::LazyIndexMap::new`]
365366
/// for construction during contract initialization.
366367
fn lazy(key: Key) -> Self {
367368
Self {

crates/storage/src/lazy/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//!
1818
//! Users should generally avoid using these collections directly in their
1919
//! contracts and should instead adhere to the high-level collections found
20-
//! in [`crate::collections`].
20+
//! in [`collections`][`crate::collections`].
2121
//! The low-level collections are mainly used as building blocks for internals
2222
//! of other higher-level storage collections.
2323
//!

examples/dns/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ mod dns {
5858
new_owner: AccountId,
5959
}
6060

61-
/// Domain name service contract inspired by ChainX's [blog post]
62-
/// (https://medium.com/@chainx_org/secure-and-decentralized-polkadot-domain-name-system-e06c35c2a48d).
61+
/// Domain name service contract inspired by ChainX's
62+
/// [blog post](https://medium.com/@chainx_org/secure-and-decentralized-polkadot-domain-name-system-e06c35c2a48d).
6363
///
6464
/// # Note
6565
///

examples/rand-extension/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
1415
#![cfg_attr(not(feature = "std"), no_std)]
1516

1617
use ink_env::Environment;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Chain-side Extension
22

3-
use this as an implement of trait `ChainExtension` in substrate and use it as the associated type ChainExtension of trait `pallet_contracts::Config`
3+
Use this as an implementation of the trait `ChainExtension` in Substrate
4+
and use it as the associated type `ChainExtension` of the trait `pallet_contracts::Config`.

0 commit comments

Comments
 (0)