Compare commits
No commits in common. "fbc81246465fb189ae6335904546002d9dfdca54" and "2b98f56240a9efc20500e9c310062cd31bb31ac9" have entirely different histories.
fbc8124646
...
2b98f56240
@ -1,21 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 153 140">
|
|
||||||
<g fill="#f7a41d">
|
|
||||||
<g>
|
|
||||||
<polygon points="46,22 28,44 19,30"/>
|
|
||||||
<polygon points="46,22 33,33 28,44 22,44 22,95 31,95 20,100 12,117 0,117 0,22" shape-rendering="crispEdges"/>
|
|
||||||
<polygon points="31,95 12,117 4,106"/>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
<polygon points="56,22 62,36 37,44"/>
|
|
||||||
<polygon points="56,22 111,22 111,44 37,44 56,32" shape-rendering="crispEdges"/>
|
|
||||||
<polygon points="116,95 97,117 90,104"/>
|
|
||||||
<polygon points="116,95 100,104 97,117 42,117 42,95" shape-rendering="crispEdges"/>
|
|
||||||
<polygon points="150,0 52,117 3,140 101,22"/>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
<polygon points="141,22 140,40 122,45"/>
|
|
||||||
<polygon points="153,22 153,117 106,117 120,105 125,95 131,95 131,45 122,45 132,36 141,22" shape-rendering="crispEdges"/>
|
|
||||||
<polygon points="125,95 130,110 106,117"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 832 B |
@ -16,7 +16,7 @@ const { showSidebarButton = true } = Astro.props;
|
|||||||
|
|
||||||
<a
|
<a
|
||||||
href="/"
|
href="/"
|
||||||
class="px-4 flex gap-2 items-center"
|
class="inline-block px-4 font-display font-black text-2xl hover:underline"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
class="inline-block h-10"
|
class="inline-block h-10"
|
||||||
@ -25,7 +25,7 @@ const { showSidebarButton = true } = Astro.props;
|
|||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href="/en/latest/learn/"
|
href="/learn/"
|
||||||
class="hidden sm:inline-block px-4 font-display font-bold-text-xl hover:underline"
|
class="hidden sm:inline-block px-4 font-display font-bold-text-xl hover:underline"
|
||||||
>
|
>
|
||||||
Learn
|
Learn
|
||||||
@ -36,6 +36,12 @@ const { showSidebarButton = true } = Astro.props;
|
|||||||
>
|
>
|
||||||
Standard Library
|
Standard Library
|
||||||
</a>
|
</a>
|
||||||
|
<a
|
||||||
|
href="/api/help/"
|
||||||
|
class="hidden sm:inline-block px-4 font-display font-bold-text-xl hover:underline"
|
||||||
|
>
|
||||||
|
Help
|
||||||
|
</a>
|
||||||
<a
|
<a
|
||||||
href="/spec/"
|
href="/spec/"
|
||||||
class="hidden sm:inline-block px-4 font-display font-bold-text-xl hover:underline"
|
class="hidden sm:inline-block px-4 font-display font-bold-text-xl hover:underline"
|
||||||
|
@ -4,15 +4,10 @@ import type { PageEntry } from "../layouts/PagesLayout.astro";
|
|||||||
const entry: PageEntry = Astro.props.entry;
|
const entry: PageEntry = Astro.props.entry;
|
||||||
const basePath: string = Astro.props.basePath;
|
const basePath: string = Astro.props.basePath;
|
||||||
|
|
||||||
const entryPath = is_index_file(entry.path)? "": entry.path;
|
const entryPath = entry.path === "index"? "": entry.path;
|
||||||
|
|
||||||
const entryUrl = basePath + entryPath + (entryPath.endsWith("/")? "" : "/");
|
const entryUrl = basePath + entryPath + (entryPath.endsWith("/")? "" : "/");
|
||||||
|
|
||||||
function is_index_file(p) {
|
|
||||||
return p.endsWith("index")
|
|
||||||
|| p.endsWith("index.md")
|
|
||||||
|| p.endsWith("index.mdx")
|
|
||||||
}
|
|
||||||
---
|
---
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -31,14 +26,14 @@ function is_index_file(p) {
|
|||||||
entry.children && (
|
entry.children && (
|
||||||
<>
|
<>
|
||||||
<div class="mt-6 px-3 py-1 uppercase font-display text-c-text-2 font-medium">
|
<div class="mt-6 px-3 py-1 uppercase font-display text-c-text-2 font-medium">
|
||||||
{entry.title.replaceAll("-", " ")}
|
{entry.title}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul class="my-1">
|
<ul class="my-1">
|
||||||
{entry.children!.map((nextEntry) => (
|
{entry.children!.map((nextEntry) => (
|
||||||
<Astro.self
|
<Astro.self
|
||||||
entry={nextEntry}
|
entry={nextEntry}
|
||||||
basePath={`${basePath}${entry.path}`}
|
basePath={`${basePath}${entry.path}/`}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -3,7 +3,7 @@ import PagesLayout from "./PagesLayout.astro";
|
|||||||
|
|
||||||
const { frontmatter, headings } = Astro.props;
|
const { frontmatter, headings } = Astro.props;
|
||||||
|
|
||||||
const posts = await Astro.glob("@/pages/learn/**/*.{md,mdx}");
|
const posts = await Astro.glob("../pages/learn/**/*.{md,mdx}");
|
||||||
const indexSubpath = `/learn/index.mdx`;
|
const indexSubpath = `/learn/index.mdx`;
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -1,150 +0,0 @@
|
|||||||
---
|
|
||||||
import Navbar from "../components/Navbar.astro";
|
|
||||||
import BaseLayout from "./BaseLayout.astro";
|
|
||||||
import TOC from "../components/TOC.astro";
|
|
||||||
import Sidebar from "../components/Sidebar.astro";
|
|
||||||
|
|
||||||
export type PageEntry = {
|
|
||||||
path: string;
|
|
||||||
title?: string;
|
|
||||||
children?: Array<PageEntry>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface AstroFile {
|
|
||||||
frontmatter: Frontmatter
|
|
||||||
__usesAstroImage: boolean
|
|
||||||
url: string
|
|
||||||
file: string
|
|
||||||
relative_file: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Frontmatter {
|
|
||||||
layout: string
|
|
||||||
title: string
|
|
||||||
order: number
|
|
||||||
}
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
/** The directory where all the md/mdx files start from */
|
|
||||||
base_dir: string
|
|
||||||
frontmatter: Frontmatter;
|
|
||||||
headings: any;
|
|
||||||
posts: Array<AstroFile>;
|
|
||||||
};
|
|
||||||
|
|
||||||
const {
|
|
||||||
base_dir,
|
|
||||||
frontmatter,
|
|
||||||
headings,
|
|
||||||
posts
|
|
||||||
}: Props = Astro.props;
|
|
||||||
|
|
||||||
const base_dir_end = base_dir.length;
|
|
||||||
|
|
||||||
const posts_2 = posts
|
|
||||||
.map(post => ({
|
|
||||||
...post,
|
|
||||||
relative_file: post.file.substring(base_dir_end),
|
|
||||||
path: post.file.substring(base_dir_end).replace(/\.mdx?$/, ""),
|
|
||||||
title: post.frontmatter.title,
|
|
||||||
}))
|
|
||||||
.sort((p1, p2) => p1.frontmatter.order > p2.frontmatter.order? 1 : -1);
|
|
||||||
|
|
||||||
// build a hierarchy of the files
|
|
||||||
const second_level: Record<string, Array<AstroFile>> = {
|
|
||||||
"_": [],
|
|
||||||
};
|
|
||||||
for (const post of posts_2) {
|
|
||||||
const fragments = post.path.split("/");
|
|
||||||
if (fragments.length === 3) {
|
|
||||||
const folder_name = fragments[1]!;
|
|
||||||
|
|
||||||
// create if not exists
|
|
||||||
if (second_level[folder_name] === undefined) {
|
|
||||||
second_level[folder_name] = [];
|
|
||||||
}
|
|
||||||
second_level[folder_name].push(post);
|
|
||||||
}
|
|
||||||
else if (fragments.length === 2) {
|
|
||||||
// add to root folder
|
|
||||||
second_level["_"]!.push(post);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// transform to the layout that the sidebar expects
|
|
||||||
|
|
||||||
const entries: Array<any> = [];
|
|
||||||
for (const levels_key in second_level) {
|
|
||||||
if (levels_key === "_") {
|
|
||||||
// top level
|
|
||||||
const posts = second_level[levels_key]!;
|
|
||||||
entries.push(...posts)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const posts = second_level[levels_key]!;
|
|
||||||
const parentEntry = {
|
|
||||||
path: "",
|
|
||||||
title: levels_key,
|
|
||||||
children: posts,
|
|
||||||
};
|
|
||||||
entries.push(parentEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const index_page = entries.find(post => post.relative_file === "/index.md" || post.relative_file === "/index.mdx");
|
|
||||||
if (index_page === undefined && process.env.NODE_ENV !== "production") {
|
|
||||||
console.error("\n\nBuilding without an index page");
|
|
||||||
console.error("Props base_dir:", base_dir);
|
|
||||||
}
|
|
||||||
const basePath = index_page?.url ?? "/";
|
|
||||||
---
|
|
||||||
|
|
||||||
<BaseLayout title={frontmatter.title}>
|
|
||||||
<Navbar />
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="lg:grid lg:grid-cols-[14rem_auto_12rem] lg:container mx-auto font-display"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
id="sidebar"
|
|
||||||
class="pt-12 h-screen lg:sticky top-0 fixed z-10 bg-c-bg w-60 lg:w-auto border-r-2 lg:border-0
|
|
||||||
border-c-border-1 -translate-x-64 lg:translate-x-0 transition-transform"
|
|
||||||
>
|
|
||||||
<nav class="py-4 pr-2 overflow-x-scroll h-[calc(100vh-3rem)]">
|
|
||||||
{
|
|
||||||
entries.map((entry) => (
|
|
||||||
<Sidebar entry={entry} basePath={basePath} />
|
|
||||||
))
|
|
||||||
}
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<main
|
|
||||||
class="pt-[3.5rem] pb-[10rem] lg:pl-12 lg:pr-4 markdown min-w-0 small-container mx-auto"
|
|
||||||
>
|
|
||||||
<slot />
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="lg:pt-12 hidden lg:block pt-4 max-h-screen overflow-x-scroll sticky top-0"
|
|
||||||
>
|
|
||||||
<nav class="rounded-md lg:mt-10">
|
|
||||||
<h2 class="font-display font-medium pb-2 text-c-text-2">
|
|
||||||
On this page
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<TOC headings={headings} />
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { highlightOnDom } from "./thpHighlighter";
|
|
||||||
document.addEventListener("DOMContentLoaded", highlightOnDom);
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
import { sidebarHighlight } from "./utils";
|
|
||||||
// Highlight the current url of the sidebar
|
|
||||||
document.addEventListener("DOMContentLoaded", sidebarHighlight);
|
|
||||||
</script>
|
|
||||||
</BaseLayout>
|
|
@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
import NewDocsLayout, { type AstroFile } from "@/layouts/NewDocsLayout.astro";
|
|
||||||
|
|
||||||
const { frontmatter, headings } = Astro.props;
|
|
||||||
// Get all the posts from this dir
|
|
||||||
|
|
||||||
const posts = await Astro.glob("./**/*.{md,mdx}") as unknown as Array<AstroFile>;
|
|
||||||
|
|
||||||
// Current dir
|
|
||||||
const current_dir = import.meta.dirname;
|
|
||||||
---
|
|
||||||
|
|
||||||
<NewDocsLayout
|
|
||||||
base_dir={current_dir}
|
|
||||||
frontmatter={frontmatter}
|
|
||||||
headings={headings}
|
|
||||||
posts={posts}
|
|
||||||
>
|
|
||||||
<slot />
|
|
||||||
</NewPagesLayout>
|
|
@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
layout: "../_wrapper.astro"
|
|
||||||
title: Abstract
|
|
||||||
---
|
|
||||||
import Code from "@/components/Code.astro"
|
|
||||||
|
|
||||||
# Abstract
|
|
||||||
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
layout: "../_wrapper.astro"
|
|
||||||
title: Readonly
|
|
||||||
---
|
|
||||||
import Code from "@/components/Code.astro"
|
|
||||||
|
|
||||||
# Readonly
|
|
||||||
|
|
||||||
<Code thpcode={`
|
|
||||||
class Caño
|
|
||||||
{
|
|
||||||
}
|
|
||||||
`} />
|
|
||||||
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
layout: "../_wrapper.astro"
|
|
||||||
title: Visibility
|
|
||||||
---
|
|
||||||
import Code from "@/components/Code.astro"
|
|
||||||
|
|
||||||
# Visibility
|
|
@ -54,7 +54,7 @@ const [thp_html] = await native_highlighter(
|
|||||||
<a
|
<a
|
||||||
class="inline-block font-display text-lg rounded-full border-2 border-pink-400 py-2 px-8
|
class="inline-block font-display text-lg rounded-full border-2 border-pink-400 py-2 px-8
|
||||||
transition-colors hover:text-black hover:bg-pink-400 mt-2"
|
transition-colors hover:text-black hover:bg-pink-400 mt-2"
|
||||||
href="/en/latest/learn/"
|
href="/learn/"
|
||||||
>
|
>
|
||||||
Learn
|
Learn
|
||||||
</a>
|
</a>
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Comments
|
title: Comments
|
||||||
order: 2
|
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Comments
|
# Comments
|
||||||
|
|
@ -1,9 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Datatypes
|
title: Datatypes
|
||||||
order: 4
|
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Datatypes
|
# Datatypes
|
||||||
|
|
@ -1,10 +1,9 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Hello world
|
title: Hello world
|
||||||
order: 1
|
|
||||||
---
|
---
|
||||||
import InteractiveCode from "@/components/InteractiveCode.astro";
|
import InteractiveCode from "../../../components/InteractiveCode.astro";
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Hello, world!
|
# Hello, world!
|
||||||
|
|
@ -1,9 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Operators
|
title: Operators
|
||||||
order: 5
|
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Operators
|
# Operators
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Variables
|
title: Variables
|
||||||
order: 3
|
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
|
|
230
src/pages/learn/cheatsheet.mdx
Normal file
230
src/pages/learn/cheatsheet.mdx
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
---
|
||||||
|
layout: ../../layouts/DocsLayout.astro
|
||||||
|
title: Cheatsheet
|
||||||
|
disable_container: true
|
||||||
|
---
|
||||||
|
import TwoColumn from "../../components/TwoColumn.astro"
|
||||||
|
import Code from "../../components/Code.astro"
|
||||||
|
|
||||||
|
# Language cheatsheet
|
||||||
|
|
||||||
|
Comparisons to PHP are noted.
|
||||||
|
|
||||||
|
<TwoColumn cols="grid-cols-[1fr_1fr] gap-2">
|
||||||
|
|
||||||
|
<Code thpcode={`
|
||||||
|
// THP code is written directly, it's not enclosed in any ?php tag
|
||||||
|
// Single line comments are written with two slashes
|
||||||
|
|
||||||
|
/*
|
||||||
|
Multiline comments use slash-asterisk
|
||||||
|
and can be /* nested */
|
||||||
|
*/
|
||||||
|
|
||||||
|
// there is no echo, only print
|
||||||
|
// Unlike PHP, parenthesis are required
|
||||||
|
print("Hello world")
|
||||||
|
`} />
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
// PHP requires a <?php opening tag
|
||||||
|
|
||||||
|
/*
|
||||||
|
PHP cannot nest multiline comments
|
||||||
|
/* this would be an error * /
|
||||||
|
*/
|
||||||
|
|
||||||
|
# PHP also has hash comments. THP doesn't
|
||||||
|
|
||||||
|
print "Hello world";
|
||||||
|
```
|
||||||
|
</TwoColumn>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Variables
|
||||||
|
|
||||||
|
|
||||||
|
<TwoColumn cols="grid-cols-[1fr_1fr] gap-2">
|
||||||
|
|
||||||
|
<Code no_warnings={true} thpcode={`
|
||||||
|
// THP has explicit variable declaration
|
||||||
|
// Variables don't start with a dollar sign ($)
|
||||||
|
// Variables are declared with \`var\`
|
||||||
|
var age = 32
|
||||||
|
|
||||||
|
// Immutable variables are declared with \`val\`,
|
||||||
|
// and can't be reassigned
|
||||||
|
val name = "John"
|
||||||
|
|
||||||
|
// Variables may have a datatype declaration
|
||||||
|
// This is an immutable variable with a type
|
||||||
|
String road = "Abbey road"
|
||||||
|
// This is a mutable variable with a type
|
||||||
|
var String name = "The Beatles"
|
||||||
|
`} />
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$age = 32;
|
||||||
|
|
||||||
|
|
||||||
|
// There is no PHP equivalent
|
||||||
|
$name = "John";
|
||||||
|
|
||||||
|
// You can't annotate the type of a variable in PHP
|
||||||
|
|
||||||
|
$road = "Abbey road";
|
||||||
|
|
||||||
|
$name = "The Beatles";
|
||||||
|
```
|
||||||
|
|
||||||
|
</TwoColumn>
|
||||||
|
|
||||||
|
## Datatypes
|
||||||
|
|
||||||
|
<TwoColumn cols="grid-cols-[1fr_1fr] gap-2">
|
||||||
|
<Code no_warnings={true} thpcode={`
|
||||||
|
// Only double quotes, never single quotes
|
||||||
|
String name = "Jane"
|
||||||
|
// Interpolation
|
||||||
|
String full_name = "{name} Doe"
|
||||||
|
|
||||||
|
Int age = 25
|
||||||
|
Float interest = 3.22
|
||||||
|
|
||||||
|
// An integer with a leading zero is an error,
|
||||||
|
// you must use \`0o\` for octal
|
||||||
|
// Int invalid = 0755
|
||||||
|
Int valid = 0o755
|
||||||
|
|
||||||
|
// Case sensitive, only \`true\` or \`false\`
|
||||||
|
Bool has_a_cute_dress = true
|
||||||
|
`} />
|
||||||
|
```php
|
||||||
|
|
||||||
|
$name = 'Jane';
|
||||||
|
|
||||||
|
$full_name = "$name Doe";
|
||||||
|
|
||||||
|
$age = 25;
|
||||||
|
$interest = 3.22;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$invalid = 0755;
|
||||||
|
$valid = 0o755;
|
||||||
|
|
||||||
|
// PHP allows true/false in any case, for some reason
|
||||||
|
$has_a_cute_dress = TrUe;
|
||||||
|
```
|
||||||
|
</TwoColumn>
|
||||||
|
|
||||||
|
|
||||||
|
<TwoColumn cols="grid-cols-[1fr_1fr] gap-2">
|
||||||
|
<Code no_warnings={true} thpcode={`
|
||||||
|
// String concatenation uses \`++\`
|
||||||
|
print("Hello " ++ "world")
|
||||||
|
|
||||||
|
// Basic operators
|
||||||
|
var res = 1 + 2 - 3 * 4 % 5
|
||||||
|
|
||||||
|
res += 2
|
||||||
|
res -= 2
|
||||||
|
res *= 2
|
||||||
|
res /= 2
|
||||||
|
res %= 2
|
||||||
|
|
||||||
|
// There are no prefix/postfix increment/decrement
|
||||||
|
//
|
||||||
|
//
|
||||||
|
`} />
|
||||||
|
```php
|
||||||
|
|
||||||
|
print("Hello " . "world");
|
||||||
|
|
||||||
|
|
||||||
|
$res = 1 + 2 - 3 * 4 % 5;
|
||||||
|
|
||||||
|
res += 2;
|
||||||
|
res -= 2;
|
||||||
|
res *= 2;
|
||||||
|
res /= 2;
|
||||||
|
res %= 2;
|
||||||
|
|
||||||
|
|
||||||
|
++res;
|
||||||
|
res--;
|
||||||
|
```
|
||||||
|
</TwoColumn>
|
||||||
|
|
||||||
|
## Flow control
|
||||||
|
|
||||||
|
<TwoColumn cols="grid-cols-[1fr_1fr] gap-2">
|
||||||
|
<Code no_warnings={true} thpcode={`
|
||||||
|
// Parenthesis not required, braces required
|
||||||
|
if age < 18
|
||||||
|
{
|
||||||
|
print("Not allowed")
|
||||||
|
}
|
||||||
|
else if age == 18
|
||||||
|
{
|
||||||
|
print("Allowed, barely")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print("Allowed")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conditionals are expressions
|
||||||
|
val gift = if prefers_silver
|
||||||
|
{
|
||||||
|
"silver necklace"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
"gold necklace"
|
||||||
|
}
|
||||||
|
`} />
|
||||||
|
|
||||||
|
```php
|
||||||
|
|
||||||
|
if (age < 18) {
|
||||||
|
print("Not allowed");
|
||||||
|
} else if (age === 18) {
|
||||||
|
print("Allowed, barely");
|
||||||
|
} else {
|
||||||
|
print("Allowed");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$gift = "";
|
||||||
|
if (prefers_silver) {
|
||||||
|
$gift = "silver necklace";
|
||||||
|
} else {
|
||||||
|
$gift = "gold necklace";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</TwoColumn>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<TwoColumn cols="grid-cols-[1fr_1fr] gap-2">
|
||||||
|
<Code no_warnings={true} thpcode={`
|
||||||
|
`} />
|
||||||
|
```php
|
||||||
|
```
|
||||||
|
</TwoColumn>
|
9
src/pages/learn/classes/abstract.mdx
Normal file
9
src/pages/learn/classes/abstract.mdx
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
|
title: Abstract
|
||||||
|
---
|
||||||
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
|
# Abstract
|
||||||
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Anonymous classes
|
title: Anonymous classes
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Anonymous classes
|
# Anonymous classes
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Constructor/Destructor
|
title: Constructor/Destructor
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Constructor/Destructor
|
# Constructor/Destructor
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Basics
|
title: Basics
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Classes
|
# Classes
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Inheritance
|
title: Inheritance
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Inheritance
|
# Inheritance
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Interfaces
|
title: Interfaces
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Interfaces
|
# Interfaces
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Magic methods
|
title: Magic methods
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Magic methods
|
# Magic methods
|
||||||
|
|
15
src/pages/learn/classes/readonly.mdx
Normal file
15
src/pages/learn/classes/readonly.mdx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
|
title: Readonly
|
||||||
|
---
|
||||||
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
|
# Readonly
|
||||||
|
|
||||||
|
<Code thpcode={`
|
||||||
|
class Caño
|
||||||
|
{
|
||||||
|
}
|
||||||
|
`} />
|
||||||
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Static
|
title: Static
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Static in classes
|
# Static in classes
|
||||||
|
|
7
src/pages/learn/classes/visibility.mdx
Normal file
7
src/pages/learn/classes/visibility.mdx
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
|
title: Visibility
|
||||||
|
---
|
||||||
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
|
# Visibility
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Arrays
|
title: Arrays
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Arrays
|
# Arrays
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Enums
|
title: Enums
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Enums
|
# Enums
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Maps
|
title: Maps
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Maps
|
# Maps
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Tuples
|
title: Tuples
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Tuples
|
# Tuples
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Tagged unions
|
title: Tagged unions
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Tagged unions
|
# Tagged unions
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Nullable types
|
title: Nullable types
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Nullable types
|
# Nullable types
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Try/Exceptions
|
title: Try/Exceptions
|
||||||
---
|
---
|
||||||
import InteractiveCode from "@/components/InteractiveCode.astro";
|
import InteractiveCode from "../../../components/InteractiveCode.astro";
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Try/exceptions
|
# Try/exceptions
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Blocks
|
title: Blocks
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Blocks
|
# Blocks
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Conditionals
|
title: Conditionals
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Conditionals
|
# Conditionals
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Loops
|
title: Loops
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Loops
|
# Loops
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Match
|
title: Match
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Match
|
# Match
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Declaration
|
title: Declaration
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Declaration
|
# Declaration
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Higher Order Functions
|
title: Higher Order Functions
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Higher Order functions
|
# Higher Order functions
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Lambdas
|
title: Lambdas
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Lambdas / Anonymous functions
|
# Lambdas / Anonymous functions
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Function parameters
|
title: Function parameters
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Function parameters
|
# Function parameters
|
||||||
|
|
251
src/pages/learn/ideas/idea_1.md
Normal file
251
src/pages/learn/ideas/idea_1.md
Normal file
@ -0,0 +1,251 @@
|
|||||||
|
# Idea 1
|
||||||
|
|
||||||
|
|
||||||
|
let mut x = 20
|
||||||
|
let y = 30
|
||||||
|
|
||||||
|
type Something = ...
|
||||||
|
|
||||||
|
Something s1 = ...
|
||||||
|
Something s2 = s1
|
||||||
|
|
||||||
|
|
||||||
|
// Passes `some` by reference, but it's immutable. Cannot call mutable methods
|
||||||
|
// or use it in mutable operations
|
||||||
|
fun do_something(Something some) -> Bool {}
|
||||||
|
do_something(s1)
|
||||||
|
|
||||||
|
// Passes `some` by reference, and it's mutable. Can call mutable methods
|
||||||
|
// or use it in mutable operations
|
||||||
|
fun do_something(&Something some) -> Bool {}
|
||||||
|
do_something(&s1)
|
||||||
|
|
||||||
|
|
||||||
|
let mut arr1 = Array(10, 20, 30)
|
||||||
|
let mut arr2 = &arr1
|
||||||
|
|
||||||
|
|
||||||
|
Owned/Reference Mutable
|
||||||
|
Type Owned n
|
||||||
|
&Type Reference n
|
||||||
|
mut Type Owned y
|
||||||
|
&mut Type Reference y
|
||||||
|
|
||||||
|
|
||||||
|
Copy/Reference Mutable Equivalent
|
||||||
|
Some Copy n 1 (technically) references the other data
|
||||||
|
&Some Reference n 1 References the other data
|
||||||
|
mut Some Copy y 2 Creates a __mutable__ copy
|
||||||
|
&mut Some Reference y 3 References the other data, __mutable__
|
||||||
|
|
||||||
|
|
||||||
|
## `Array[A]::map`
|
||||||
|
|
||||||
|
```thp
|
||||||
|
fun map[B](this, (A) -> B callback) -> Array[B]
|
||||||
|
```
|
||||||
|
|
||||||
|
Applies `callback` to all the elements of this array, and
|
||||||
|
returns those new values in a new array.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```thp
|
||||||
|
let numbers = Array(1, 2, 3, 4, 5)
|
||||||
|
|
||||||
|
let numbers_squared = numbers.map {it ** 2}
|
||||||
|
|
||||||
|
print(numbers_squared) // Array(1, 4, 9, 16, 25)
|
||||||
|
|
||||||
|
numbers.map(fun(v) {
|
||||||
|
v - 2
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## `Array[A]::reduce`
|
||||||
|
|
||||||
|
```thp
|
||||||
|
fun reduce[B](
|
||||||
|
this,
|
||||||
|
B initial,
|
||||||
|
(A previous, B current) -> B callback,
|
||||||
|
) -> B
|
||||||
|
```
|
||||||
|
|
||||||
|
Iteratively reduce the array to a single value using `callback`.
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```thp
|
||||||
|
let numbers = Array(1, 2, 3, 4, 5)
|
||||||
|
|
||||||
|
let sum = numbers.reduce(0, \+)
|
||||||
|
let sum = numbers.reduce(0) {$1 + $2}
|
||||||
|
let sum = numbers.reduce(0, fun(prev, curr) {prev + curr})
|
||||||
|
|
||||||
|
print(sum) // 15
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
```thp
|
||||||
|
let numbers = Array(1, 2, 3, 4, 5)
|
||||||
|
|
||||||
|
let sum = numbers.reduce("", fun(prev, curr) {prev + curr})
|
||||||
|
|
||||||
|
let sum = numbers.reduce("") {prev, curr -> prev + curr}
|
||||||
|
|
||||||
|
print(sum) // "12345"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
```thp
|
||||||
|
// Functor
|
||||||
|
|
||||||
|
fun fmap(
|
||||||
|
(A) -> B,
|
||||||
|
f[A],
|
||||||
|
) -> f[B]
|
||||||
|
|
||||||
|
fun (<$)(
|
||||||
|
A,
|
||||||
|
f[B],
|
||||||
|
) -> f[A]
|
||||||
|
|
||||||
|
|
||||||
|
// Applicative
|
||||||
|
|
||||||
|
fun pure(A) -> f[A]
|
||||||
|
|
||||||
|
fun (<*>)(
|
||||||
|
f[A -> B],
|
||||||
|
f[A],
|
||||||
|
) -> f[B]
|
||||||
|
|
||||||
|
fun (*>)(
|
||||||
|
f[_],
|
||||||
|
f[B],
|
||||||
|
) -> f[B]
|
||||||
|
|
||||||
|
fun (<*)(
|
||||||
|
f[A],
|
||||||
|
f[_],
|
||||||
|
) -> f[A]
|
||||||
|
|
||||||
|
|
||||||
|
// Monad
|
||||||
|
|
||||||
|
fun (>>=)[m, A, B](
|
||||||
|
m[A],
|
||||||
|
(A) -> m[B],
|
||||||
|
) -> m[B]
|
||||||
|
|
||||||
|
|
||||||
|
(Array[Int], Int -> Array[String]) -> Array[String]
|
||||||
|
|
||||||
|
let result = Array(1, 2, 3, 4, 5) >>= {Array($.into[String]())}
|
||||||
|
|
||||||
|
print(result) // Array("1", "2", "3", "4", "5")
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
```thp
|
||||||
|
Option[Int] result = "322".try_into()
|
||||||
|
Option[Int] result_halved = result >>= {Some($ / 2)}
|
||||||
|
|
||||||
|
print(result_halved) // Some(161)
|
||||||
|
|
||||||
|
|
||||||
|
Option[Int] result = "abc".try_into()
|
||||||
|
Option[Int] result_halved = result >>= {Some($ / 2)}
|
||||||
|
|
||||||
|
print(result_halved) // None
|
||||||
|
```
|
||||||
|
|
||||||
|
```thp
|
||||||
|
fun (<$>)[m, A, B](
|
||||||
|
(A) -> B,
|
||||||
|
m[A],
|
||||||
|
) -> m[B]
|
||||||
|
|
||||||
|
|
||||||
|
fun half(Int x) -> Int {
|
||||||
|
x / 2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Option[Int] result = "322".try_into()
|
||||||
|
Option[Int] result_halved = result <$> half
|
||||||
|
|
||||||
|
print(result_halved) // Some(161)
|
||||||
|
|
||||||
|
|
||||||
|
Option[Int] result = "abc".try_into()
|
||||||
|
Option[Int] result_halved = result <$> half
|
||||||
|
|
||||||
|
print(result_halved) // None
|
||||||
|
```
|
||||||
|
|
||||||
|
```thp
|
||||||
|
fun (>>)[A, B, C](
|
||||||
|
(A) -> B,
|
||||||
|
(B) -> C,
|
||||||
|
) -> (A) -> C
|
||||||
|
|
||||||
|
let f1 = add1 >> times2
|
||||||
|
|
||||||
|
f1(5) // 12
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```thp
|
||||||
|
function_call[Datatype](param1, param2) {
|
||||||
|
// lambda
|
||||||
|
}
|
||||||
|
|
||||||
|
function_call([arr1, arr2])
|
||||||
|
function_call[Datatype]([arr1, arr2])
|
||||||
|
|
||||||
|
|
||||||
|
fun test[A, B](A a, B b) -> B {}
|
||||||
|
|
||||||
|
|
||||||
|
Array[String] v = 20
|
||||||
|
|
||||||
|
val x = Obj {
|
||||||
|
Array[Int] x: [1, 2, 3]
|
||||||
|
}
|
||||||
|
|
||||||
|
value + [1, 2, 3]
|
||||||
|
|
||||||
|
value + [Int]
|
||||||
|
|
||||||
|
|
||||||
|
value[0]
|
||||||
|
|
||||||
|
|
||||||
|
let functions = [
|
||||||
|
{0},
|
||||||
|
{1},
|
||||||
|
{2},
|
||||||
|
]
|
||||||
|
|
||||||
|
let index = 0
|
||||||
|
|
||||||
|
functions[index]()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
```thp
|
||||||
|
fun main()
|
||||||
|
{
|
||||||
|
// Using the turbofish operator
|
||||||
|
let result = "42".parse[Int]()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
@ -1,10 +1,68 @@
|
|||||||
---
|
---
|
||||||
layout: "./_wrapper.astro"
|
layout: ../../layouts/DocsLayout.astro
|
||||||
title: Welcome
|
title: Welcome
|
||||||
order: 1
|
pagesLayout:
|
||||||
|
- path: index
|
||||||
|
- path: install
|
||||||
|
- path: cheatsheet
|
||||||
|
- path: basics
|
||||||
|
title: Basics
|
||||||
|
children:
|
||||||
|
- path: hello-world
|
||||||
|
- path: comments
|
||||||
|
- path: variables
|
||||||
|
- path: datatypes
|
||||||
|
- path: operators
|
||||||
|
- path: flow-control
|
||||||
|
title: Flow control
|
||||||
|
children:
|
||||||
|
- path: conditionals
|
||||||
|
- path: loops
|
||||||
|
- path: match
|
||||||
|
- path: blocks
|
||||||
|
- path: data-structures
|
||||||
|
title: Data structures
|
||||||
|
children:
|
||||||
|
- path: tuples
|
||||||
|
- path: arrays
|
||||||
|
- path: maps
|
||||||
|
- path: enums
|
||||||
|
- path: unions
|
||||||
|
- path: functions
|
||||||
|
title: Functions
|
||||||
|
children:
|
||||||
|
- path: declaration
|
||||||
|
- path: parameters
|
||||||
|
- path: higher-order
|
||||||
|
- path: lambdas
|
||||||
|
- path: error-handling
|
||||||
|
title: Error handling
|
||||||
|
children:
|
||||||
|
- path: "null"
|
||||||
|
- path: try
|
||||||
|
- path: classes
|
||||||
|
title: Classes
|
||||||
|
children:
|
||||||
|
- path: definition
|
||||||
|
- path: constructor
|
||||||
|
- path: inheritance
|
||||||
|
- path: static
|
||||||
|
- path: visibility
|
||||||
|
- path: readonly
|
||||||
|
- path: abstract
|
||||||
|
- path: interfaces
|
||||||
|
- path: anonymous
|
||||||
|
- path: magic
|
||||||
|
- path: templating
|
||||||
|
title: Templating
|
||||||
|
children:
|
||||||
|
- path: intro
|
||||||
|
- path: components
|
||||||
|
- path: props
|
||||||
|
- path: control-flow
|
||||||
---
|
---
|
||||||
import InteractiveCode from "@/components/InteractiveCode.astro";
|
import InteractiveCode from "../../components/InteractiveCode.astro";
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../components/Code.astro"
|
||||||
|
|
||||||
|
|
||||||
# Welcome
|
# Welcome
|
28
src/pages/learn/install.md
Normal file
28
src/pages/learn/install.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
layout: ../../layouts/DocsLayout.astro
|
||||||
|
title: Install
|
||||||
|
---
|
||||||
|
|
||||||
|
# Install
|
||||||
|
|
||||||
|
**THP is technically usable.**
|
||||||
|
|
||||||
|
## From source (*nix)
|
||||||
|
|
||||||
|
Requires Rust installed.
|
||||||
|
|
||||||
|
Clone [the repo](https://git.araozu.dev/fernando/thp) and run
|
||||||
|
`cargo build --release`. You'll have a `thp` binary on
|
||||||
|
`target/release/thp`, run it and see for yourself.
|
||||||
|
|
||||||
|
|
||||||
|
## Binary
|
||||||
|
|
||||||
|
Goal: Install THP with a single binary. Assumes that php and composer is
|
||||||
|
available.
|
||||||
|
|
||||||
|
|
||||||
|
## With composer
|
||||||
|
|
||||||
|
TBD: Install THP with `composer require thp`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Components
|
title: Components
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
import Info from "@/components/docs/Info.astro"
|
import Info from "../../../components/docs/Info.astro"
|
||||||
|
|
||||||
# Components
|
# Components
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Control flow
|
title: Control flow
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
import Info from "@/components/docs/Info.astro"
|
import Info from "../../../components/docs/Info.astro"
|
||||||
|
|
||||||
# Control flow
|
# Control flow
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Introduction
|
title: Introduction
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
import Info from "@/components/docs/Info.astro"
|
import Info from "../../../components/docs/Info.astro"
|
||||||
|
|
||||||
# THP templating
|
# THP templating
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/DocsLayout.astro
|
||||||
title: Props
|
title: Props
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
import Info from "@/components/docs/Info.astro"
|
import Info from "../../../components/docs/Info.astro"
|
||||||
|
|
||||||
# Props
|
# Props
|
||||||
|
|
@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
import NewDocsLayout, { type AstroFile } from "@/layouts/NewDocsLayout.astro";
|
|
||||||
|
|
||||||
const { frontmatter, headings } = Astro.props;
|
|
||||||
// Get all the posts from this dir
|
|
||||||
|
|
||||||
const posts = await Astro.glob("./**/*.{md,mdx}") as unknown as Array<AstroFile>;
|
|
||||||
|
|
||||||
// Current dir
|
|
||||||
const current_dir = import.meta.dirname;
|
|
||||||
---
|
|
||||||
|
|
||||||
<NewDocsLayout
|
|
||||||
base_dir={current_dir}
|
|
||||||
frontmatter={frontmatter}
|
|
||||||
headings={headings}
|
|
||||||
posts={posts}
|
|
||||||
>
|
|
||||||
<slot />
|
|
||||||
</NewPagesLayout>
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/SpecLayout.astro
|
||||||
title: AST
|
title: AST
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/SpecLayout.astro
|
||||||
title: Expression
|
title: Expression
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -1,8 +1,26 @@
|
|||||||
---
|
---
|
||||||
layout: "./_wrapper.astro"
|
layout: ../../layouts/SpecLayout.astro
|
||||||
title: Welcome
|
title: Welcome
|
||||||
|
pagesLayout:
|
||||||
|
- path: index
|
||||||
|
- path: tokens
|
||||||
|
title: Tokens
|
||||||
|
children:
|
||||||
|
- path: tokens
|
||||||
|
- path: numbers
|
||||||
|
- path: identifier
|
||||||
|
- path: string
|
||||||
|
- path: comments
|
||||||
|
- path: operator
|
||||||
|
- path: grouping
|
||||||
|
- path: newline
|
||||||
|
- path: ast
|
||||||
|
title: THP AST
|
||||||
|
children:
|
||||||
|
- path: ast
|
||||||
|
- path: expression
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../components/Code.astro"
|
||||||
|
|
||||||
|
|
||||||
# The THP Language Specification
|
# The THP Language Specification
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/SpecLayout.astro
|
||||||
title: Comment
|
title: Comment
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Comment
|
# Comment
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/SpecLayout.astro
|
||||||
title: Grouping signs
|
title: Grouping signs
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/SpecLayout.astro
|
||||||
title: Identifiers & Datatypes
|
title: Identifiers & Datatypes
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Identifiers & Datatypes
|
# Identifiers & Datatypes
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/SpecLayout.astro
|
||||||
title: New line
|
title: New line
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/SpecLayout.astro
|
||||||
title: Numbers
|
title: Numbers
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Numbers
|
# Numbers
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/SpecLayout.astro
|
||||||
title: Operator
|
title: Operator
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# Operator
|
# Operator
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/SpecLayout.astro
|
||||||
title: String
|
title: String
|
||||||
---
|
---
|
||||||
import Code from "@/components/Code.astro"
|
import Code from "../../../components/Code.astro"
|
||||||
|
|
||||||
# String
|
# String
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
layout: "../_wrapper.astro"
|
layout: ../../../layouts/SpecLayout.astro
|
||||||
title: Index
|
title: Index
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -1,9 +1,3 @@
|
|||||||
{
|
{
|
||||||
"extends": "astro/tsconfigs/strictest",
|
"extends": "astro/tsconfigs/strictest"
|
||||||
"compilerOptions": {
|
}
|
||||||
"baseUrl": ".",
|
|
||||||
"paths": {
|
|
||||||
"@/*": ["src/*"],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user