Skip to content

feat: Backport doc improvements for 0.7 #395

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

Merged
merged 1 commit into from
Apr 27, 2025
Merged
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -13,6 +13,11 @@ jobs:
- name: Checkout project
uses: actions/checkout@v2

- name: Clean previous docs
run: |
rm -rf ./src/stdlib/*/
rm -rf ./src/stdlib/*.md
Comment on lines +18 to +19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a package.json script instead? This may require rimraf or something of the like.

Copy link
Member Author

@spotandjake spotandjake Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this makes a lot of sense, just because we don't have any matching scripts to generate the stdlib docs in the package.json we would only have cleanStdlibDocs or something.

(This will also only be around for a little while until we merge v2)

- name: Replace download links
# This checks the "grain" prefix so our preview links aren't updated
run: |
11 changes: 11 additions & 0 deletions src/builtin_types.md
Original file line number Diff line number Diff line change
@@ -102,6 +102,17 @@ type Rational

The type of Grain rationals, e.g. `2/3r`. Rationals are represented as a numerator and denominator.

### **Range**

```grain
record Range<a> {
rangeStart: a,
rangeEnd: a
}
```

A range of values, with a start and end value.

### **Number**

```grain
2 changes: 1 addition & 1 deletion src/getting_grain.md
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ See the [plugin](https://github.com/cometkim/asdf-grain) for more details.

To get access to the entirely native compiler, you can build Grain from source.

First, you'll need [Node.js](https://nodejs.org/en/download/current/) v16.
First, you'll need [Node.js](https://nodejs.org/en/download/current/) v22.

Start by cloning the Grain repository:

4 changes: 3 additions & 1 deletion src/guide/collections_and_libraries.md
Original file line number Diff line number Diff line change
@@ -115,7 +115,9 @@ In some cases, this could allow us to write programs that are more efficient tha
However, the size of an array is fixed. To add additonal items to an array, we must append them together, which would create a brand new, third array:

```grain
import Array from "array"
module Main
from "array" include Array
let one = [> 1]
let twoThree = [> 2, 3]
2 changes: 1 addition & 1 deletion src/guide/loops.md
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ while (true) {
```grain
module Main
import Array from "array"
from "array" include Array
let strings = [> "foo", "bar", "baz"]
2 changes: 1 addition & 1 deletion src/guide/mutation.md
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ It is also possible to create a binding with the same name as an existing bindin
module Main
let val = 1
let val = 2 // `val` now refers a new value
let val = 2 // `val` now refers to a new value
```

It is important to note that shadowing does not modify what the shadowed binding refers to, but rather makes a new association for a binding name within the scope:
6 changes: 5 additions & 1 deletion src/index.md
Original file line number Diff line number Diff line change
@@ -10,4 +10,8 @@ Grain is a programming language that brings wonderful features from academic and

## The WebAssembly Bits

One of the most exciting things about Grain is that it compiles to WebAssembly. As such, Grain can run in the browser, on your computer, on a server, and potentially elsewhere. This guide will largely focus on the browser and terminal.
One of the most exciting things about Grain is that it compiles to WebAssembly. As such, Grain can run in the browser, on your computer, on a server, and potentially elsewhere. This guide will largely focus on the browser and terminal.

## Getting additional help

If something isn't making sense or you have more questions, reach out in the `#support` channel on the [Grain Discord server](https://discord.com/invite/grain-lang). There are a bunch of friendly folks happy to help out!
11 changes: 6 additions & 5 deletions src/tooling/grain_cli.md
Original file line number Diff line number Diff line change
@@ -25,13 +25,14 @@ All of the supported flags can be found below:
| Flag | Description |
| ----------------------------- | --------------------------------------------------------------------------- |
| -I, --include-dirs <dirs> | add additional dependency include directories |
| -S, --stdlib <path> | override the standard libary with your own |
| -S, --stdlib <path> | override the standard library with your own |
| -o <filename> | output filename |
| --initial-memory-pages <size> | initial number of WebAssembly memory pages |
| --maximum-memory-pages <size> | maximum number of WebAssembly memory pages |
| --compilation-mode <mode> | compilation mode (advanced use only) |
| --import-memory | import the memory from `env.memory` |
| --elide-type-info | don't include runtime type information used by toString/print |
| --release | compile using the release profile (production mode) |
| --experimental-wasm-tail-call | enables tail-call optimization |
| --no-wasm-tail-call | disables tail-call optimization |
| --debug | compile with debugging information |
| --wat | additionally produce a WebAssembly Text (.wat) file |
| --hide-locs | hide locations from intermediate trees. Only has an effect with `--verbose` |
@@ -40,9 +41,9 @@ All of the supported flags can be found below:
| --no-bulk-memory | polyfill WebAssembly bulk memory instructions |
| --wasi-polyfill <filename> | path to custom WASI implementation |
| --use-start-section | replaces the \_start export with a start section during linking |
| --single-file | compile a single file without compiling |
| --no-link | disable static linking |
| --no-pervasives | don't automatically import the Grain Pervasives module |
| --parser-debug-level <level> | debugging level for parser output |
| --memory-base <addr> | set the base address for the Grain heap |
| --source-map | generate source maps |
| --strict-sequence | enable strict sequencing |
@@ -51,7 +52,7 @@ All of the supported flags can be found below:

## `grain run`

Runs a WebAssembly file. The `grain run` command can run Grain programs compiled with `--no-link`, and can also run WebAssembly files produced by other compilers.
Runs a WebAssembly file. The `grain run` command can also run WebAssembly files produced by other compilers.

```sh
grain run hello.gr.wasm