Skip to content

Commit

Permalink
fix and update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny-chung committed Apr 9, 2024
1 parent bb0956d commit c7b4e10
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 7 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/deploy-website.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: doc-output
path: doc
path: .
retention-days: 1
build-main-doc:
needs: build-apidoc-and-demo
Expand All @@ -46,12 +46,13 @@ jobs:
with:
name: doc-output
- run: ls -al
- run: cd doc && ls -al
- run: asciidoctor -r asciidoctor-diagram -D "output" usermanual/index.adoc
- run: cp -R usermanual/img output/img
- run: cp -R usermanual/media output/media
- uses: actions/upload-artifact@v3
with:
name: doc-output2
path: .
path: doc
retention-days: 1
deploy:
needs: build-main-doc
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,17 @@ val a = (symbolTable.findPropertyByDeclaredName("a") as LongValue).value // 4181

The interpreter is well tested.

![Well tested](./doc/usermanual/img/tests.png)
![Well tested](./doc/usermanual/media/tests.png)

## Demo

[Web - Kotlite Interpreter in browser](https://sunny-chung.github.io/kotlite/demo/)

| Android | iOS |
|-----------------------------------------------------|---------------------------------------------|
| ![Android Demo](./doc/usermanual/media/Android.mp4) | ![iOS Demo](./doc/usermanual/media/iOS.mp4) |


## Documentation

[Documentation site](https://sunny-chung.github.io/kotlite/)
2 changes: 1 addition & 1 deletion doc/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ docker run --rm -it -v "$(pwd)/..:/wd" uwebarthel/asciidoctor asciidoctor \
-r asciidoctor-diagram \
-D "/wd/doc/output" \
/wd/doc/usermanual/index.adoc
cp -R usermanual/img output/img
cp -R usermanual/media output/media
14 changes: 14 additions & 0 deletions doc/usermanual/Demo.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
= Demo

Their source codes are under https://github.com/sunny-chung/kotlite/tree/main/demo[the demo folder] of the GitHub repository.

== Web

link:./demo/[JS - An online Kotlite interpreter that runs within your browser]

video::media/Web.mp4[width=1024]

== Android

video::media/Android.mp4[width=480]

== iOS

video::media/iOS.mp4[width=480]
2 changes: 1 addition & 1 deletion doc/usermanual/Introduction.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ https://github.com/sunny-chung/kotlite/[icon:github[] The Kotlite GitHub Reposit
* Well tested -- there are more than a thousand of hand-written unit tests per platform
* Can be written in any IDE supporting Kotlin 1.9 -- Kotlite does not create new syntax

image::img/tests.png[]
image::media/tests.png[]

CAUTION: To be honest, the standard library is not well tested. Only the language itself is well tested. Please kindly help to report if any issue is found.

Expand Down
Binary file added doc/usermanual/media/Android.mp4
Binary file not shown.
Binary file added doc/usermanual/media/Web.mp4
Binary file not shown.
Binary file added doc/usermanual/media/iOS.mp4
Binary file not shown.
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ open class CodeGenerator(protected val node: ASTNode, val isPrintDebugInfo: Bool
= nodes.joinToString("") { "${it.generate()}\n" }

protected fun FunctionTypeNode.generate(): String
= "(${parameterTypes!!.joinToString(", ") {(it as ASTNode).generate()}}) -> ${(returnType as ASTNode).generate()}"
= "${receiverType?.let { "${(it as ASTNode).generate()}." } ?: ""}(${parameterTypes!!.joinToString(", ") {(it as ASTNode).generate()}}) -> ${(returnType as ASTNode).generate()}"

protected fun TypeNode.generate(): String
= "$name${arguments?.let { "<${it.joinToString(", ") { (it as ASTNode).generate() }}>" } ?: ""}${if (isNullable) "?" else ""}"
Expand Down
14 changes: 14 additions & 0 deletions stdlib/src/commonTest/kotlin/AllStdLibTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import com.sunnychung.lib.multiplatform.kotlite.KotliteInterpreter
import com.sunnychung.lib.multiplatform.kotlite.MermaidFlowchartDirection
import com.sunnychung.lib.multiplatform.kotlite.error.SemanticException
import com.sunnychung.lib.multiplatform.kotlite.evalKotliteExpression
import com.sunnychung.lib.multiplatform.kotlite.kotliteAstNodeMermaidDiagram
import com.sunnychung.lib.multiplatform.kotlite.model.ExecutionEnvironment
import com.sunnychung.lib.multiplatform.kotlite.model.IntValue
Expand Down Expand Up @@ -35,6 +36,19 @@ class AllStdLibTest {
assertEquals("Hello world!\n", console.toString())
}

@Test
fun expression() {
val env = ExecutionEnvironment().apply {
install(AllStdLibModules())
}
val result: IntValue = evalKotliteExpression(
filename = "Calculate",
code = "(1..10).fold(0) { acc, it -> acc + it }",
executionEnvironment = env,
) as IntValue
assertEquals(55, result.value)
}

@Test
fun noMutableListSuccess() {
val env = ExecutionEnvironment(
Expand Down

0 comments on commit c7b4e10

Please sign in to comment.