adjust docs

This commit is contained in:
Araozu 2023-11-04 07:17:32 -05:00
parent e519d2d80b
commit 94c0831533
6 changed files with 52 additions and 37 deletions

View File

@ -14,7 +14,8 @@ class Logger
setLogger(Logger())
// Using an anonymous class
setLogger(class {
setLogger(class
{
pub fun log(String msg)
{
print(msg)
@ -23,7 +24,8 @@ setLogger(class {
```
```thp
setLogger(class(Int param1) -> SomeClass(param1), SomeInterface {
setLogger(class(Int param1) -> SomeClass(param1), SomeInterface
{
pub fun method()
{
// code

View File

@ -2,8 +2,6 @@
Basically kotlin syntax.
Methods have to have a first parameter `$`.
## Create a new instance of a class
@ -29,19 +27,19 @@ val instance = SimpleClass()
class SimpleClass
{
// Properties are private by default
var String? name;
var String? name = ...
// Made public with `pub`
pub var String? surname;
pub var String? surname = ...
// Methods are private by default
fun display_name($)
fun display_name()
{
// `$` is used instead of $this
print($name)
}
pub fun get_name($) -> String?
pub fun get_name() -> String?
{
$name
}
@ -61,7 +59,7 @@ Kotlin style
```thp
class Cat(val String name)
{
pub fun get_name($) -> String
pub fun get_name() -> String
{
$name
}
@ -71,6 +69,21 @@ val michifu = Cat("Michifu")
print(michifu.get_name())
```
With kotlin's `init` block.
```thp
class Dog(val String name)
{
val Int name_length
init
{
print("Dog has been instantiated")
$name_length = name.length()
}
}
```
## Inheritance
Kotlin style
@ -78,7 +91,7 @@ Kotlin style
```thp
class Animal(val String name)
{
pub fun say_name($)
pub fun say_name()
{
print($name)
}

View File

@ -6,14 +6,14 @@
interface Serializable
{
// Methods are always public in interfaces
fun serialize($) -> String
fun serialize() -> String
}
class Cat -> Serializable
{
pub fun Serializable($) -> String
pub fun Serializable() -> String
{
// code
}

View File

@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"generate": "md-docs",
"watch": "concurrently -k \"pnpm tailwind:watch\" \"serve ./static/ -l 3333\"",
"dev": "concurrently -k \"pnpm tailwind:watch\" \"serve ./static/ -l 3333\"",
"tailwind:watch": "tailwindcss -i ./tailwind.css -o ./static/css/out.css --watch",
"tailwind:build": "tailwindcss -i ./tailwind.css -o ./static/css/out.css --minify"
},

View File

@ -15,7 +15,7 @@ Prism.languages.thp = {
pattern: /(["])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
greedy: true,
},
"keyword": /\b(?:static|const|enum|loop|use|break|catch|continue|do|else|finally|for|fun|if|in|fn|nil|return|throw|try|while|val|var|type|match|with|of|abstract|class|interface|private|pub|obj|override|open)\b/,
"keyword": /\b(?:static|const|enum|loop|use|break|catch|continue|do|else|finally|for|fun|if|in|fn|nil|return|throw|try|while|val|var|type|match|with|of|abstract|class|interface|private|pub|obj|override|open|init)\b/,
"number": /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
"operator": /[<>]=?|[!=]=?=?|--?|\$|\+\+?|&&?|\|\|?|[?*/~^%]/,
"punctuation": /[{}[\];(),.]/,

View File

@ -1,28 +1,28 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./static/**/*.html"],
theme: {
extend: {
colors: {
"c-bg": "var(--c-bg)",
"c-text": "var(--c-text)",
"c-purple": "var(--c-purple)",
"c-purple-light": "var(--c-purple-light)",
"c-box-shadow": "var(--c-box-shadow)",
"c-ping": "var(--c-pink)",
"c-background-2": "var(--c-background-2)",
"c-primary": "var(--c-primary)",
"c-secondary": "var(--c-secondary)",
"c-nav-bg": "var(--c-nav-bg)",
}
content: ["./static/**/*.html"],
theme: {
extend: {
colors: {
"c-bg": "var(--c-bg)",
"c-text": "var(--c-text)",
"c-purple": "var(--c-purple)",
"c-purple-light": "var(--c-purple-light)",
"c-box-shadow": "var(--c-box-shadow)",
"c-ping": "var(--c-pink)",
"c-background-2": "var(--c-background-2)",
"c-primary": "var(--c-primary)",
"c-secondary": "var(--c-secondary)",
"c-nav-bg": "var(--c-nav-bg)",
}
},
fontFamily: {
"mono": ["'Fira Code'", "Inconsolata", "Iosevka", "monospace"],
"display": ["'Josefin Sans'", "'Fugaz One'", "sans-serif"],
"body": ["'Fira Sans Condensed'", "Inter", "sans-serif"],
"nav-title": ["'Josefin Sans'", "'Fugaz One'", "sans-serif"],
},
},
fontFamily: {
"mono": ["'Fira Code'", "Inconsolata", "Iosevka", "monospace"],
"display": ["'Josefin Sans'", "'Fugaz One'", "sans-serif"],
"body": ["'Fira Sans Condensed'", "Inter", "sans-serif"],
"nav-title": ["'Josefin Sans'", "'Fugaz One'", "sans-serif"],
},
},
plugins: [],
plugins: [],
}