Skip to content

Commit bf29a0a

Browse files
committed
docs: installing packages.md
1 parent 79e9595 commit bf29a0a

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Installing packages from the gtp
2+
3+
The purpose of inflator is to let you create and install packages. The latter is easier so let's do that first.
4+
5+
The command for installing packages is `inflate install`
6+
7+
We are going to install a package (called a gobo) from the
8+
[gtp](https://github.com/inflated-goboscript/gtp/ "goboscript table of packages")
9+
10+
Let's install [cmath](https://github.com/inflated-goboscript/cmath "Gobo for complex number calculations") and use that.
11+
12+
??? Warning
13+
14+
There are [a few issues with some niche functions in cmath](https://github.com/inflated-goboscript/cmath/issues/2)
15+
16+
## Installing cmath
17+
18+
Inflator has a similar syntax to pip, so you just do `inflate install cmath`
19+
20+
If everything goes well, you should find it say `Installed cmath v1.0.1 by FAReTek1 into <appdata directory>`.
21+
It should also have installed `math`, which is a dependency of `cmath`.
22+
23+
Now that you have installed cmath, you now have to add it as a dependency in `inflator.toml`. Like so:
24+
25+
```toml
26+
# inflator.toml syntax documentation: https://github.com/inflated-goboscript/inflator#inflator
27+
name = "tutorial"
28+
version = "v0.0.0"
29+
username = "if this is left blank then -9999 aura 💀" # (1)
30+
31+
[dependencies]
32+
cmath = "cmath"
33+
```
34+
35+
1. You can change this to your username if it bothers you.
36+
37+
Now, run `inflate`. This will sync the packages and place them in the `inflator/` directory.
38+
39+
We can now `%include` cmath.
40+
41+
[//]: # (One day we might add a goboscript syntax highlighter, but not right now)
42+
```gs
43+
%include inflator/math # (1)
44+
%include inflator/cmath
45+
46+
47+
costumes "blank.svg";
48+
49+
onflag {
50+
say "Hello, World!";
51+
}
52+
```
53+
54+
1. Due to a [goboscript bug](https://github.com/aspizu/goboscript/issues/197), nested `%includes` is unstable. For now, you need to include every dependency separately.
55+
56+
!!! Note
57+
58+
If you ever want to update a package you are using, you can use `inflate install -U <pkg>` to upgrade it.
59+
60+
Let's use some complex math now:
61+
62+
```gs
63+
%include inflator/math
64+
%include inflator/cmath
65+
66+
67+
costumes "blank.svg";
68+
69+
onflag {
70+
Complex i = Complex(0, 1);
71+
72+
Complex result = c_pow(i, i);
73+
74+
say c_str(result);
75+
}
76+
```
77+
78+
This program demonstrates the result of doing `i` ** `i`. You may notice that the result is actually entirely real!

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ theme:
4949
- content.tabs.link
5050
- content.tooltips
5151
- navigation.footer
52+
- content.code.annotate
5253

5354
plugins:
5455
- social
@@ -128,3 +129,4 @@ nav:
128129
- Behaviour: inflator/behaviour.md
129130
- Usage:
130131
- Getting Started: inflator/usage/getting started.md
132+
- Installing Packages: inflator/usage/installing packages.md

0 commit comments

Comments
 (0)