Skip to content

Commit 813d7f5

Browse files
Merge pull request #6 from aayush-tripathi/docs/mdbook-setup
Docs/mdbook setup
2 parents ff92918 + a8f035a commit 813d7f5

17 files changed

Lines changed: 483 additions & 4 deletions

File tree

.github/workflows/mdbook.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Deploy Docs
2+
3+
on:
4+
push:
5+
branches: [master] # build on every push to master
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Install mdBook
13+
run: cargo install mdbook
14+
15+
- name: Build book
16+
run: mdbook build docs
17+
18+
# Upload the generated site as an artifact that Pages can deploy
19+
- uses: actions/upload-pages-artifact@v3
20+
with:
21+
path: docs/book
22+
23+
deploy:
24+
needs: build
25+
permissions:
26+
pages: write # to push to gh-pages
27+
id-token: write
28+
runs-on: ubuntu-latest
29+
environment:
30+
name: github-pages
31+
url: ${{ steps.deploy.outputs.page_url }}
32+
steps:
33+
- uses: actions/deploy-pages@v4
34+
id: deploy

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Rust build artifacts
22
target/
3-
tundra/target/
3+
tundra/target/
4+
# mdBook build output
5+
/docs/book/

docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
book

docs/book.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[book]
2+
title = "The Tundra Language Reference"
3+
author = "Aayush Tripathi"
4+
language = "en"
5+
description = "This book is a reference on the syntax and workig of Tundra!"
6+
[output.html]
7+
default-theme = "light"

docs/src/SUMMARY.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Summary
2+
3+
[Introduction](./intro.md)
4+
5+
- [Syntax Overview](./syntax.md)
6+
- [Literals](./literals.md)
7+
- [Operators](./operators.md)
8+
- [Control Flow](./control_flow.md)
9+
- [Functions & Classes](./functions.md)
10+
- [Standard Library](./stdlib.md)

docs/src/control_flow.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Control Flow
2+
3+
### `if` / `else`
4+
- Tundra supports regular `if`/`else` statements like python.
5+
- The condition must be wrapped around parenthesis
6+
```tundra
7+
if (condition):
8+
# true branch
9+
print("Yes")
10+
else:
11+
# false branch
12+
print("No")
13+
```
14+
15+
### `while`
16+
- Tundra supports regular `while` statements like python.
17+
- The condition must be wrapped around parenthesis
18+
```tundra
19+
var i = 0
20+
while (i < 5):
21+
print(i)
22+
i = i + 1
23+
```
24+
25+
### `for over range()`
26+
- Tundra supports regular `for` statements like python.
27+
```tundra
28+
for i in range(3):
29+
print(i)
30+
```
31+
32+
### `break` and `continue`
33+
- - Tundra supports regular `break` and `continue` statements like python.
34+
```tundra
35+
for i in range(10):
36+
if (i == 3):
37+
break
38+
if (i % 2 == 0):
39+
continue
40+
print(i)
41+
```
42+

docs/src/custom.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.book .navbar .title {
2+
font-size: 1.5em;
3+
background: url('../images/tundraLogo.png') no-repeat left center;
4+
padding-left: 1.5em;
5+
}
6+
7+
.book .content code {
8+
background-color: #f0f0f0;
9+
}

docs/src/functions.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Functions & Classes
2+
3+
## Function Declaration
4+
5+
```tundra
6+
fun add(a, b):
7+
return a + b
8+
```
9+
The functions in tundra follow a very pythonic syntax
10+
- Need to begin with `fun` keyword
11+
- Followed by function name and parameters
12+
- Colon to begin definition
13+
- Indent and followed by a regular code
14+
15+
### Example
16+
```tundra
17+
fun fib(n):
18+
if (n < 2):
19+
return n
20+
return fib(n - 1) + fib(n - 2)
21+
print(fib(10))
22+
23+
```
24+
#### Bytecode
25+
```bytecode
26+
== == Disassembled Bytecode == ==
27+
0000 Line 6 LoadConstant(0, Value { value: Function(RefCell { value: FunctionObject { name: "fib", arity: 1, chunk: RefCell { value: Chunk { code: [GetLocal(1, 0), Move(2, 1), LoadConstant(3, Value { value: Int(2) }), Less(4, 2, 3), JumpIfFalse(4, 2), GetLocal(3, 0), Return(3), GetGlobal(4, "fib"), GetLocal(3, 0), Move(2, 3), LoadConstant(5, Value { value: Int(1) }), Subtract(6, 2, 5), Move(5, 6), Call(5, 4, 1), Move(4, 5), GetGlobal(6, "fib"), GetLocal(2, 0), Move(7, 2), LoadConstant(8, Value { value: Int(2) }), Subtract(9, 7, 8), Move(7, 9), Call(8, 6, 1), Add(6, 4, 8), Return(6), Return(0)], constants: [], lines: [3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6], max_register: 10 } }, jitted: None } }) })
28+
0001 Line 6 DefineGlobal(0, "fib")
29+
0002 Line 6 GetGlobal(0, "fib")
30+
0003 Line 6 LoadConstant(1, Value { value: Int(10) })
31+
0004 Line 6 Call(2, 0, 1)
32+
0005 Line 6 Print(2)
33+
0006 Line 7 Return(2)
34+
```
35+
#### Output
36+
55
37+
---
38+
## Class Declaration
39+
40+
- To be implemented

docs/src/images/tundraLogo.png

64.5 KB
Loading

docs/src/intro.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Introduction
2+
3+
Welcome to **Tundra**!
4+
Tundra is a Python-like, register-based language implemented in Rust.
5+
This Wiki is here to help users use, understand and contribute to Tundra.

0 commit comments

Comments
 (0)