Skip to content

Commit d02fb5d

Browse files
authored
Update all titles + various improvements (cairo-book#726)
1 parent 05c6fc4 commit d02fb5d

42 files changed

Lines changed: 162 additions & 161 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cairo-documentation-style-guide.md

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ The style guide is based on the best practices collected from the following book
3939
- [Terminology](#terminology)
4040
- [Recommended Terms](#recommended-terms)
4141
- [Admonitions](#admonitions)
42-
- [Appendix A Existing Style Guides](#appendix-a-existing-style-guides)
42+
- [Appendix A: Existing Style Guides](#appendix-a-existing-style-guides)
4343
- [Documentation](#documentation)
4444
- [Code](#code)
4545

4646
## Heading Titles
4747

4848
The Cairo Book usually have heading titles based on nouns or gerunds:
4949

50-
> **Design Patterns**<br>
50+
> **Design Patterns**
5151
> **Using Structs to Structure Related Data**
5252
5353
### Capitalization
@@ -56,28 +56,28 @@ In heading titles, capitalize the first letter of every word **except for**:
5656

5757
- Articles (a, an, the); unless an article is the first word.
5858

59-
> **Defining an Enum**<br>
60-
> **Generic Types and Traits**
59+
> **Defining an Enum**
6160
6261
- Coordinating conjunctions (and, but, for, or, nor).
6362

63+
> **Generic Types and Traits**
6464
> **Packages and Crates**
6565
66-
- Prepositions of four letters or less; unless these prepositions are the first or last words.
67-
- Prepositions of _five_ letters and above should be capitalized (Before, Through, Versus, Among, Under, Between, Without, etc.).
68-
69-
> **Peripherals as State Machines**
66+
- Prepositions of _four_ letters or less, unless these prepositions are the first or last words. Prepositions of _five_ letters and above should be capitalized (Before, Through, Versus, Among, Under, Between, Without, etc.).
67+
68+
> **Using Structs to Structure Related Data**
69+
> **Components: Under the Hood**
7070
7171
Do not capitalize names of functions, commands, packages, websites, etc.
7272

73-
> **What is `assert`**<br>
73+
> **What is `assert`**
7474
> **Bringing Paths into Scope with the `use` Keyword**
7575
7676
See also, the [Using `monospace`](#using-monospace) section.
7777

7878
In hyphenated words, do not capitalize the parts following the hyphens.
7979

80-
> **Built-in Targets**<br>
80+
> **Built-in Targets**
8181
> **Allowed-by-default Lints**
8282
8383
## Linking
@@ -101,13 +101,13 @@ Example:
101101

102102
### Formatting
103103

104-
The Cairo Book usually use the following link formatting:
104+
The Cairo Book usually uses the following link formatting:
105105

106-
> Instead, you must define a [Trait](https://book.cairo-lang.org/ch08-02-traits-in-cairo.html) and a, ...
106+
> Instead, you must define a [Trait](./ch08-02-traits-in-cairo.md) and a, ...
107107
108-
- Make intra-book links relative, so they work both online and locally
108+
- Make intra-book links relative, so they work both online and locally.
109109

110-
Do NOT turn long phrases into links
110+
Do NOT turn long phrases into links.
111111

112112
> ❌ See the [Cairo Reference’s section on constant evaluation](https://book.cairo-lang.org/ch02-01-variables-and-mutability.html) for more information on what operations can be used when declaring constants.
113113
@@ -126,13 +126,13 @@ See also, the [Using `monospace`](#using-monospace) section.
126126

127127
The following types of lists are usually used in documentation:
128128

129-
- **Bullet list** -- use it if the order or items is not important
129+
- **Bullet list** -- use it if the order of items is not important
130130
- **Numbered list** -- use it if the order of items is important, such as when describing a process
131131
- **Procedure** -- special type of numbered list that gives steps to achieve some goal (to achieve this, do this); for an example of a procedure, see the [Usage](https://doc.rust-lang.org/nightly/rustc/profile-guided-optimization.html#usage) section in The rustc book.
132132

133133
### Formatting
134134

135-
The Cairo Book usually use the following list formatting:
135+
The Cairo Book usually uses the following list formatting:
136136

137137
- Finish an introductory sentence with a dot.
138138
- Capitalize the first letter of each bullet point.
@@ -160,29 +160,28 @@ Use monospace font for the following items:
160160

161161
- Code snippets
162162

163-
- Start the terminal commands with $
164-
- Output of previous commands should not start with $
165-
163+
- Start the terminal commands with `$`
164+
- Output of previous commands should not start with `$`
166165
- Use `bash` syntax highlighting
167166

168167
- Cairo declarations: commands, functions, arguments, parameters, flags, variables
169168
- In-line command line output
170169

171170
> Writing a program that prints `Hello, world!`
172171
173-
- Data types: `u8`, `u128`
174-
- Names of crates, traits, libraries,
172+
- Data types: `u8`, `u128`, etc
173+
- Names of crates, traits, libraries
175174
- Command line tools, plugins, packages
176175

177176
### Monospace and Other Types of Formatting
178177

179178
Monospace font can also be used in:
180179

181-
- links
180+
- Links
182181

183-
> [`String`](https://doc.rust-lang.org/std/string/struct.String.html) is a string type provided by ...
182+
> [`String`](./ch02-02-data-types.html#string-types) is a string type provided by ...
184183
185-
- headings
184+
- Headings
186185

187186
> **Serializing with `Serde`**
188187
@@ -212,11 +211,11 @@ Monospace font can also be used in:
212211
>
213212
> `scarb new hello_world`
214213
>
215-
> 2\. Go into the hello_world directory with the command cd hello_world.
214+
> 2\. Go into the _hello_world_ directory with the command cd hello_world
216215
>
217216
> `cd hello_world`
218217
219-
- Use _the third person_ (the user, it) when describing how things work from the perspective of hardware or software
218+
- Use _the third person_ (the user, it) when describing how things work from the perspective of hardware or software.
220219

221220
> Cairo uses an immutable memory model, meaning that once a memory cell is written to, it can't be overwritten but only read from. To reflect this immutable memory model, variables in Cairo are immutable by default.
222221
@@ -257,6 +256,8 @@ In markdown:
257256
> ⚠️ **Note**: Write your note.
258257
```
259258

259+
## Appendix A: Existing Style Guides
260+
260261
### Documentation
261262

262263
- [The Rust Programming Language Style Guide](https://github.com/rust-lang-ja/book-ja/blob/master-ja/style-guide.md)

src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
- [Starknet Smart Contracts Security](./ch17-00-starknet-smart-contracts-security.md)
151151

152152
- [General Recommendations](./ch17-01-general-recommendations.md)
153-
- [Testing Smart Contracts with Starknet Foundry]()
153+
- [Testing Smart Contracts]()
154154
- [Static Analysis Tools](./ch17-03-static-analysis-tools.md)
155155
- [Formal Verification]()
156156

src/appendix-01-keywords.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ They cannot be used as names of any items.
4949

5050
---
5151

52-
## Loose keywords
52+
## Loose Keywords
5353

5454
These keywords are associated with a specific behaviour, but can also be used to define items.
5555

@@ -58,7 +58,7 @@ These keywords are associated with a specific behaviour, but can also be used to
5858

5959
---
6060

61-
## Reserved keywords
61+
## Reserved Keywords
6262

6363
These keywords aren't used yet, but they are reserved for future use.
6464
For now, it is possible to use them to define items, although it is highly recommended not to do so.
@@ -84,7 +84,7 @@ Cairo by forbidding them to use these keywords.
8484

8585
---
8686

87-
## Built-in functions
87+
## Built-in Functions
8888

8989
The Cairo programming language provides several specific functions that serve a special purpose. We will not cover all of them in this book, but using the names of these functions as names of other items is not recommended.
9090

src/appendix-04-common-types-and-traits-and-cairo-prelude.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The compiler currently exposes 2 different versions of the prelude:
3333
- A general version, with a lot of traits that are made available, corresponding to `edition = "2023_01"`.
3434
- A restricted version, including the most essential traits needed for general cairo programming, corresponding to `edition = 2023_11`.
3535

36-
## List of common types and traits
36+
## List of Common Types and Traits
3737

3838
The following section provides a brief overview of commonly used types and traits when developing Cairo programs. Most of these are included in the prelude and are therefore not required to be imported explicitly - but not all of them.
3939

src/appendix-06-cairo-binaries.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Appendix F - Installing the Cairo binaries
1+
# Appendix F - Installing the Cairo Binaries
22

33
If you want to have access to the Cairo binaries, for anything that you could not achieve by purely using Scarb you can install them by following the instructions below.
44

@@ -55,7 +55,7 @@ and finally, restart your shell:
5555
exec $SHELL
5656
```
5757

58-
### Set up your shell environment for Cairo
58+
### Set Up your Shell Environment for Cairo
5959

6060
- Define environment variable `CAIRO_ROOT` to point to the path where
6161
Cairo will store its data. `$HOME/.cairo` is the default.
@@ -127,7 +127,7 @@ IDE-like popup interface in the terminal window.
127127
(Note that their completions are independent of Cairo's codebase
128128
so they might be slightly out of sync for bleeding-edge interface changes.)
129129
130-
### Restart your shell
130+
### Restart your Shell
131131
132132
for the `PATH` changes to take effect.
133133
@@ -176,7 +176,7 @@ is pull the latest changes and rebuild as follows:
176176
cd $CAIRO_ROOT && git fetch && git pull && cargo build --all --release
177177
```
178178
179-
### Step 2: Add Cairo 1.0 executables to your path
179+
### Step 2: Add Cairo 1.0 Executables to Your Path
180180
181181
```bash
182182
export PATH="$CAIRO_ROOT/target/release:$PATH"

src/appendix-07-system-calls.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ extern fn get_block_hash_syscall(
3333

3434
Gets the hash of a specific StarkNet block within the range of `[first_v0_12_0_block, current_block - 10]`.
3535

36-
#### Return values
36+
#### Return Values
3737

3838
Returns the hash of the given block.
3939

40-
#### Error messages
40+
#### Error Messages
4141

4242
- `Block number out of range`: `block_number` is greater than _`current_block`_`- 10`.
4343
- `0`: `block_number` is less than the first block number of v0.12.0.
4444

45-
#### Common library
45+
#### Common Library
4646

4747
- [syscalls.cairo](https://github.com/starkware-libs/cairo/blob/0c882679fdb24a818cad19f2c18decbf6ef66153/corelib/src/starknet/syscalls.cairo#L37)
4848

@@ -66,11 +66,11 @@ In Cairo 1.0, all block/transaction/execution context getters are batched into t
6666

6767
None.
6868

69-
#### Return values
69+
#### Return Values
7070

7171
Returns a [struct](https://github.com/starkware-libs/cairo/blob/efbf69d4e93a60faa6e1363fd0152b8fcedbb00a/corelib/src/starknet/info.cairo#L8) containing the execution info.
7272

73-
#### Common library
73+
#### Common Library
7474

7575
- [syscalls.cairo](https://github.com/starkware-libs/cairo/blob/cca08c898f0eb3e58797674f20994df0ba641983/corelib/src/starknet/syscalls.cairo#L35)
7676

@@ -100,11 +100,11 @@ Calls a given contract. This system call expects the address of the called contr
100100
- _`entry_point_selector`_: A selector for a function within that contract, can be computed with the `selector!` macro.
101101
- _`calldata`_: The calldata array.
102102

103-
#### Return values
103+
#### Return Values
104104

105105
The call response, of type `SyscallResult<Span<felt252>>`.
106106

107-
#### Common library
107+
#### Common Library
108108

109109
- [syscalls.cairo](https://github.com/starkware-libs/cairo/blob/cca08c898f0eb3e58797674f20994df0ba641983/corelib/src/starknet/syscalls.cairo#L10)
110110

@@ -136,15 +136,15 @@ Deploys a new instance of a previously declared class.
136136
- _`calldata`_: The constructor’s calldata. An array of felts.
137137
- _`deploy_from_zero`_: A flag used for the contract address computation. If not set, the caller address will be used as the new contract’s deployer address, otherwise 0 is used.
138138

139-
#### Return values
139+
#### Return Values
140140

141141
A tuple wrapped with SyscallResult where:
142142

143143
- The first element is the address of the deployed contract, of type `ContractAddress`.
144144

145145
- The second element is the response array from the contract’s constructor, of type `Span::<felt252>`.
146146

147-
#### Common library
147+
#### Common Library
148148

149149
- [syscalls.cairo](https://github.com/starkware-libs/cairo/blob/4821865770ac9e57442aef6f0ce82edc7020a4d6/corelib/src/starknet/syscalls.cairo#L22)
150150

@@ -170,7 +170,7 @@ For more information and a higher-level syntax for emitting events, see [Starkne
170170

171171
- _`data`_: The event’s data.
172172

173-
#### Return values
173+
#### Return Values
174174

175175
None.
176176

@@ -189,7 +189,7 @@ values.append(3);
189189
emit_event_syscall(keys, values).unwrap_syscall();
190190
```
191191

192-
#### Common library
192+
#### Common Library
193193

194194
- [syscalls.cairo](https://github.com/starkware-libs/cairo/blob/cca08c898f0eb3e58797674f20994df0ba641983/corelib/src/starknet/syscalls.cairo#L30)
195195

@@ -217,11 +217,11 @@ This system call replaces the known delegate call functionality from Ethereum, w
217217

218218
- _`calldata`_: The calldata.
219219

220-
#### Return values
220+
#### Return Values
221221

222222
The call response, of type `SyscallResult<Span<felt252>>`.
223223

224-
#### Common library
224+
#### Common Library
225225

226226
- [syscalls.cairo](https://github.com/starkware-libs/cairo/blob/cca08c898f0eb3e58797674f20994df0ba641983/corelib/src/starknet/syscalls.cairo#L43)
227227

@@ -249,7 +249,7 @@ For more information, see Starknet’s [messaging mechanism](https://docs.starkn
249249

250250
- _`payload`_: The array containing the message payload.
251251

252-
#### Return values
252+
#### Return Values
253253

254254
None.
255255

@@ -264,7 +264,7 @@ payload.append(2);
264264
send_message_to_l1_syscall(payload).unwrap_syscall();
265265
```
266266

267-
#### Common library
267+
#### Common Library
268268

269269
- [syscalls.cairo](https://github.com/starkware-libs/cairo/blob/cca08c898f0eb3e58797674f20994df0ba641983/corelib/src/starknet/syscalls.cairo#L51)
270270

@@ -292,11 +292,11 @@ Once `replace_class` is called, the class of the calling contract (i.e. the cont
292292

293293
- _`class_hash`_: The hash of the class you want to use as a replacement.
294294

295-
#### Return values
295+
#### Return Values
296296

297297
None.
298298

299-
#### Common library
299+
#### Common Library
300300

301301
- [syscalls.cairo](https://github.com/starkware-libs/cairo/blob/cca08c898f0eb3e58797674f20994df0ba641983/corelib/src/starknet/syscalls.cairo#L77)
302302

@@ -324,7 +324,7 @@ For information on accessing storage by using the storage variables, see [storag
324324

325325
- _`address`_: The requested storage address.
326326

327-
#### Return values
327+
#### Return Values
328328

329329
The value of the key, of type `SyscallResult<felt252>`.
330330

@@ -339,7 +339,7 @@ let storage_address = storage_base_address_from_felt252(353453575475624637547542
339339
storage_read_syscall(0, storage_address).unwrap_syscall()
340340
```
341341

342-
#### Common library
342+
#### Common Library
343343

344344
- [syscalls.cairo](https://github.com/starkware-libs/cairo/blob/cca08c898f0eb3e58797674f20994df0ba641983/corelib/src/starknet/syscalls.cairo#L60)
345345

@@ -369,10 +369,10 @@ For information on accessing storage by using the storage variables, see [storag
369369

370370
- _`value`_: The value to write to the key.
371371

372-
#### Return values
372+
#### Return Values
373373

374374
None.
375375

376-
#### Common library
376+
#### Common Library
377377

378378
- [syscalls.cairo](https://github.com/starkware-libs/cairo/blob/cca08c898f0eb3e58797674f20994df0ba641983/corelib/src/starknet/syscalls.cairo#L70)

0 commit comments

Comments
 (0)