Unverified Commit 9f24b473 authored by Hero Bird's avatar Hero Bird Committed by GitHub
Browse files

Add proc. macro documentation (#504)



* [lang] add doc to ink_lang::test proc. macro

* [lang] add doc to ink_lang::trait_definition proc. macro

* [examples] add whitespace to separate trait methods

* [env] make it possible to use a primitive [u8; 32] as hash type

* [lang] add doc-comment to #[ink::contract] proc. macro

* [lang] add additional notes to #[ink::contract] docs

* [lang] document #[ink::contract] selector controlling

* [lang] add documentation for #[ink::contract] event definition and emitting

* [lang] add doc section explaining env interaction via #[ink::contract]

Explains Self::env() and self.env() interations.

* [ci] add doc generation for ink_lang_ir and ink_lang_codegen

* [lang/macro] fix docs
Co-authored-by: Michael Müller's avatarMichael Müller <mich@elmueller.net>

* [lang/macro] fix typo
Co-authored-by: Michael Müller's avatarMichael Müller <mich@elmueller.net>

* [ink/macro] fix typo
Co-authored-by: Michael Müller's avatarMichael Müller <mich@elmueller.net>

* [lang/macro] improve docs
Co-authored-by: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>

* [lang/macro] fix typo
Co-authored-by: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>

* [lang/macro] fix typo
Co-authored-by: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>

* [lang/macro] fix typo
Co-authored-by: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>

* [env] implement Clear for Hash in terms of Clear for [u8; 32]

* [storage] apply better formatting

* [storage] make clearer that we use DynamicAllocator in test

* [lang/macro] improve docs
Co-authored-by: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>

* [lang/macro] fix typo
Co-authored-by: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>

* [lang/macro] add note about payable constructors

* [lang/macro] fix payable messages example

* [lang/macro] add note about disabling dynamic storage allocator

* [lang/macro] improve section about compile_as_dependency

* [lang/macro] clear up EnvTypes SCALE encoding

* [lang/macro] fix docs

* [lang/macro] fix typo
Co-authored-by: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>
Co-authored-by: Michael Müller's avatarMichael Müller <mich@elmueller.net>
Co-authored-by: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>
parent 4770498c
Pipeline #109616 passed with stages
in 8 minutes and 33 seconds
...@@ -270,8 +270,10 @@ publish-docs: ...@@ -270,8 +270,10 @@ publish-docs:
- git fetch origin gh-pages - git fetch origin gh-pages
# Generating Docs # Generating Docs
- time cargo doc --no-deps --all-features - time cargo doc --no-deps --all-features
-p scale-info -p ink_metadata -p ink_env -p ink_storage -p ink_storage_derive -p scale-info -p ink_metadata
-p ink_primitives -p ink_prelude -p ink_lang -p ink_lang_macro -p ink_env -p ink_storage -p ink_storage_derive
-p ink_primitives -p ink_prelude
-p ink_lang -p ink_lang_macro -p ink_lang_ir -p ink_lang_codegen
# saving README and docs # saving README and docs
- mv target/doc/ /tmp/ - mv target/doc/ /tmp/
- cp README.md /tmp/doc/ - cp README.md /tmp/doc/
......
...@@ -216,12 +216,22 @@ pub trait Clear { ...@@ -216,12 +216,22 @@ pub trait Clear {
fn clear() -> Self; fn clear() -> Self;
} }
impl Clear for Hash { impl Clear for [u8; 32] {
fn is_clear(&self) -> bool { fn is_clear(&self) -> bool {
self.as_ref().iter().all(|&byte| byte == 0x00) self.as_ref().iter().all(|&byte| byte == 0x00)
} }
fn clear() -> Self { fn clear() -> Self {
Self([0x00; 32]) [0x00; 32]
}
}
impl Clear for Hash {
fn is_clear(&self) -> bool {
<[u8; 32] as Clear>::is_clear(&self.0)
}
fn clear() -> Self {
Self(<[u8; 32] as Clear>::clear())
} }
} }
This diff is collapsed.
...@@ -126,7 +126,7 @@ impl DynamicAllocatorState { ...@@ -126,7 +126,7 @@ impl DynamicAllocatorState {
DynamicAllocatorState::Finalized => { DynamicAllocatorState::Finalized => {
panic!( panic!(
"cannot finalize the dynamic storage allocator \ "cannot finalize the dynamic storage allocator \
after it has already been finalized" after it has already been finalized"
) )
} }
DynamicAllocatorState::UninitCall | DynamicAllocatorState::UninitDeploy => { DynamicAllocatorState::UninitCall | DynamicAllocatorState::UninitDeploy => {
......
...@@ -194,7 +194,7 @@ fn test_call_setup_works() { ...@@ -194,7 +194,7 @@ fn test_call_setup_works() {
assert_eq!(allocator.alloc(), DynamicAllocation(0)); assert_eq!(allocator.alloc(), DynamicAllocation(0));
assert_eq!(allocator.alloc(), DynamicAllocation(1)); assert_eq!(allocator.alloc(), DynamicAllocation(1));
let root_key = Key::from([0xFE; 32]); let root_key = Key::from([0xFE; 32]);
SpreadLayout::push_spread(&allocator, &mut KeyPtr::from(root_key)); DynamicAllocator::push_spread(&allocator, &mut KeyPtr::from(root_key));
alloc::initialize(ContractPhase::Call); alloc::initialize(ContractPhase::Call);
assert_eq!(alloc(), DynamicAllocation(2)); assert_eq!(alloc(), DynamicAllocation(2));
assert_eq!(alloc(), DynamicAllocation(3)); assert_eq!(alloc(), DynamicAllocation(3));
......
...@@ -25,6 +25,7 @@ pub trait Flip { ...@@ -25,6 +25,7 @@ pub trait Flip {
/// Flips the current value of the Flipper's bool. /// Flips the current value of the Flipper's bool.
#[ink(message)] #[ink(message)]
fn flip(&mut self); fn flip(&mut self);
/// Returns the current value of the Flipper's bool. /// Returns the current value of the Flipper's bool.
#[ink(message)] #[ink(message)]
fn get(&self) -> bool; fn get(&self) -> bool;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment