Skip to content

Commit

Permalink
Merge pull request #10 from Tipbs/docs/language_mdbook
Browse files Browse the repository at this point in the history
Updated mdbook github action
  • Loading branch information
Tipbs authored Dec 19, 2023
2 parents 91b4031 + a288abe commit e838aaf
Show file tree
Hide file tree
Showing 14 changed files with 271 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/mdbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Sample workflow for building and deploying a mdBook site to GitHub Pages
#
# To get started with mdBook see: https://rust-lang.github.io/mdBook/index.html
#
name: Deploy mdBook site to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["dev", "main"]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
env:
MDBOOK_VERSION: 0.4.36
steps:
- uses: actions/checkout@v4
- name: Install mdBook
run: |
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh
rustup update
cargo install --version ${MDBOOK_VERSION} mdbook
- name: Setup Pages
id: pages
uses: actions/configure-pages@v4
- name: Build with mdBook
run: mdbook build docs/language-doc
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: ./docs/language-doc/book

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ cabal.project.local~
compile_commands.json
glados-exe
glados-exe.cabal
book/
6 changes: 6 additions & 0 deletions docs/language-doc/book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[book]
authors = ["MizuriGit"]
language = "en"
multilingual = false
src = "src"
title = "Documentation of our super language"
12 changes: 12 additions & 0 deletions docs/language-doc/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Summary

- [Introduction](./introduction.md)
- [Getting started](./getting_started.md)
- [Hello world!](./hello_world.md)
- [Compile and run your program](./compile_and_run.md)
- [Go further](./syntax.md)
- [Variables](./variables.md)
- [Function that returns a value](./function_with_return.md)
- [Conditions](./conditions.md)
- [If Statements](./if_statements.md)
- [Lists](./lists.md)
31 changes: 31 additions & 0 deletions docs/language-doc/src/compile_and_run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Compile and run your program

Now that we have our file `main.???`, we'll have to compile it using GLaDOS

### Compile using GLaDOS

Compiling is pretty straight forward, all we need to do is to give our file to the GLaDOS program and use the `-c` argument

Let's compile our file `main.???`:

```bash
> ./GLaDOS -c main.???
```

Well done! Look, there is a new file in our directory:

```bash
> ls
main.??? exectuable
```

### Run using GLaDOS

Now that you have your executable, you need to use the VM in the GLaDOS program.

To do so, use this command:

```bash
> ./GLaDOS -r executable
Hello world!
```
19 changes: 19 additions & 0 deletions docs/language-doc/src/conditions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Conditions

This language cover a various number of operators returning boolean values

- `a < b` less than
- `a <= b` less than or equal to
- `a > b` greater thané
- `a >= `greater than or equal to b
- `a == b` equal to
- `a != b` not equal to

Their use is pretty straight forward, you can get the boolean value and store it as a variable or use it in **if statements**

```
var value = 1 == 2;
// value == false
```

As we said earlier, they can be use in **if statements**, check out next page...
29 changes: 29 additions & 0 deletions docs/language-doc/src/function_with_return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Function that returns a value

As said on the [Hello world! page](./hello_world.md), functions can return value that can be used or stored in a variable.

#### **`main.???`**
```
int sum(x, y)
{
return x + y;
}
int main(argc, argv)
{
var x = 5;
var y = 8;
var z = sum(x, y);
print(z)
print(z + sum(z, x))
}
```

To learn how to compile the file, [check this out!](./compile_and_run.md)

```
> ./GLaDOS -r executable
13
18
```
1 change: 1 addition & 0 deletions docs/language-doc/src/getting_started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Getting started
39 changes: 39 additions & 0 deletions docs/language-doc/src/hello_world.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Hello world!

We'll start off by writing a simple hello world.

### But first, we'll learn how to create a function.

```
fn foobar(a, b)
{
...
}
```
- `fn` tells the code that a function is being created.
- `foobar` is the name of the function, choose whatever you want.
- `(a, b)` are the function arguments, define them using the parenthesis, then give them a name (here `a` and `b`)
- `{ ... }` open the function, that's where your code will go

Functions can also return a value using the `return` keyword followed by a value (example: `return 4`.

### Alright, now that you know how to create a function, let's introduce the `main` function.

The `main` function is the function that is being executed first, so if we want to write a Hello world!, then we'll have to create a main function:

#### **`main.???`**
```
fn main(argc, argv)
{
print("Hello world!\n");
}
```
There you go, Hello world!

The `main` function takes 2 arguments:
- `argc`, being the number of arguments passed from the command line
- `argv`, being an array containing the arguments passed from the command line

The `print` function takes 1 argument, here a string, that is gonna be written to the screen. The `\n` at the end of the string means that we want to add a new-line at after the text.

Now that we have created our `main` function printing "Hello world!" to the terminal, we need to compile and run our code, head up to the next part to learn how!
32 changes: 32 additions & 0 deletions docs/language-doc/src/if_statements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# If Statements

Usage of if statements is pretty straight forward and easy to use.

```
if (condition) {
...
} else {
...
}
```

If you'd like to see a real example

#### **`main.???`**
```
fn main(argc, argv)
{
if (4 > 9) {
print("It is true!")
} else {
print("It is false!")
}
}
```

To learn how to compile the file, [check this out!](./compile_and_run.md)

```sh
> ./GLaDOS -r executable
It is false!
```
1 change: 1 addition & 0 deletions docs/language-doc/src/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Introduction
20 changes: 20 additions & 0 deletions docs/language-doc/src/lists.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Lists

Lists are used to store multiple arguments in 1 variable, in the format of an array.

#### **`main.???`**
```
int main(argc, argv)
{
var littleList = [1, "salut", "hey"];
print(littleList);
}
```

To learn how to compile the file, [check this out!](./compile_and_run.md)

```
> ./GLaDOS -r executable
[1, "salut", "hey"]
```
3 changes: 3 additions & 0 deletions docs/language-doc/src/syntax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Go further

In this page we'll cover some exemple to discover the syntax of this language.
20 changes: 20 additions & 0 deletions docs/language-doc/src/variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Variables

To create a variable, you need to use the keyword `var` and set a value. You don't need to precise the type of your variable, the language will process it and guess the type.

#### **`main.???`**
```
fn main(argc, argv)
{
var value = 4;
print(value);
}
```

To learn how to compile the file, [check this out!](./compile_and_run.md)

```sh
> ./GLaDOS -r executable
4
```

0 comments on commit e838aaf

Please sign in to comment.