Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various documentation additions #1811

Merged
merged 24 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2d00f7f
Core\when?: added deprecation notice
drkameleon Nov 23, 2024
19e37fa
fixed In a nutshell guide
drkameleon Nov 23, 2024
0090613
update syntax for character literals
drkameleon Nov 23, 2024
fc3cbfd
minor fixes re: Paths + more examples for PathLabels
drkameleon Nov 23, 2024
e66472a
added better example for right-to-left evaluation rules
drkameleon Nov 23, 2024
e7cd5ff
update function scope explanation
drkameleon Nov 23, 2024
3f7a25e
fixed documentation re: syntax sugar
drkameleon Nov 23, 2024
41e5fe8
added extra example for custom types
drkameleon Nov 23, 2024
9b7e41b
added documentation for `\shortcut` labels
drkameleon Nov 23, 2024
e570f2f
added example for Rational literals
drkameleon Nov 23, 2024
c3fc2d3
added section for Range values
drkameleon Nov 23, 2024
745cc28
added documentation for methods, including Magic methods
drkameleon Nov 23, 2024
202e997
added complete list of recognized symbols
drkameleon Nov 23, 2024
1838758
added better example for Bytecode
drkameleon Nov 23, 2024
b2440e1
minor fix
drkameleon Nov 23, 2024
b3e06e0
added documentation for Unit & Quantity values
drkameleon Nov 23, 2024
dc1fec3
added documentation for Exclamation-mark operator
drkameleon Nov 23, 2024
89e7eff
restructured the whole document
drkameleon Nov 23, 2024
89428d7
added documentation for Object values
drkameleon Nov 23, 2024
28cb1fc
added documentation for Socket values
drkameleon Nov 23, 2024
54a0dc9
added documentation for Store values
drkameleon Nov 23, 2024
3202aa4
minor edits + added documentatin for Path literals
drkameleon Nov 23, 2024
335f7b4
updated package-related documentation
drkameleon Nov 23, 2024
9954cda
minor edit
drkameleon Nov 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 24 additions & 34 deletions docs/website/pages/documentation/command line.art
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ The command line is where the whole journey starts: whether you want to try out
* [Start the interactive console](#start-the-interactive-console)
* [Working with bytecode](#working-with-bytecode)
- [Package manager](#package-manager)
* [List available modules](#list-available-modules)
* [List remote modules](#list-remote-modules)
* [Get module info](#get-module-info)
* [Install a new module](#install-a-new-module)
* [Uninstall a module](#uninstall-a-module)
* [Update existing modules](#update-existing-modules)
* [List available packages](#list-available-packages)
* [List remote packages](#list-remote-packages)
* [Install a new package](#install-a-new-package)
* [Uninstall a package](#uninstall-a-package)
* [Update all packages](#update-all-packages)

---

Expand Down Expand Up @@ -66,63 +65,54 @@ This will output a `path/to/your/script.art.bcode` file.
arturo -x path/to/your/script.art.bcode
```

<h3 id="package-manager">Package manager <span class="tag is-danger">Experimental</span></h3>
<h3 id="package-manager">Package manager</h3>

Although Arturo's philosophy is batteries-included - so you'll most likely need nothing that is not already included - Arturo also comes with a ready-to-use package manager, to make your life even easier.

<h4 id="list-available-modules">List available modules</h4>
<h4 id="list-available-packages">List available packages</h4>

To list all available modules, just type:
To list all available packages, just type:

```bash
arturo -m list
arturo -p list
```

This will show you all the modules you have installed locally.
This will show you all the packages you have installed locally.)

It looks like this:
<h4 id="list-remote-packags">List remote packages</h4>

![Module listing](https://arturo-lang.io/resources/images/module_list.png)

<h4 id="list-remote-modules">List remote modules</h4>

If you want to fetch a list of *all* modules available to download from the [official repository](https://github.com/arturo-lang/art-modules), just type:
If you want to fetch a list of *all* packages available to download from the [official repository](https://pkgr.art), just type:

```bash
arturo -m remote
arturo -p remote
```

<h4 id="get-module-info">Get module info</h4>
<h4 id="install-a-new-package">Install a new package</h4>

Have you spotted a module you like and want to know more about it? That's easy:
To install a package

```bash
arturo -m info html
arturo -p install grafito
```

<h4 id="install-a-new-module">Install a new module</h4>

When you have finally decided you want to install a module, it's also easy:
> 💡 If you do e.g. `import 'grafito!` from within the REPL or your Arturo script, if the package isn't already installed, it'll automatically be taken care of - so, nothing to worry about! ;-)

```bash
arturo -m install html
```

<h4 id="uninstall-a-module">Uninstall a module</h4>
<h4 id="uninstall-a-package">Uninstall a package</h4>

In order to uninstall a module you have previously, you just have to type:
In order to uninstall a package you have previously, you just have to type:

```bash
arturo -m uninstall html
arturo -p uninstall grafito
```

<h4 id="update-existing-modules">Update existing modules</h4>
<h4 id="update-all-packages">Update all packages</h4>

If you want to update all of your local modules, there's no reason to uninstall/reinstall anything. Just type:
If you want to update all of your local packages, there's no reason to uninstall/reinstall anything. Just type:

```bash
arturo -m update
arturo -p update
```

And *all* of your modules will be automatically up-to-date.
And *all* of your packages will be automatically up-to-date.
}
77 changes: 58 additions & 19 deletions docs/website/pages/documentation/in a nutshell.art
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ c3: {:
:}

; characters
ch: `c`
ch: 'c'

; blocks/arrays
d: [1 2 3]
Expand All @@ -59,11 +59,23 @@ g2: #0077BF
; dates
h: now ; 2021-05-03T17:10:48+02:00

; versions

currentVersion: 3.2.10-beta ; SemVer compatible :)

; logical values
i1: true
i2: false
i3: maybe

; units
meters: `m
kilograms: `kg

; quantities
height: 3`yd
width: 4`m

;---------------------------------
; BASIC OPERATORS
;---------------------------------
Expand Down Expand Up @@ -127,23 +139,47 @@ and? [1=2][2<3] ; => false
if 2 > 1 [ print "yes!"] ; yes!
if 3 <> 2 -> print "true!" ; true!

; if/else statements
; note it's 'if?' not 'if'
if? 2 > 3 -> print "2 is greater than 3"
else -> print "2 is not greater than 3" ; 2 is not greater than 3

; switch statements
switch 2 > 3 -> print "2 is greater than 3"
-> print "2 is not greater than 3" ; 2 is not greater than 3

a: (2 > 3)?["yes"]["no"] ; a: "no"
a: (2 > 3)? -> "yes" -> "no" ; a: "no" (exactly the same as above)
a: (2 > 3)? -> "yes" -> "no" ; a: "no" (exactly the same as above)

; case statements
key: "one"

; case/when statements
case [1]
when? [>2] -> print "1 is greater than 2. what?!"
when? [<0] -> print "1 is less than 0. nope..."
else -> print "here we are!" ; here we are!
case key [ ; the main block is always evaluated!
"one" -> print "key is one!"
"two" -> print "key is two!"
any -> print "key is none of the above"
]

; when statements
when [ ; the main block is always evaluated!
prime? 4 -> print "yes, 4 is prime - wait, what?!"
prime? 5 -> print "yes, 5 is prime
prime? 7 -> print "yes, 6 is prime
true -> print "none of the above was true"
]
; yes, 5 is prime

when.any [ ; cascade-style checking (without breaking)
prime? 4 -> print "yes, 4 is prime - wait, what?!"
prime? 5 -> print "yes, 5 is prime"
prime? 7 -> print "yes, 7 is prime"
]
; yes, 5 is prime
; yes, 7 is prime

x: 2
when.has: x [ ; prepends passed parameter to each block/condition
[=0] -> print "x is zero!"
[<1] -> print "x is less than 1"
[<4] -> print "x is less than 4"
true -> print "x is >= 4"
]
; x is less than 4

;---------------------------------
; LOOPS
Expand Down Expand Up @@ -173,7 +209,7 @@ loop 1..3 'x -> ; since it's a single statement
print x ; there's no need for [block] notation
; we can wrap it up using the `->` syntactic sugar

loop `a`..`c` 'ch ->
loop 'a'..'c' 'ch ->
print ch
; a
; b
Expand All @@ -198,7 +234,7 @@ loop dict [key value][
; age -> 34

; while loops
i: new 0
i: 0
while [i<3][
print ["i =" i]
inc 'i
Expand Down Expand Up @@ -297,14 +333,17 @@ arr\0: "nada"
set arr 2 "dos"
print arr ; nada one dos three

z: 2
arr\[z]: "dos" ; would have the same effect

; adding elements to an array
arr: new []
arr: []
'arr ++ "one"
'arr ++ "two"
print arr ; one two

; remove elements from an array
arr: new ["one" "two" "three" "four"]
arr: ["one" "two" "three" "four"]
'arr -- "two" ; arr: ["one" "three" "four"]
remove 'arr .index 0 ; arr: ["three" "four"]

Expand All @@ -327,7 +366,7 @@ sort.descending arr ; => [5 4 3 2 1]
; mapping values
map 1..10 [x][2*x] ; => [2 4 6 8 10 12 14 16 18 20]
map 1..10 'x -> 2*x ; same as above
map 1..10 => [2*&] ; same as above
map 1..10 => [2 * &] ; same as above
map 1..10 => [2*] ; same as above

; selecting/filtering array values
Expand Down Expand Up @@ -400,8 +439,8 @@ sayHello: function [this :person][
]

; create new objects of our custom type
a: to :person ["John" "Doe" 34] ; let's create 2 "Person"s
b: to :person ["jane" "Doe" 33] ; and another one
a: to :person ["John" "Doe" 34]! ; let's create 2 "Person"s
b: to :person ["jane" "Doe" 33]! ; and another one

; call pseudo-inner method
sayHello a ; Hello John
Expand Down
Loading
Loading