Skip to content

Commit

Permalink
Update website docs (#1433)
Browse files Browse the repository at this point in the history
  • Loading branch information
maciektr authored Jul 10, 2024
1 parent 3af50d5 commit 64c39db
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion extensions/scarb-cairo-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct Args {

/// Choose test kind to run.
#[arg(short, long)]
pub test_kind: Option<TestKind>,
test_kind: Option<TestKind>,

/// Whether to print resource usage after each test.
#[arg(long, default_value_t = false)]
Expand Down
1 change: 1 addition & 0 deletions website/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const sidebar = {
],
},
p("Language server", "/docs/extensions/cairo-language-server"),
p("Expand", "/docs/extensions/expand"),
],
},
{
Expand Down
22 changes: 22 additions & 0 deletions website/docs/extensions/expand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Expand

`scarb expand` is a tool that makes debugging macros in Scarb easier.

Before the actual compilation of your Cairo code, the Cairo compiler runs multiple pre-processing steps on it (these are
usually called plugins).
Each of these steps takes parsed Cairo code as an input, modifies it and returns modified Cairo code back to the
compiler.

This can often implement code generation, optimizations, or other transformations.
For instance, derives for Cairo structs can be implemented this way, or some boilerplate code can be generated.
This is also used in Cairo compiler to implement conditional compilation with `cfg` attributes.
Blocks of code under disabled `cfg` sets will be removed at this phase.

While preprocessing is useful for making the programmers code shorter and easier to reason about, it can also make
debugging harder.
Because of the preprocessing, Cairo code that is **actually** compiled can be different from the one you see in your
editor.

To help with debugging your code in such cases, you can use `scarb expand` command, which runs all preprocessing steps
on your package and return expanded Cairo code.
The expanded Cairo is saved as a file in your target directory.
18 changes: 15 additions & 3 deletions website/docs/reference/manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,18 @@ enable-gas = false

This flag cannot be disabled while compiling the `starknet-contract` target.

### `inlining-strategy`

This field is responsible for setting the inlining strategy to be used by compiler when building the package.
The possible values are `default` or `avoid`.
If `avoid` strategy is set, the compiler will only inline function annotated with `#[inline(always)]` attribute.

> [!WARNING]
> Using the `avoid` strategy may result in a slower execution of the compiled code and significantly larger artefacts
> size.
> Please use with caution, only if your tooling requires that.
> You can use profile settings overwriting, for more granular control of which builds use the avoid strategy.
### `unstable-add-statements-functions-debug-info`

> [!WARNING]
Expand All @@ -285,9 +297,9 @@ This flag cannot be disabled while compiling the `starknet-contract` target.
> It may slow down the compilation - it is advised not to use it for other purposes than mentioned in
> [cairo-profiler](https://github.com/software-mansion/cairo-profiler) documentation.
If enabled, during the project compilation Scarb will a add mapping between Sierra statement indexes and vectors of fully
qualified paths of Cairo functions to debug info. A statement index maps to a vector consisting of a function which
caused the statement to be generated and all functions that were inlined or generated along the way.
If enabled, during the project compilation Scarb will a add mapping between Sierra statement indexes and vectors of
fully qualified paths of Cairo functions to debug info. A statement index maps to a vector consisting of a function
which caused the statement to be generated and all functions that were inlined or generated along the way.
By default, this flag is disabled.

```toml
Expand Down

0 comments on commit 64c39db

Please sign in to comment.