https://github.com/cairo-book/cairo-book
The Cairo Programming Language Book, a comprehensive documentation of the Cairo 1 programming language.
https://github.com/cairo-book/cairo-book
cairo cairo-lang documentation
Last synced: about 1 year ago
JSON representation
The Cairo Programming Language Book, a comprehensive documentation of the Cairo 1 programming language.
- Host: GitHub
- URL: https://github.com/cairo-book/cairo-book
- Owner: cairo-book
- License: mit
- Created: 2023-03-29T12:23:02.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-22T21:30:42.000Z (over 1 year ago)
- Last Synced: 2024-09-24T16:09:16.090Z (over 1 year ago)
- Topics: cairo, cairo-lang, documentation
- Language: JavaScript
- Homepage: https://book.cairo-lang.org/
- Size: 22.9 MB
- Stars: 226
- Watchers: 13
- Forks: 217
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cairo - The Cairo Book
README
English | [็ฎไฝไธญๆ](translations/README-cn.md)
[](#contributors)
The Cairo Programming Language Book
Alexandria
## Description
This repository contains the source of "The Cairo Programming Language" book, a comprehensive documentation of the Cairo 1 programming language. This documentation is your go-to resource for mastering Cairo, created and maintained by the Starknet community. You can read the book [online](https://book.cairo-lang.org/).
Created by builders, for builders ๐
## Contribute
### Setup
1. Rust related packages:
- Install toolchain providing `cargo` using [rustup](https://rustup.rs/).
- Install [mdBook](https://rust-lang.github.io/mdBook/guide/installation.html) and the required extensions:
```
cargo install mdbook mdbook-i18n-helpers mdbook-last-changed
```
2. Host machine packages:
- Install [gettext](https://www.gnu.org/software/gettext/) for translations, usually available with regular package manager: `sudo apt install gettext`.
- Install [mdbook-quiz-cairo](https://github.com/cairo-book/mdbook-quiz-cairo?tab=readme-ov-file) following the instructions [here](https://github.com/cairo-book/mdbook-quiz-cairo?tab=readme-ov-file#installation) to be able to add interactive quizzes.
3. Clone this repository.
4. Install mdbook-cairo to process references and labels, and custom tags.
```
cargo install --path mdbook-cairo
```
### Guidelines
Read the [CONTRIBUTING.md](./docs/CONTRIBUTING.md) file for more details on the style guide and guidelines for contributions to the book.
### Work locally (english, main language)
All the Markdown files **MUST** be edited in english. To work locally in english:
- Start a local server with `mdbook serve` and visit [localhost:3000](http://localhost:3000) to view the book.
You can use the `--open` flag to open the browser automatically: `mdbook serve --open`.
- Make changes to the book and refresh the browser to see the changes.
- Open a PR with your changes.
### Work locally (translations)
This book is targeting international audience, and aims at being gradually translated in several languages.
**All files in the `src` directory MUST be written in english**. This ensures that all the translation files can be
auto-generated and updated by translators.
To work with translations, these are the steps to update the translated content:
- Run a local server for the language you want to edit: `./translations.sh es` for instance. If no language is provided, the script will only extract translations from english.
- Open the translation file you are interested in `po/es.po` for instance. You can also use editors like [poedit](https://poedit.net/) to help you on this task.
- When you are done, you should only have changes into the `po/xx.po` file. Commit them and open a PR.
The PR must start with `i18n` to let the maintainers know that the PR is only changing translation.
The translation work is inspired from [Comprehensive Rust repository](https://github.com/google/comprehensive-rust/blob/main/TRANSLATIONS.md).
#### Initiate a new translation for your language
If you wish to initiate a new translation for your language without running a local server, consider the following tips:
- Execute the command `./translations.sh new xx` (replace `xx` with your language code). This method can generate the `xx.po` file of your language for you.
- To update your `xx.po` file, execute the command `./translations.sh xx` (replace `xx` with your language code), as mentioned in the previous chapter.
- If the `xx.po` file already exists (which means you are not initiating a new translation), you should not run this command.
### Verifying your Cairo Programs
The `cairo-listings` CLI tool is designed to wrap all Cairo and Starknet plugins for quickly verifying Cairo programs. You can verify that listings are correct with the `verify` argument, and generate the corresponding output with the `output` argument.
Install this tool with:
#### Setup
Firstly, you need to have `scarb` resolved in your path. See [here][installation] for more details.
To run the `cairo-listings` helper tool and verify Cairo programs, ensure that you are at the root of the repository (same directory of this `README.md` file), and run:
```sh
cargo run --bin cairo-listings verify
```
Alternatively, you can also install the tool with:
```sh
cargo install --path cairo-listings
```
and then run:
```sh
cairo-listings verify
```
[installation]: ./src/ch01-01-installation.md
#### Usage
The tool scans for all `*.cairo` files in the specified directory and performs the following actions:
For a Starknet contract:
- `scarb build`
- If it has tests: `scarb test`
Cairo program:
- If it has a `main` function: `scarb cairo-run --available-gas=200000000`
- Else, `scarb build`
- If it has tests: `scarb test`
- `scarb fmt -c`
To specify which tests to run, you can add a comment at the top of your file with the following format:
```cairo
// TAG:
// TAGS: ,
```
Here is a list of available tags:
- `does_not_compile`: don't run `scarb build`
- `does_not_run`: don't run `scarb cairo-run --available-gas=200000000`
- `ignore_fmt`: don't run `scarb fmt`
- `tests_fail`: don't run `scarb test`
The mdbook-cairo is a mdbook preprocessor that only removes the `// TAG` lines in code blocks.
## Contributors

Fricoben
๐ค ๐ ๐

Mathieu
๐ค ๐ป ๐งโ๐ซ ๐ ๐ ๐ง ๐ง

Nadai
๐

glihm
๐ป ๐ง

Clรฉment Walter
๐

V.O.T
๐ป

Pia
๐ป ๐

cryptonerdcn
๐

Argetlames
๐

julio4
๐ป ๐ง

Haresh Gedia
๐

Darlington Nnam
๐ป

Tiago Neto
๐

omahs
๐ป

Shramee Srivastav
๐ป

Daniel Bejarano
๐ป

Tristan
๐ป ๐ง ๐

okhai.stark ( Tony Stark )
๐ป

shwang
๐ป

kwkr
๐ป

ArnaudBD
๐ป

Jimmy Fate
๐ป

SimplementeCao
๐ป

Lucas @ StarkWare
๐ป

Rรฉmy Baranx
๐ป

Steven Cordero
๐

Symmaque
๐ ๐ป

Asher
๐ป

Nenad Misiฤ
๐ ๐ป

Teddy Not Bear
๐

Malatrax
๐ ๐ป

Beeyoung
๐ ๐ป

Charlotte
๐ ๐ป

Oba
๐

martin machiebe
๐

Jean-Michel
๐ ๐ป

Emmanuel A Akalo
๐ ๐ป

Supreme Labs
๐ ๐ป

blocksorcerer
๐ ๐ป

quentin-abei
๐ ๐ป

0xjarix
๐

kkawula
๐ ๐ป