GithubHelp home page GithubHelp logo

iwueseiter / cairo-book Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cairo-book/cairo-book

0.0 0.0 0.0 19.17 MB

The Cairo Programming Language Book, a comprehensive documentation of the Cairo 1 programming language.

Home Page: https://book.cairo-lang.org/

License: MIT License

Shell 0.51% JavaScript 48.71% Rust 6.92% TypeScript 5.29% CSS 5.29% Handlebars 3.58% Cairo 29.71%

cairo-book's Introduction

English | 简体中文

All 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.

Created by builders, for builders 📜

Contribute

Setup

  1. Rust related packages:

    • Install toolchain providing cargo using rustup.
    • Install mdBook and the required extensions:
    cargo install mdbook mdbook-i18n-helpers mdbook-last-changed
    
  2. Host machine packages:

    • Install gettext for translations, usually available with regular package manager: sudo apt install gettext.
    • Install mdbook-quiz-cairo following the instructions here to be able to add interactive quizzes.
  3. Clone this repository.

  4. Install mdbook-cairo for Cairo code blocks

    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 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 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.

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-listings 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.

Setup

Firstly, you need to have scarb resolved in your path. See here 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:

cargo run --bin cairo-listings verify

Alternatively, you can also install the tool with:

cargo install --path cairo-listings

and then run:

cairo-listings 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 --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:

// TAG: <tag1>
// TAGS: <tag1>, <tag2>

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
Fricoben

🤔 🔍 📆
Mathieu
Mathieu

🤔 💻 🧑‍🏫 👀 📆 🚧 🔧
Nadai
Nadai

🌍
glihm
glihm

💻 🔧
Clément Walter
Clément Walter

👀
V.O.T
V.O.T

💻
Pia
Pia

💻 📝
cryptonerdcn
cryptonerdcn

🌍
Argetlames
Argetlames

🌍
julio4
julio4

💻 🔧
Haresh Gedia
Haresh Gedia

📖
Darlington Nnam
Darlington Nnam

💻
Tiago Neto
Tiago Neto

👀
omahs
omahs

💻
Shramee Srivastav
Shramee Srivastav

💻
Daniel Bejarano
Daniel Bejarano

💻
Tristan
Tristan

💻 🚧 👀
okhai.stark ( Tony Stark )
okhai.stark ( Tony Stark )

💻
shwang
shwang

💻
kwkr
kwkr

💻
ArnaudBD
ArnaudBD

💻
Jimmy Fate
Jimmy Fate

💻
SimplementeCao
SimplementeCao

💻
Lucas @ StarkWare
Lucas @ StarkWare

💻
Rémy Baranx
Rémy Baranx

💻
Steven Cordero
Steven Cordero

📖
Symmaque
Symmaque

📖 💻
Nenad Misić
Nenad Misić

📖 💻
Teddy Not Bear
Teddy Not Bear

📖
Malatrax
Malatrax

📖 💻

cairo-book's People

Contributors

enitrat avatar tadev0 avatar allcontributors[bot] avatar fricoben avatar cryptonerdcn avatar symmaque avatar julio4 avatar zarboq avatar remybar avatar kwkr avatar simplementecao avatar 0xeniotna avatar ametel01 avatar nadai2010 avatar glihm avatar okhaimie-dev avatar wenzhenxiang avatar tserg avatar th0rgal avatar boorich avatar giwook-han avatar friendlylifeguard avatar suiwater avatar gnart33 avatar gaetbout avatar trbutler4 avatar shramee avatar orangeryang avatar rodrigo-pino avatar sinsotec avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.