First version of the docs

This commit is contained in:
Moritz Hölting 2024-04-03 00:09:47 +02:00
commit 17b38c7449
20 changed files with 5316 additions and 0 deletions

21
.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
# build output
dist/
# generated types
.astro/
# dependencies
node_modules/
# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# environment variables
.env
.env.production
# macOS-specific files
.DS_Store

4
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}

18
README.md Normal file
View File

@ -0,0 +1,18 @@
# Documentation for ShulkerScript
This is the documentation for ShulkerScript. It is a work in progress and will be updated as the language evolves.
## Getting Started
This documentation is created using Astro and Starlight. To get started, you need to install the dependencies and start the development server.
## 🧞 Commands
All commands are run from the root of the project, from a terminal:
| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:4321` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro -- --help` | Get help using the Astro CLI |

61
astro.config.mjs Normal file
View File

@ -0,0 +1,61 @@
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';
import starlightLinksValidator from "starlight-links-validator";
import shikiConfig from './src/utils/shiki';
// https://astro.build/config
export default defineConfig({
integrations: [
starlight({
title: 'ShulkerScript',
logo: {
src: './src/assets/logo.webp',
alt: 'ShulkerScript Logo',
},
favicon: '/favicon.ico',
description: 'A simple and powerful scripting language for Minecraft datapacks.',
social: {
github: 'https://github.com/moritz-hoelting/shulkerscript-cli',
},
tableOfContents: { minHeadingLevel: 1, maxHeadingLevel: 3 },
defaultLocale: 'root',
locales: {
root: {
label: 'English',
lang: 'en',
},
de: {
label: 'Deutsch',
lang: 'de',
},
},
editLink: {
baseUrl: 'https://github.com/moritz-hoelting/shulkerscript-webpage/edit/main',
},
plugins: [starlightLinksValidator({
errorOnFallbackPages: false,
})],
expressiveCode: {
shiki: shikiConfig,
},
sidebar: [
{
label: 'Guides',
autogenerate: {
directory: 'guides',
},
},
{
label: 'Reference',
autogenerate: {
directory: 'reference',
},
badge: {
text: 'WIP',
variant: 'caution',
}
}
]
}),
],
});

20
package.json Normal file
View File

@ -0,0 +1,20 @@
{
"name": "",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/check": "^0.5.10",
"@astrojs/starlight": "^0.21.3",
"astro": "^4.3.5",
"sharp": "^0.32.5",
"starlight-links-validator": "^0.7.1",
"typescript": "^5.4.3"
}
}

4839
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

