cairo-book
所属分类:编程语言基础
开发工具:Cairo
文件大小:0KB
下载次数:0
上传日期:2023-11-09 07:57:06
上 传 者:
sh-1993
说明: 开罗编程语言手册,开罗1编程语言的综合文档。
(The Cairo Programming Language Book, a comprehensive documentation of the Cairo 1 programming language.)
文件列表:
.all-contributorsrc (4804, 2024-01-06)
.idea/ (0, 2024-01-06)
.idea/alexandria.iml (336, 2024-01-06)
.idea/misc.xml (172, 2024-01-06)
.idea/modules.xml (272, 2024-01-06)
.idea/vcs.xml (167, 2024-01-06)
.tool-versions (12, 2024-01-06)
Cargo.lock (54221, 2024-01-06)
Cargo.toml (60, 2024-01-06)
LANGUAGES (15, 2024-01-06)
LICENSE (1067, 2024-01-06)
Scarb.lock (102, 2024-01-06)
Scarb.toml (119, 2024-01-06)
_typos.toml (107, 2024-01-06)
assets/ (0, 2024-01-06)
assets/alexandria.jpg (142760, 2024-01-06)
book.toml (669, 2024-01-06)
cairo-verify/ (0, 2024-01-06)
cairo-verify/Cargo.toml (480, 2024-01-06)
cairo-verify/src/ (0, 2024-01-06)
cairo-verify/src/cmd.rs (1697, 2024-01-06)
cairo-verify/src/config.rs (1503, 2024-01-06)
cairo-verify/src/error_sets.rs (912, 2024-01-06)
cairo-verify/src/logger.rs (1174, 2024-01-06)
cairo-verify/src/main.rs (5962, 2024-01-06)
cairo-verify/src/tags.rs (475, 2024-01-06)
cairo-verify/src/utils.rs (2115, 2024-01-06)
listings/ (0, 2024-01-06)
... ...
English | [简体中文](https://github.com/cairo-book/cairo-book/blob/master/translations/README-cn.md)
[![All Contributors](https://github.com/cairo-book/cairo-book/blob/master/https://img.shields.io/badge/all_contributors-17-orange.svg?style=flat-square)](https://github.com/cairo-book/cairo-book/blob/master/#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://github.com/cairo-book/cairo-book/blob/master/https://book.cairo-lang.org/).
Created by builders, for builders
## Contribute
### Setup
1. Rust related packages:
- Install toolchain providing `cargo` using [rustup](https://github.com/cairo-book/cairo-book/blob/master/https://rustup.rs/).
- Install [mdBook](https://github.com/cairo-book/cairo-book/blob/master/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://github.com/cairo-book/cairo-book/blob/master/https://www.gnu.org/software/gettext/) for translations, usually available with regular package manager:
`sudo apt install gettext`.
3. Clone this repository.
4. Install mdbook-cairo [for Cairo code blocks](https://github.com/cairo-book/cairo-book/blob/master/#work-locally-cairo-programs-verification)
```
cargo install --path mdbook-cairo
```
### 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](https://github.com/cairo-book/cairo-book/blob/master/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, those 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://github.com/cairo-book/cairo-book/blob/master/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 stars 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/cairo-book/cairo-book/blob/master/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.
### Work locally (Cairo programs verification)
The `cairo-verify` tool is designed to wrap all cairo and starknet plugins for quickly verifying cairo programs.
#### Setup
Firstly, you need to have `scarb` resolved in your path:
They should be available after installing cairo, see [here](https://github.com/cairo-book/cairo-book/blob/master/https://cairo-book.github.io/ch01-01-installation.html) for more details.
To run the `cairo-verify` helper tool, ensure that you are at the root of the repository (same directory of this `README.md` file), and run:
```sh
cargo run --bin cairo-verify
```
Alternatively, you can also install the tool with:
```sh
cargo install --path cairo-verify
```
#### 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`
- 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:
```rust
// 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`
- `ignore_fmt`: don't run `scarb fmt`
- `tests_fail`: don't run `scarb test`
You can skip and ignore a specific test by adding the corresponding flag:
```sh
$ cairo-verify --help
Usage: cairo-verify [OPTIONS]
Options:
-p, --path The path to explore for *.cairo files [default: ./listings]
-v, --verbose Print more information
-q, --quiet Only print final results
-f, --formats-skip Skip cairo-format checks
-s, --starknet-skip Skip starknet-compile checks
-c, --compile-skip Skip cairo-compile checks
-r, --run-skip Skip cairo-run checks
-t, --test-skip Skip cairo-test checks
--file Specify file to check
-h, --help Print help
-V, --version Print version
```
In CI, it's preferable to reduce output, so run `cairo-verify` with the `--quiet` flag.
The mdbook-cairo is a mdbook preprocessor that only removes the `// TAG` lines in code blocks.
## Contributors
近期下载者:
相关文件:
收藏者: