Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit 7c18bea

Browse files
Feat: Upgrade to vocs static site generator (#256)
* feat: migrate frontend framework from mdbook to vocs (#185) * feat: migration to vocs * Update CONTRIBUTING.md * Update README.md * fix: pr review requested changes * temp: remove pages * chore: Anchors in listings * feat: voc sidebar config * feat: migrate listings and book to vocs * chore: npm -> pnpm * ci/cd: fix build * feat: footer * feat: add tailwindcss * feat: styling and configuration * feat: mathjax support * feat: collapsible sidebar css * ci/cd: remove mdbook workflow * feat: cairo syntax hl * style: minor improvements * fix: mdbook leftover anchors * feat: collapsible sidebar * feat: themes, inline highlighting, minor fixes * ci/cd: add .npmrc file --------- Co-authored-by: Kushagra Sarathe <76868364+kushagrasarathe@users.noreply.github.com>
1 parent 67db631 commit 7c18bea

193 files changed

Lines changed: 8753 additions & 27593 deletions

File tree

Some content is hidden

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

.github/workflows/install-mdbook/action.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/mdbook.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

.github/workflows/setup-rust-cache/action.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.gitignore

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
book
2-
target
3-
output
1+
node_modules
2+
.env
3+
dist/*
44

55
# Editors tmp files.
66
*~
@@ -11,4 +11,10 @@ output
1111
.vscode/settings.json
1212
**/starkli-wallet
1313

14-
node_modules
14+
# From previous mdbook build
15+
book/*
16+
target/*
17+
src/**/*.md
18+
19+
node_modules
20+

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node-linker=hoisted

CONTRIBUTING.md

Lines changed: 42 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ Please note we have a code of conduct, please follow it in all your interactions
1111
- [Contributing](#contributing)
1212
- [Table of Contents](#table-of-contents)
1313
- [Setup](#setup)
14-
- [MdBook](#mdbook)
14+
- [Working with Markdown Files](#working-with-markdown-files)
1515
- [Adding a new chapter](#adding-a-new-chapter)
1616
- [Adding a new Cairo program](#adding-a-new-cairo-program)
1717
- [Verification script](#verification-script)
1818
- [Tests](#tests)
19-
- [Use of anchor](#use-of-anchor)
20-
- [Translations](#translations)
21-
- [Initiate a new translation for your language](#initiate-a-new-translation-for-your-language)
19+
- [Use of region](#use-of-region)
2220
- [Code of Conduct](#code-of-conduct)
2321
- [Our Pledge](#our-pledge)
2422
- [Our Standards](#our-standards)
@@ -31,33 +29,41 @@ Please note we have a code of conduct, please follow it in all your interactions
3129

3230
1. Clone this repository.
3331

34-
2. Rust related packages:
32+
2. Install the required dependencies using pnpm:
3533

36-
- Install toolchain providing `cargo` using [rustup](https://rustup.rs/).
37-
- Install [mdBook](https://rust-lang.github.io/mdBook/guide/installation.html) and the required extension with `cargo install mdbook mdbook-i18n-helpers mdbook-last-changed `.
34+
```
35+
pnpm i
36+
```
3837

3938
3. Install `scarb` using [asdf](https://asdf-vm.com/) with `asdf install`. Alternatively, you can install `scarb` manually by following the instructions [here](https://docs.swmansion.com/scarb/).
4039

41-
## MdBook
40+
4. Start the development server:
4241

43-
All the Markdown files **MUST** be edited in english. To work locally in english:
42+
```
43+
pnpm dev
44+
```
4445

45-
- Start a local server with `mdbook serve` and visit [localhost:3000](http://localhost:3000) to view the book.
46-
You can use the `--open` flag to open the browser automatically: `mdbook serve --open`.
46+
## Working with Markdown Files
4747

48-
- Make changes to the book and refresh the browser to see the changes.
48+
All Markdown files (\*.md) MUST be edited in English. Follow these steps to work locally with Markdown files:
4949

50-
- Open a PR with your changes.
50+
- Make changes to the desired .md files in your preferred text editor.
51+
- Save the changes, and your browser window should automatically refresh to reflect the updates.
52+
- Once you've finished making your changes, build the application to ensure everything works as expected:
53+
```
54+
pnpm build
55+
```
56+
- If everything looks good, commit your changes and open a pull request with your modifications.
5157

5258
## Adding a new chapter
5359

54-
To add a new chapter, create a new markdown file in the `src` directory. All the Markdown files **MUST** be edited in english. In order to add them to the book, you need to add a link to it in the `src/SUMMARY.md` file.
60+
- To add a new chapter, create a new markdown file in the `pages` directory. All the Markdown files **MUST** be edited in english. In order to add them to the book, you need to add in the `vocs.config.ts` file.
5561

56-
Do not write directly Cairo program inside the markdown files. Instead, use code blocks that import the Cairo programs from the `listing` directory. These programs are bundled into scarb projects, which makes it easier to test and build all programs. See the next section for more details.
62+
- Do not write directly Cairo program inside the markdown files. Instead, use code blocks that import the Cairo programs from the `listings` directory. These programs are bundled into scarb projects, which makes it easier to test and build all programs. See the next section for more details.
5763

5864
Be sure to check for typos with `typos`:
5965

60-
```shell
66+
```bash [Terminal]
6167
cargo install typos-cli
6268
typos src/
6369
```
@@ -159,7 +165,8 @@ Every listing needs to have atleast integration tests:
159165

160166
Add your contract in a specific file, you can name it `contract.cairo` or anything else. You can also add other files if needed.
161167

162-
You should add the tests in the same file as the contract, using the `#[cfg(test)]` flag and a `tests` module. With the usage of ANCHOR, the tests will not be displayed in the book but can be optionally be displayed by using the `{{#rustdoc_include ...}}` syntax.
168+
You should add the tests in the same file as the contract, using the `#[cfg(test)]` flag and a `tests` module.
169+
<!-- With the usage of ANCHOR, the tests will not be displayed in the book but can be optionally be displayed by using the `{{#rustdoc_include ...}}` syntax. -->
163170

164171
Here's a sample `lib.cairo` file:
165172

@@ -171,9 +178,9 @@ mod contract;
171178
And in the `contract.cairo` file:
172179

173180
```cairo
174-
// ANCHOR: contract
181+
// [!region contract]
175182
// Write your contract here
176-
// ANCHOR_END: contract
183+
// [!endregion contract]
177184
178185
#[cfg(test)]
179186
mod tests {
@@ -183,27 +190,26 @@ mod tests {
183190

184191
You can use Starknet Foundry to write and run your tests.
185192

186-
### Use of anchor
193+
### Use of region
187194

188195
You can add delimiting comments to select part of the code in the book.
189196

190197
```cairo
191198
file.cairo:
192199
193200
a
194-
// ANCHOR: anchor_name
201+
// [!region region_name]
195202
b
196-
// ANCHOR_END: anchor_name
203+
// [!endregion region_name]
197204
c
198205
```
199206

200207
Then, in the markdown file, you can use the following syntax to include only the code between the delimiting comments:
201208

202209
````markdown
203-
````cairo
204-
{{#include ../../listings/path/to/listing/src/contract.cairo:anchor_name}}
205-
\```
206-
````
210+
```cairo
211+
// [!include ~/listings/src/contract.cairo:region_name]
212+
```
207213
````
208214

209215
This will result in the following code being included in the book:
@@ -212,39 +218,21 @@ This will result in the following code being included in the book:
212218
b
213219
```
214220

215-
Using `#rustdoc_include` you can have the same result, but users can expand the code in the book to see the whole file (used for showing tests):
221+
To render code in tabs format you can use `:::code-group`. Example you can render contract and tests in separate tabs like this:
216222

217-
````markdown
218-
````cairo
219-
{{#rustdoc_include ../../listings/path/to/listing/src/contract.cairo:anchor_name}}
220-
\```
221223
````
222-
````
223-
224-
## Translations
224+
:::code-group
225225
226-
> Translations efforts are currently on hold. If you are interested in helping out, please send a message in the telegram channel.
226+
```cairo [contract]
227+
// [!include ~/listings/src/contract.cairo:contract]
228+
```
227229
228-
To work with translations, those are the steps to update the translated content:
230+
```cairo [tests]
231+
// [!include ~/listings/src/contract.cairo:tests]
232+
```
229233
230-
- Run a local server for the language you want to edit: `./translations.sh zh-cn` for instance. If no language is provided, the script will only extract translations from english.
231-
232-
- Open the translation file you are interested in `po/zh-cn.po` for instance. You can also use editors like [poedit](https://poedit.net/) to help you on this task.
233-
234-
- When you are done, you should only have changes into the `po/xx.po` file. Commit them and open a PR.
235-
The PR must stars with `i18n` to let the maintainers know that the PR is only changing translation.
236-
237-
The translation work is inspired from [Comprehensive Rust repository](https://github.com/google/comprehensive-rust/blob/main/TRANSLATIONS.md).
238-
239-
You can test to build the book with all translations using the `build.sh` script and serve locally the `book` directory.
240-
241-
### Initiate a new translation for your language
242-
243-
If you wish to initiate a new translation for your language without running a local server, consider the following tips:
244-
245-
- 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.
246-
- To update your `xx.po` file, execute the command `./translations.sh xx` (replace `xx` with your language code), as mentioned in the previous chapter.
247-
- If the `xx.po` file already exists (which means you are not initiating a new translation), you should not run this command.
234+
:::
235+
````
248236

249237
## Code of Conduct
250238

LANGUAGES

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@ Please refer to the Contribution Guidelines page:
1010
- [Contributing](CONTRIBUTING.md#contributing)
1111
- [Table of Contents](CONTRIBUTING.md#table-of-contents)
1212
- [Setup](CONTRIBUTING.md#setup)
13-
- [MdBook](CONTRIBUTING.md#mdbook)
13+
- [Working with Markdown Files](CONTRIBUTING.md#working-with-markdown-files)
1414
- [Adding a new chapter](CONTRIBUTING.md#adding-a-new-chapter)
1515
- [Adding a new Cairo program](CONTRIBUTING.md#adding-a-new-cairo-program)
16-
- [Verification script](CONTRIBUTING.md#verification-script)
1716
- [Tests](CONTRIBUTING.md#tests)
18-
- [Use of anchor](CONTRIBUTING.md#use-of-anchor)
19-
- [Translations](CONTRIBUTING.md#translations)
20-
- [Initiate a new translation for your language](CONTRIBUTING.md#initiate-a-new-translation-for-your-language)
17+
- [Use of region](CONTRIBUTING.md#use-of-region)
2118
- [Code of Conduct](CONTRIBUTING.md#code-of-conduct)
2219
- [Our Pledge](CONTRIBUTING.md#our-pledge)
2320
- [Our Standards](CONTRIBUTING.md#our-standards)
2421
- [Our Responsibilities](CONTRIBUTING.md#our-responsibilities)
2522
- [Scope](CONTRIBUTING.md#scope)
2623
- [Enforcement](CONTRIBUTING.md#enforcement)
27-
- [Attribution](CONTRIBUTING.md#attribution)
24+
- [Attribution](CONTRIBUTING.md#attribution)

Scarb.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ members = [
33
"listings/getting-started/*",
44
"listings/applications/*",
55
"listings/advanced-concepts/*",
6-
"listings/templates/*",
6+
"listings/cairo_cheatsheet",
77
]
88

99
[workspace.scripts]

book.toml

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)