1
public/favicon.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path fill-rule="evenodd" d="M81 36 64 0 47 36l-1 2-9-10a6 6 0 0 0-9 9l10 10h-2L0 64l36 17h2L28 91a6 6 0 1 0 9 9l9-10 1 2 17 36 17-36v-2l9 10a6 6 0 1 0 9-9l-9-9 2-1 36-17-36-17-2-1 9-9a6 6 0 1 0-9-9l-9 10v-2Zm-17 2-2 5c-4 8-11 15-19 19l-5 2 5 2c8 4 15 11 19 19l2 5 2-5c4-8 11-15 19-19l5-2-5-2c-8-4-15-11-19-19l-2-5Z" clip-rule="evenodd"/><path d="M118 19a6 6 0 0 0-9-9l-3 3a6 6 0 1 0 9 9l3-3Zm-96 4c-2 2-6 2-9 0l-3-3a6 6 0 1 1 9-9l3 3c3 2 3 6 0 9Zm0 82c-2-2-6-2-9 0l-3 3a6 6 0 1 0 9 9l3-3c3-2 3-6 0-9Zm96 4a6 6 0 0 1-9 9l-3-3a6 6 0 1 1 9-9l3 3Z"/><style>path{fill:#000}@media (prefers-color-scheme:dark){path{fill:#fff}}</style></svg>

After

Width:  |  Height:  |  Size: 696 B

BIN
src/assets/logo.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

6
src/content/config.ts Normal file
View File

@ -0,0 +1,6 @@
import { defineCollection } from 'astro:content';
import { docsSchema } from '@astrojs/starlight/schema';
export const collections = {
docs: defineCollection({ schema: docsSchema() }),
};

View File

@ -0,0 +1,39 @@
---
title: Wilkommen bei der ShulkerScript Dokumentation
description: Eine einfache und leistungsstarke Sprache für Minecraft Datapacks
template: splash
hero:
tagline: Einführung in ShulkerScript
image:
file: ../../../assets/logo.webp
actions:
- text: Los geht's
link: guides/getting-started/
icon: right-arrow
variant: primary
- text: Beitragen
link: https://github.com/moritz-hoelting/shulkerscript-cli
icon: external
---
import { Card, CardGrid } from '@astrojs/starlight/components';
<CardGrid stagger>
<Card title="Einfacher Syntax" icon="seti:html">
Der Syntax ist ähnlich zu anderen Programmiersprachen, was das Lernen einfach macht,
und bietet gleichzeitig leistungsstarke Funktionen, die in `.mcfunction` Dateien nicht zu finden sind.
</Card>
<Card title="Unkomplizierte Functions" icon="add-document">
Mehrere Funktionsdateien aus einer einzigen Quelldatei generieren und sie
von Minecraft oder anderen ShulkerScript-Dateien aus aufrufen.
</Card>
<Card title="In Rust geschrieben" icon="seti:rust">
Die ShulkerScript-Compiler sind in Rust geschrieben, was für eine hohe Geschwindigkeit und Sicherheit sorgt.
</Card>
<Card title="Zum Projekt beitragen" icon="github">
Zu [dem CLI](https://github.com/moritz-hoelting/shulkerscript-cli) oder [dem Compiler](https://github.com/moritz-hoelting/shulkerscript-lang) beitragen.
</Card>
</CardGrid>

View File

@ -0,0 +1,36 @@
---
title: Kommandozeilen-Interface Referenz
description: Referenz für das ShulkerScript Kommandozeilen-Tool
sidebar:
label: CLI
---
Das ShulkerScript CLI ist ein Kommandozeilen-Tool zum Verwalten von ShulkerScript-Projekten.
## init
Initialisiert ein Projekt im angegebenen Pfad.
Erstellt Projektdateien und -verzeichnisse.
```bash
shulkerscript init [OPTIONS] [PATH]
```
- `PATH`: Der Pfad zu dem Verzeichnis, in dem das Projekt erstellt werden soll. Standardmäßig das aktuelle Verzeichnis.
Optionen:
- `--force`: Erlaubt das Initialisieren in einem nicht-leeren Verzeichnis.
- `--name`: Der Name des Projekts. Standardmäßig der Name des Verzeichnisses.
- `--description`: Die Beschreibung des Projekts.
- `--pack-format`: Das Format des Packs. Standardmäßig `26`.
## build
Baut das Projekt im angegebenen Pfad in das `dist`-Verzeichnis.
```bash
shulkerscript build [PATH]
```
- `PATH`: Der Pfad zum Verzeichnis, in dem sich das Projekt befindet. Standardmäßig das aktuelle Verzeichnis.
## package
Baut und verpackt das Projekt im angegebenen Pfad in eine `.zip`-Datei.
```bash
shulkerscript package [PATH]
```

View File

@ -0,0 +1,94 @@
---
title: Getting Started
description: Get started with ShulkerScript
---
import { Steps, FileTree } from '@astrojs/starlight/components';
## Installation
To get started with ShulkerScript, you need to install the ShulkerScript CLI.
You can either [download](#download-from-github) the latest release from the GitHub releases page or [build it from source](#building-from-source).
### Download from GitHub
<Steps>
1. Go to the [GitHub releases page](https://github.com/moritz-hoelting/shulkerscript-cli/releases) and download the latest release for your platform.
2. Extract the downloaded archive.
3. Move the extracted binary to a directory in your PATH.
4. Test the installation by running
```bash
shulkerscript --version
```
You should see the version of the CLI printed to the console.
</Steps>
### Building from source
<Steps>
1. Make sure you have [Rust and Cargo](https://rustup.rs) installed.
2. Install the CLI by running
```bash
cargo install --git https://github.com/moritz-hoelting/shulkerscript-cli
```
3. Test the installation by running
```bash
shulkerscript --version
```
</Steps>
## Creating a new project
<Steps>
1. Create a new directory for your project.
2. Navigate into the directory.
3. Run
```bash
shulkerscript init
```
This will create a new ShulkerScript project in the current directory.
4. Open the `pack.toml` file in your favorite text editor and configure the project to your liking.
</Steps>
The project structure should look like this:
<FileTree>
- src/
- main.shu
- .gitignore
- pack.toml
- pack.png
</FileTree>
## Writing your first script
After opening the file `src/main.shu` in your favorite text editor, you should see the following content:
```shulkerscript title="src/main.shu"
#[tick]
fn main() {
/say Hello, world!
}
```
The annotation `#[tick]` tells the compiler that this function should be executed every tick.
Every line that starts with a `/` is a command that will included in the output. You can add as many commands as you like.
To begin with, you can change the message in the `/say` command to something else.
## Building the project
<Steps>
1. Navigate into the project directory.
2. Run
```bash
shulkerscript build
```
This will compile the project and output the result to the `dist` directory.
3. Alternatively you can run
```bash
shulkerscript watch
```
to automatically rebuild the project when a file changes.
</Steps>
## Distributing the project
<Steps>
1. Navigate into the project directory.
2. Run
```bash
shulkerscript package
```
This will create a ZIP archive containing the compiled project.
3. You can now distribute the archive to your users.
</Steps>

View File

@ -0,0 +1,67 @@
---
title: Syntax
description: Learn the syntax of ShulkerScript
sidebar:
badge:
text: WIP
variant: caution
---
## Comments
Single line comments start with `//` and continue until the end of the line.
Multiline comments start with `/*` and end with `*/`.
```shulkerscript
// This is a single line comment
/* This is a
multiline comment */
```
These comments are completely ignored by the compiler and will not show up in the generated datapack.
If you want to include a comment in the datapack, you can use the doccomment syntax.
```shulkerscript
/// This is a doccomment
```
## Literal Commands
Literal commands are commands that are directly included in the output.
They start with a `/` and are followed by the command.
```shulkerscript
/say Hello, world!
```
This will result in `say Hello, world!` being included in the `.mcfunction` file.
## Functions
Functions are blocks of code that can be executed.
They start with `fn` followed by the name of the function, parenthesis and a block of code.
Optionally they can be preceeded by annotations.
```shulkerscript title="src/main.shu"
#[tick]
fn main() {
/say Hello, world!
}
```
This code defines a function called `main` that will be executed every tick.
### Annotations
Annotations are special attributes that can be attached to functions.
They start with `#` followed by the name of the annotation in square brackets. Some annotations can have arguments assigned to them with the `=` operator.
Currently the following annotations are supported:
- `#[tick]`: The function will be executed every tick.
- `#[load]`: The function will be executed when the datapack is loaded.
- `#[deobfuscate]`: The function will keep the original name in the output (path of the `.shu`-file followed by the function name).
- `#[deobfuscate = "path/to/function"]`: The function will be named as specified in the argument.
## Conditional Statements
Conditional statements are used to execute code based on a condition.
They start with `if` followed by a condition in parenthesis and a block of code.
Optionally they can be followed by an `else` block.
```shulkerscript
if ("block ~ ~-1 ~ minecraft:stone") {
/say On stone
} else {
/say Not on stone
}
```

View File

@ -0,0 +1,38 @@
---
title: Welcome to the ShulkerScript docs
description: Get started writing your datapacks with ShulkerScript
template: splash
hero:
tagline: Intro to getting started with ShulkerScript
image:
file: ../../assets/logo.webp
actions:
- text: Get started
link: guides/getting-started/
icon: right-arrow
variant: primary
- text: Contribute
link: https://github.com/moritz-hoelting/shulkerscript-cli
icon: external
---
import { Card, CardGrid } from '@astrojs/starlight/components';
<CardGrid stagger>
<Card title="Simple Syntax" icon="seti:html">
The syntax is similar to other programming languages, making it easy to learn,
while at the same time providing powerful features not found in `.mcfunction` files.
</Card>
<Card title="Easy Functions" icon="add-document">
Generate multiple function files from a single source file, and call them from Minecraft or other ShulkerScript files.
</Card>
<Card title="Written in Rust" icon="seti:rust">
Fast compile times and a small binary size make ShulkerScript a great choice for your next project.
</Card>
<Card title="Contribute to this project" icon="github">
Contribute to [the CLI](https://github.com/moritz-hoelting/shulkerscript-cli) or [the compiler](https://github.com/moritz-hoelting/shulkerscript-lang).
</Card>
</CardGrid>

View File

@ -0,0 +1,36 @@
---
title: Command-line interface reference
description: Reference for the ShulkerScript command-line tool
sidebar:
label: CLI
---
The ShulkerScript CLI is a command-line tool for managing ShulkerScript projects.
## init
Initalize a project at the specified path.
Creates project files and directories.
```bash
shulkerscript init [OPTIONS] [PATH]
```
- `PATH`: The path to the directory where the project should be created. Defaults to the current directory.
Options:
- `--force`: Allow initalizing in a non-empty directory.
- `--name`: The name of the project. Defaults to the name of the directory.
- `--description`: The description of the project.
- `--pack-format`: The format of the pack. Defaults to `26`.
## build
Build the project at the specified path to the `dist` folder.
```bash
shulkerscript build [PATH]
```
- `PATH`: The path to the directory where the project is located. Defaults to the current directory.
## package
Build and package the project at the specified path to a `.zip` file.
```bash
shulkerscript package [PATH]
```

2
src/env.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />

20
src/utils/shiki.ts Normal file
View File

@ -0,0 +1,20 @@
import type { PluginShikiOptions } from "@astrojs/starlight/expressive-code";
const config: PluginShikiOptions = {
langs: [
/*{
name: 'shulkerscript',
aliases: ['shu'],
displayName: 'ShulkerScript',
fileTypes: ['shu'],
scopeName: 'source.shulkerscript',
patterns: [
{
}
]
}*/
]
};
export default config;

3
tsconfig.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "astro/tsconfigs/strict"
}