Skip to content

Commit

Permalink
docs: configure spell-check (#1224)
Browse files Browse the repository at this point in the history
This PR configures the spell-check added to the docs workflow in the
github-actions repo: FuelLabs/github-actions#23

The files checked are configured in `.spellcheck.yml`. This is also
where you can configure what types of elements are ignored.

Right now it ignores:
- All code blocks that have a language (and will check code blocks that
do not have a language)
- Anything in between backticks
- Words in `spell-check-custom-words.txt` (case sensitive, only exact
match)
- Numbers, even if they are attached to a word
- Links in markdown link format

#### Handling errors:

If the test fails:
- look up the word in the question to verify it is a real word and is
correctly spelled
- If it is a file name or is code, use backticks to ignore the word.
- If it is a real word that is spelled correctly, or an acronym that is
either common or is defined already, add it to
`spell-check-custom-words.txt`.
- If needed, rewrite the sentence. Ex: DON'T use "`lock`ing" and add
"ing" to the custom words list. Instead, rewrite the sentence as
"locking with the `lock` method".
- If it otherwise should be ignored, you can configure the pipeline in
`.spellcheck.yml`.
  • Loading branch information
sarahschwartz authored Dec 8, 2023
1 parent 0151ccf commit 7d8fe92
Show file tree
Hide file tree
Showing 37 changed files with 321 additions and 63 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ jobs:
with:
docs-src-path: "docs/src"
pre-command: 'cargo run --package versions-replacer -- ./docs --manifest-path ./Cargo.toml --filename-regex "\.md$"'
spellcheck-config-path: 'docs/.spellcheck.yml'
30 changes: 30 additions & 0 deletions docs/.spellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
matrix:
- name: SPCheck
aspell:
lang: en
dictionary:
encoding: utf-8
wordlists:
- docs/spell-check-custom-words.txt
pipeline:
- pyspelling.filters.context:
context_visible_first: true
escapes: \\[\\`~]
delimiters:
# Ignore all code blocks
- open: '(?s)^(?P<open> *`{3,}\s*(\w+\s*,?\s*)+.*?)$'
close: '^( *`{3,})$'
- pyspelling.filters.markdown:
markdown_extensions:
- pymdownx.superfences:
- pyspelling.filters.html:
comments: false
ignores:
- code
- pre
sources:
- 'docs/*.md'
- 'docs/src/*.md'
- 'docs/src/**/*.md'
default_encoding: utf-8

227 changes: 227 additions & 0 deletions docs/spell-check-custom-words.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
ABI
ABIs
ASM
IDE
IDEs
LSP
namespace
ALU
APIs
JSON
BrowserStack
CLI
Deserialization
deserializing
DApp
subcurrency
Subcurrency
intrinsics
Intrinsics
workspace
workspaces
Workspaces
neovim
EVM
EVM's
EOA
ERC
Ethereum
Ethereum's
FVM
FuelVM
Fuelup
Github
GraphQL
Infura
JSON
LSP
Merkle
PoA
PoS
PoW
RPC
SDK
SDK's
SDKs
SauceLabs
Sepolia
Structs
Sway
TAI
TODO
TypeScript
UTF
UTXO
UTXOs
Utils
VM
VSCode
abigen
args
async
backend
backtraces
blockchain
blockchain's
bytecode
codespace
codespaces
config
cryptographic
customizable
customizations
dapp
dev
dropdown
enum
enums
env
forc
frontend
fuelup
fullstack
graphQL
graphql
http
https
js
localhost
mainnet
mempool
merkle
monorepo
monorepos
natively
npm
nvm
onboarding
params
pnpm
prerelease
queryable
quickstart
relayer
relayers
repo
repos
runnable
stateful
struct
structs
struct's
testnet
testnets
toolchain
toolchains
urql
validator
validators
superABI
superABIs
SuperABIs
supertraits
compositional
typeclass
turbofish
DSL
TOML
IPFS
Bitwise
Bitwise
runtime
runtimes
formatter
deployable
Utils
ETH
initializer
initializers
destructuring
instantiation
VMs
superset
CEI
pre
entrancy
interoperable
blockchains
keccak
SHA
UI
backtrace
Collateralized
collateralized
submodule
DEX
TypeChain
inlines
inlining
MiB
FuelVM's
deterministically
CLI
VS
GraphViz
DOT
DCA
AST
GitHub
decrypt
subcommand
subcommands
Subcommands
supertrait
supertraits
Supertraits
incrementor
monomorphization
Booleans
boolean
Orchestrator
orchestrator
growable
arity
tuple's
unary
SRC
DEX
FuelLabs
PRs
codebase
PostgreSQL
Postgres
MacOS
macOS
backends
hoc
semver
SQLx
Homebrew
Changelog
lookups
namespaces
YAML
WASM
WebAssembly
dApp
dApps
JWT
Schemas
schemas
AssemblyScript
indexable
Macbook
Dockerized
TLDR
IaaS
Updatable
dereferenced
dereference
dereferencing
codec
Codec
calldata
configurables
Cardinality
RocksDB
cryptographically
22 changes: 11 additions & 11 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- [Connecting to a Fuel node](./connecting/index.md)
- [Connecting to the Testnet or an external node](./connecting/external-node.md)
- [Running a short-lived Fuel node with the SDK](./connecting/short-lived.md)
- [Rocksdb](./connecting/rocksdb.md)
- [RocksDB](./connecting/rocksdb.md)
- [Querying the blockchain](./connecting/querying.md)
- [Retrying upon errors](./connecting/retrying.md)
- [Accounts](./accounts.md)
Expand Down Expand Up @@ -47,18 +47,18 @@
- [Transaction builders](./custom-transactions/transaction-builders.md)
- [Custom contract and script calls](./custom-transactions/custom-calls.md)
- [Types](./types/index.md)
- [Bytes32](./types/bytes32.md)
- [Address](./types/address.md)
- [ContractId](./types/contract-id.md)
- [AssetId](./types/asset-id.md)
- [`Bytes32`](./types/bytes32.md)
- [`Address`](./types/address.md)
- [`ContractId`](./types/contract-id.md)
- [`AssetId`](./types/asset-id.md)
- [Converting native types](./types/conversion.md)
- [Bech32](./types/bech32.md)
- [`Bech32`](./types/bech32.md)
- [Structs and enums](./types/custom_types.md)
- [String](./types/string.md)
- [Bits256](./types/bits256.md)
- [Bytes](./types/bytes.md)
- [B512](./types/B512.md)
- [EvmAddress](./types/evm_address.md)
- [`String`](./types/string.md)
- [`Bits256`](./types/bits256.md)
- [`Bytes`](./types/bytes.md)
- [`B512`](./types/B512.md)
- [`EvmAddress`](./types/evm_address.md)
- [Vectors](./types/vectors.md)
- [Codec](./codec/index.md)
- [Encoding](./codec/encoding.md)
Expand Down
6 changes: 3 additions & 3 deletions docs/src/abigen/the-abigen-macro.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ where:

- `name` is the name that will be given to the generated bindings,

- `abi` is either a path to the json abi file or its actual contents.
- `abi` is either a path to the JSON ABI file or its actual contents.
<!-- abigen:example:end -->

---
Expand Down Expand Up @@ -62,9 +62,9 @@ Each `ProgramType` gets its own `mod` based on the `name` given in the `abigen!`

One extra `mod` called `shared_types` is generated if `abigen!` detects that the given programs share types. Instead of each `mod` regenerating the type for itself, the type is lifted out into the `shared_types` module, generated only once, and then shared between all program bindings that use it. Reexports are added to each mod so that even if a type is deemed shared, you can still access it as though each `mod` had generated the type for itself (i.e. `my_contract_mod::SharedType`).

A type is deemed shared if its name and definition match up. This can happen either because you've used the same library (a custom one or a type from the stdlib) or because you've happened to define the exact same type.
A type is deemed shared if its name and definition match up. This can happen either because you've used the same library (a custom one or a type from the `stdlib`) or because you've happened to define the exact same type.

Finally, `pub use` statements are inserted, so you don't have to fully qualify the generated types. To avoid conflict, only types that have unique names will get a `pub use` statement. If you find rustc can't find your type, it might just be that there is another generated type with the same name. To fix the issue just qualify the path by doing `abigen_bindings::whatever_contract_mod::TheType`.
Finally, `pub use` statements are inserted, so you don't have to fully qualify the generated types. To avoid conflict, only types that have unique names will get a `pub use` statement. If you find `rustc` can't find your type, it might just be that there is another generated type with the same name. To fix the issue just qualify the path by doing `abigen_bindings::whatever_contract_mod::TheType`.

> **Note:**
> It is **highly** encouraged that you generate all your bindings in one `abigen!` call. Doing it in this manner will allow type sharing and avoid name collisions you'd normally get when calling `abigen!` multiple times inside the same namespace. If you choose to proceed otherwise, keep in mind the generated code overview presented above and appropriately separate the `abigen!` calls into different modules to resolve the collision.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/calling-contracts/call-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Once you unwrap the `FuelCallResponse`, you have access to this struct:

<!-- This section should explain the fields of the `FuelCallResponse` struct -->
<!-- call_resp_fields:example:start -->
Where `value` will hold the value returned by its respective contract method, represented by the exact type returned by the FuelVM, E.g., if your contract returns a FuelVM's `u64`, `value`'s `D` will be a `u64`. If it's a FuelVM's tuple `(u8,bool)`, then `D` will be a `(u8,bool)`. If it's a custom type, for instance, a Sway struct `MyStruct` containing two components, a `u64`, and a `b256`, `D` will be a struct generated at compile-time, called `MyStruct` with `u64` and a `[u8; 32]` (the equivalent of `b256` in Rust-land).
Where `value` will hold the value returned by its respective contract method, represented by the exact type returned by the FuelVM, E.g., if your contract returns a FuelVM's `u64`, `value`'s `D` will be a `u64`. If it's a FuelVM's tuple `(u8,bool)`, then `D` will be a `(u8,bool)`. If it's a custom type, for instance, a Sway struct `MyStruct` containing two components, a `u64`, and a `b256`, `D` will be a struct generated at compile-time, called `MyStruct` with `u64` and a `[u8; 32]` (the equivalent of `b256` in Rust).

- `receipts` will hold all [receipts](https://specs.fuel.network/master/protocol/abi/receipts.html) generated by that specific contract call.
- `gas_used` is the amount of gas it consumed by the contract call.
Expand All @@ -31,7 +31,7 @@ Where `value` will hold the value returned by its respective contract method, re

<!-- This section should explain how to use the `is_ok` and `is_err` methods for a call response -->
<!-- call_resp_ok:example:start -->
You can use the `is_ok` and `is_err` methods to check if a contract call `Result` is ok or contains an error. These methods will return either `true` or `false`.
You can use the `is_ok` and `is_err` methods to check if a contract call `Result` is `Ok` or contains an error. These methods will return either `true` or `false`.
<!-- call_resp_ok:example:end -->

<!-- This section should show an example of how to use the `is_ok` and `is_err` methods for a call response -->
Expand Down
2 changes: 1 addition & 1 deletion docs/src/calling-contracts/custom-asset-transfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- This section should explain the `add_custom_asset()` method -->
<!-- transfer:example:start -->
The SDK provides the option to transfer assets within the same transaction, when making a contract call. By using `add_custom_asset()` you specify the asset id, the amount, and the destination address:
The SDK provides the option to transfer assets within the same transaction, when making a contract call. By using `add_custom_asset()` you specify the asset ID, the amount, and the destination address:
<!-- transfer:example:end -->

```rust,ignore
Expand Down
2 changes: 1 addition & 1 deletion docs/src/calling-contracts/read-only.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Sometimes you want to call a contract method that doesn't change the state of th

In this case, there's no need to generate an actual blockchain transaction; you only want to read a value quickly.

You can do this with the SDK. Instead of `.call()`ing the method, use `.simulate()`:
You can do this with the SDK. Instead of calling the method with `.call()`, use `.simulate()`:
<!-- read_only:example:end -->

```rust,ignore
Expand Down
2 changes: 1 addition & 1 deletion docs/src/calling-contracts/tx-dependency-estimation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ As mentioned in previous chapters, you can specify the external contract with `.
{{#include ../../../examples/contracts/src/lib.rs:dependency_estimation_manual}}
```

But this requires you to know the contract id of the external contract and the needed number of output variables. Alternatively, by chaining `.estimate_tx_dependencies()` instead, the dependencies will be estimated by the SDK and set automatically. The optional parameter is the maximum number of simulation attempts:
But this requires you to know the contract ID of the external contract and the needed number of output variables. Alternatively, by chaining `.estimate_tx_dependencies()` instead, the dependencies will be estimated by the SDK and set automatically. The optional parameter is the maximum number of simulation attempts:

```rust,ignore
{{#include ../../../examples/contracts/src/lib.rs:dependency_estimation}}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/cli/fuels-abi-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $ cargo run -- encode params -v bool true -v u32 42 -v u32 100
0000000000000001000000000000002a0000000000000064
```

Note that for every param you want to encode, you must pass a `-v` flag followed by the type, and then the value: `-v <type_1> <value_1> -v <type_2> <value_2> -v <type_n> <value_n>`
Note that for every parameter you want to encode, you must pass a `-v` flag followed by the type, and then the value: `-v <type_1> <value_1> -v <type_2> <value_2> -v <type_n> <value_n>`

### Encoding function call

Expand Down
4 changes: 2 additions & 2 deletions docs/src/codec/index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Codec

Encoding and decoding are done as per [the fuel spec](https://specs.fuel.network/master/abi/argument-encoding.html). To this end, `fuels` makes use of the [ABIEncoder](https://docs.rs/fuels/latest/fuels/core/codec/struct.ABIEncoder.html) and the [ABIDecoder](https://docs.rs/fuels/latest/fuels/core/codec/struct.ABIDecoder.html).
Encoding and decoding are done as per [the fuel spec](https://specs.fuel.network/master/abi/argument-encoding.html). To this end, `fuels` makes use of the [`ABIEncoder`](https://docs.rs/fuels/latest/fuels/core/codec/struct.ABIEncoder.html) and the [`ABIDecoder`](https://docs.rs/fuels/latest/fuels/core/codec/struct.ABIDecoder.html).

## Prerequisites for decoding/encoding

To encode a type, you must first convert it into a [`Token`](https://docs.rs/fuels/latest/fuels/types/enum.Token.html). This is commonly done by implementing the [Tokenizable](https://docs.rs/fuels/latest/fuels/core/traits/trait.Tokenizable.html) trait.
To encode a type, you must first convert it into a [`Token`](https://docs.rs/fuels/latest/fuels/types/enum.Token.html). This is commonly done by implementing the [`Tokenizable`](https://docs.rs/fuels/latest/fuels/core/traits/trait.Tokenizable.html) trait.

To decode, you also need to provide a [`ParamType`](https://docs.rs/fuels/latest/fuels/types/param_types/enum.ParamType.html) describing the schema of the type in question. This is commonly done by implementing the [Parameterize](https://docs.rs/fuels/latest/fuels/core/traits/trait.Parameterize.html) trait.

Expand Down
Loading

0 comments on commit 7d8fe92

Please sign in to comment.