Skip to content

Commit 59bbc0e

Browse files
committed
enhanced documentation
1 parent aabfb9f commit 59bbc0e

264 files changed

Lines changed: 817 additions & 517 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ Public release.
2727
- Dart CI workflow and badge.
2828

2929
# 1.1.0
30-
- Added try/catch feature.
30+
- Added try/catch feature.
31+
32+
# 1.1.1
33+
- Enchanced documentation.

README.md

Lines changed: 23 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
11
# OcheScript
2-
3-
**Oche *(pronounced "ock-ee")*. The official name for the throwing line in a game of darts.**
4-
5-
Embedded script language for Flutter/Dart applications.
6-
72
[![Dart CI](https://github.com/atebitftw/ochescript/actions/workflows/dart.yaml/badge.svg)](https://github.com/atebitftw/ochescript/actions/workflows/dart.yaml)
83

94
![OcheScript Logo](https://atebitftw.github.io/site/assets/oche_script_logo_640.png)
5+
*Oche *(pronounced "ock-ee")*. The official name for the throwing line in a game of darts.*
6+
7+
#### Embedded script language for Flutter/Dart applications.
108

119
## Key Features
12-
OcheScript is a lightweight, dynamically typed, object-oriented, scripting language designed for embedding into Dart applications.
13-
14-
* Convenient Dart interop capabilities.
15-
* Extensible via native methods and functions.
16-
* Object-oriented programming features (classes, methods, properties, etc.).
17-
* Closures and lambdas.
18-
* (Limited) Asynchronous support (async/await).
19-
* String interpolation.
20-
* Try/catch exception handling.
21-
* Lightweight preprocessor directive capabilities.
22-
* `.oche` script file syntax highlighting extension for VSCode/Antigravity.
10+
OcheScript is an extensible, lightweight yet powerful scripting language designed for embedding into Dart/Flutter applications.
11+
12+
* **Convenient [Dart interop](https://github.com/atebitftw/ochescript/blob/main/doc/dart_interop.md) Features.**
13+
* **Initialize OcheScript globals from Dart.**
14+
* **Call Dart functions from OcheScript and get return values.**
15+
* **Send values from OcheScript to Dart at any time.**
16+
* **Extensible - Make It Your Own**
17+
* **Define [extension methods](https://github.com/atebitftw/ochescript/blob/main/doc/native_methods.md) bound to supported types (many already included).**
18+
* **Define [global functions](https://github.com/atebitftw/ochescript/blob/main/doc/native_functions.md) that can execute arbitrary Dart code (many already included).**
19+
* **Object-Oriented Programming Features (classes, methods, properties, etc.).**
20+
* **Closures and Lambdas.**
21+
* **String Interpolation.**
22+
* **Try/Catch Exception Handling.**
23+
* **Asynchronous Support (async/await).**
24+
* **Lightweight Preprocessor Directive Capabilities.**
25+
* **`.oche` Script File Syntax Highlighting Extension for VSCode/Antigravity.**
26+
* **Comprehensive API and Language Documentation.**
2327

2428
## Hello World In OcheScript
25-
*In a text file with extension `.oche`*
26-
```js
27-
print("Hello World!");
28-
```
29-
30-
Running from Dart:
31-
3229
```dart
3330
import 'package:oche_script/oche_script.dart' as oche;
3431
3532
Future<void> main() async {
3633
final result = await oche.compileAndRun(r"print("Hello World!");");
3734
}
35+
36+
// Hello World!
3837
```
3938

4039
## Getting Started
@@ -44,7 +43,7 @@ See the [Getting Started](https://github.com/atebitftw/ochescript/blob/main/doc/
4443
See the [Language Specification](https://github.com/atebitftw/ochescript/blob/main/doc/language_specification.md) document for more information.
4544

4645
## Library API
47-
See the [API](https://github.com/atebitftw/ochescript/tree/main/doc/api) document for more information. This is an HTML document generated from the Dartdoc comments in the source code.
46+
See the [API](https://pub.dev/documentation/oche_script/latest/) document for more information. This is an HTML document generated from the Dartdoc comments in the source code.
4847

4948
## Dart Interop
5049
See the [Dart Interop](https://github.com/atebitftw/ochescript/blob/main/doc/dart_interop.md) document for more information.
@@ -54,56 +53,6 @@ I work on some very large-scale Flutter projects that sometimes require a bit of
5453

5554
*Side Note: Dart technically does have arbitrary code execution capability via `dart:mirrors`, but I personally do not consider it to be a viable approach for many production application scenarios, especially anything Flutter-based (mirrors disallowed). Another reason to avoid mirrors: As soon as you bring in mirrors, you lose tree-shaking.*
5655

57-
## Error Handling
58-
Unless captured in a `try/catch` block, runtime errors cause script execution to halt with an error message.
59-
60-
Errors are not emitted to stdout by default. They are usually reported via the [Logging Package](https://pub.dev/packages/logging) at level WARNING and above. To listen to these errors, you can use the `Logging` class from the `logging` package.
61-
62-
```dart
63-
// (assumes you've added the logging package as a dependency in your pubspec.yaml)
64-
import 'package:logging/logging.dart';
65-
import 'package:oche_script/oche_script.dart' as oche;
66-
67-
Future<void> main() async {
68-
Logger.root.level = Level.WARNING;
69-
Logger.root.onRecord.listen((record) {
70-
print("${record.level.name}: ${record.message}");
71-
// emits the error message and stack trace
72-
});
73-
74-
final result = await oche.compileAndRun(r"print("Hello World!");");
75-
76-
print("Return Code: ${result['return_code']}");
77-
if (result.containsKey('error')) {
78-
print("Error: ${result['error']}");
79-
}
80-
}
81-
```
82-
83-
Error messages are also placed in the return map of the `compileAndRun` function (without stack trace). The map has the following structure:
84-
85-
```dart
86-
{
87-
"error": "{error message}",
88-
"return_code": 1,
89-
// other stuff emitted by any out() functions in the script.
90-
}
91-
```
92-
93-
### Why not just print errors to stdout?
94-
Since OcheScript is primarily designed for use as an embedded language in other Dart/Flutter applications, stdout is not reliably available on various platforms. Using the logging package gives the developer more flexibility in how and where they receive error messages.
95-
96-
If you want the error message to be printed to stdout, you can use the `Logging` class from the `logging` package to listen to the `Logger` at level WARNING and above.
97-
98-
### Included Library Error Reporting
99-
When using the `#include` directive to include other "library" files into your script, OcheScript tracks the original source file and line number. If a runtime error occurs within an included file, the error message will be prefixed with the file name and line number, like so:
100-
101-
```
102-
Runtime error: [my_lib:42] Undefined variable 'foo'.
103-
```
104-
105-
This is useful for debugging scripts that are composed of multiple files.
106-
10756
## These Batteries Are Not Included
10857
* No module system (beyond `#INCLUDE` directive)
10958
* No operator overloading.

doc/api/__404error.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ <h5>
9797
<footer>
9898
<span class="no-break">
9999
oche_script
100-
1.1.0
100+
1.1.1
101101
</span>
102102

103103
</footer>

doc/api/index.html

Lines changed: 29 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -44,82 +44,55 @@
4444

4545
<section class="desc markdown">
4646
<h1 id="ochescript">OcheScript</h1>
47-
<p><strong>Oche <em>(pronounced "ock-ee")</em>. The official name for the throwing line in a game of darts.</strong></p>
48-
<p>Embedded script language for Flutter/Dart applications.</p>
4947
<p><a href="https://github.com/atebitftw/ochescript/actions/workflows/dart.yaml"><img src="https://github.com/atebitftw/ochescript/actions/workflows/dart.yaml/badge.svg" alt="Dart CI"></a></p>
50-
<p><img src="https://atebitftw.github.io/site/assets/oche_script_logo_640.png" alt="OcheScript Logo"></p>
48+
<p><img src="https://atebitftw.github.io/site/assets/oche_script_logo_640.png" alt="OcheScript Logo">
49+
<em>Oche <em>(pronounced "ock-ee")</em>. The official name for the throwing line in a game of darts.</em></p>
50+
<h4 id="embedded-script-language-for-flutterdart-applications">Embedded script language for Flutter/Dart applications.</h4>
5151
<h2 id="key-features">Key Features</h2>
52-
<p>OcheScript is a lightweight, dynamically typed, object-oriented, scripting language designed for embedding into Dart applications.</p>
52+
<p>OcheScript is an extensible, lightweight yet powerful scripting language designed for embedding into Dart/Flutter applications.</p>
5353
<ul>
54-
<li>Convenient Dart interop capabilities.</li>
55-
<li>Extensible via native methods and functions.</li>
56-
<li>Object-oriented programming features (classes, methods, properties, etc.).</li>
57-
<li>Closures and lambdas.</li>
58-
<li>(Limited) Asynchronous support (async/await).</li>
59-
<li>String interpolation.</li>
60-
<li>Try/catch exception handling.</li>
61-
<li>Lightweight preprocessor directive capabilities.</li>
62-
<li><code>.oche</code> script file syntax highlighting extension for VSCode/Antigravity.</li>
54+
<li><strong>Convenient <a href="https://github.com/atebitftw/ochescript/blob/main/doc/dart_interop.md">Dart interop</a> Features.</strong>
55+
<ul>
56+
<li><strong>Initialize OcheScript globals from Dart.</strong></li>
57+
<li><strong>Call Dart functions from OcheScript and get return values.</strong></li>
58+
<li><strong>Send values from OcheScript to Dart at any time.</strong></li>
59+
</ul>
60+
</li>
61+
<li><strong>Extensible - Make It Your Own</strong>
62+
<ul>
63+
<li><strong>Define <a href="https://github.com/atebitftw/ochescript/blob/main/doc/native_methods.md">extension methods</a> bound to supported types (many already included).</strong></li>
64+
<li><strong>Define <a href="https://github.com/atebitftw/ochescript/blob/main/doc/native_functions.md">global functions</a> that can execute arbitrary Dart code (many already included).</strong></li>
65+
</ul>
66+
</li>
67+
<li><strong>Object-Oriented Programming Features (classes, methods, properties, etc.).</strong></li>
68+
<li><strong>Closures and Lambdas.</strong></li>
69+
<li><strong>String Interpolation.</strong></li>
70+
<li><strong>Try/Catch Exception Handling.</strong></li>
71+
<li><strong>Asynchronous Support (async/await).</strong></li>
72+
<li><strong>Lightweight Preprocessor Directive Capabilities.</strong></li>
73+
<li><strong><code>.oche</code> Script File Syntax Highlighting Extension for VSCode/Antigravity.</strong></li>
74+
<li><strong>Comprehensive API and Language Documentation.</strong></li>
6375
</ul>
6476
<h2 id="hello-world-in-ochescript">Hello World In OcheScript</h2>
65-
<p><em>In a text file with extension <code>.oche</code></em></p>
66-
<pre class="language-js"><code class="language-js">print("Hello World!");
67-
</code></pre>
68-
<p>Running from Dart:</p>
6977
<pre class="language-dart"><code class="language-dart">import 'package:oche_script/oche_script.dart' as oche;
7078

7179
Future&lt;void&gt; main() async {
7280
final result = await oche.compileAndRun(r"print("Hello World!");");
7381
}
82+
83+
// Hello World!
7484
</code></pre>
7585
<h2 id="getting-started">Getting Started</h2>
7686
<p>See the <a href="https://github.com/atebitftw/ochescript/blob/main/doc/getting_started.md">Getting Started</a> document for more information.</p>
7787
<h2 id="language-specification">Language Specification</h2>
7888
<p>See the <a href="https://github.com/atebitftw/ochescript/blob/main/doc/language_specification.md">Language Specification</a> document for more information.</p>
7989
<h2 id="library-api">Library API</h2>
80-
<p>See the <a href="https://github.com/atebitftw/ochescript/tree/main/doc/api">API</a> document for more information. This is an HTML document generated from the Dartdoc comments in the source code.</p>
90+
<p>See the <a href="https://pub.dev/documentation/oche_script/latest/">API</a> document for more information. This is an HTML document generated from the Dartdoc comments in the source code.</p>
8191
<h2 id="dart-interop">Dart Interop</h2>
8292
<p>See the <a href="https://github.com/atebitftw/ochescript/blob/main/doc/dart_interop.md">Dart Interop</a> document for more information.</p>
8393
<h2 id="why-does-this-exist">Why Does This Exist?</h2>
8494
<p>I work on some very large-scale Flutter projects that sometimes require a bit of dynamic runtime automation, and I found that I needed execute arbitrary code at runtime in certain situations. I built OcheScript to meet this need. In the Flutter/Dart ecosystem, there are probably five people that need this kind of thing, and I am one of them. To the other four, I say: "Hello World!".</p>
8595
<p><em>Side Note: Dart technically does have arbitrary code execution capability via <code>dart:mirrors</code>, but I personally do not consider it to be a viable approach for many production application scenarios, especially anything Flutter-based (mirrors disallowed). Another reason to avoid mirrors: As soon as you bring in mirrors, you lose tree-shaking.</em></p>
86-
<h2 id="error-handling">Error Handling</h2>
87-
<p>Unless captured in a <code>try/catch</code> block, runtime errors cause script execution to halt with an error message.</p>
88-
<p>Errors are not emitted to stdout by default. They are usually reported via the <a href="https://pub.dev/packages/logging">Logging Package</a> at level WARNING and above. To listen to these errors, you can use the <code>Logging</code> class from the <code>logging</code> package.</p>
89-
<pre class="language-dart"><code class="language-dart">// (assumes you've added the logging package as a dependency in your pubspec.yaml)
90-
import 'package:logging/logging.dart';
91-
import 'package:oche_script/oche_script.dart' as oche;
92-
93-
Future&lt;void&gt; main() async {
94-
Logger.root.level = Level.WARNING;
95-
Logger.root.onRecord.listen((record) {
96-
print("${record.level.name}: ${record.message}");
97-
// emits the error message and stack trace
98-
});
99-
100-
final result = await oche.compileAndRun(r"print("Hello World!");");
101-
102-
print("Return Code: ${result['return_code']}");
103-
if (result.containsKey('error')) {
104-
print("Error: ${result['error']}");
105-
}
106-
}
107-
</code></pre>
108-
<p>Error messages are also placed in the return map of the <code>compileAndRun</code> function (without stack trace). The map has the following structure:</p>
109-
<pre class="language-dart"><code class="language-dart">{
110-
"error": "{error message}",
111-
"return_code": 1,
112-
// other stuff emitted by any out() functions in the script.
113-
}
114-
</code></pre>
115-
<h3 id="why-not-just-print-errors-to-stdout">Why not just print errors to stdout?</h3>
116-
<p>Since OcheScript is primarily designed for use as an embedded language in other Dart/Flutter applications, stdout is not reliably available on various platforms. Using the logging package gives the developer more flexibility in how and where they receive error messages.</p>
117-
<p>If you want the error message to be printed to stdout, you can use the <code>Logging</code> class from the <code>logging</code> package to listen to the <code>Logger</code> at level WARNING and above.</p>
118-
<h3 id="included-library-error-reporting">Included Library Error Reporting</h3>
119-
<p>When using the <code>#include</code> directive to include other "library" files into your script, OcheScript tracks the original source file and line number. If a runtime error occurs within an included file, the error message will be prefixed with the file name and line number, like so:</p>
120-
<pre class="language-dart"><code>Runtime error: [my_lib:42] Undefined variable 'foo'.
121-
</code></pre>
122-
<p>This is useful for debugging scripts that are composed of multiple files.</p>
12396
<h2 id="these-batteries-are-not-included">These Batteries Are Not Included</h2>
12497
<ul>
12598
<li>No module system (beyond <code>#INCLUDE</code> directive)</li>
@@ -258,7 +231,7 @@ <h5 class="hidden-xs"><span class="package-name">oche_script</span> <span class=
258231
<footer>
259232
<span class="no-break">
260233
oche_script
261-
1.1.0
234+
1.1.1
262235
</span>
263236

264237
</footer>

doc/api/native_functions_define_native_functions/clock.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ <h5>define_native_functions library</h5>
105105
<footer>
106106
<span class="no-break">
107107
oche_script
108-
1.1.0
108+
1.1.1
109109
</span>
110110

111111
</footer>

doc/api/native_functions_define_native_functions/date.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ <h5>define_native_functions library</h5>
122122
<footer>
123123
<span class="no-break">
124124
oche_script
125-
1.1.0
125+
1.1.1
126126
</span>
127127

128128
</footer>

doc/api/native_functions_define_native_functions/defineVmNativeFunctions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ <h5>define_native_functions library</h5>
106106
<footer>
107107
<span class="no-break">
108108
oche_script
109-
1.1.0
109+
1.1.1
110110
</span>
111111

112112
</footer>

doc/api/native_functions_define_native_functions/duration.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ <h5>define_native_functions library</h5>
117117
<footer>
118118
<span class="no-break">
119119
oche_script
120-
1.1.0
120+
1.1.1
121121
</span>
122122

123123
</footer>

doc/api/native_functions_define_native_functions/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ <h5>define_native_functions library</h5>
283283
<footer>
284284
<span class="no-break">
285285
oche_script
286-
1.1.0
286+
1.1.1
287287
</span>
288288

289289
</footer>

doc/api/native_functions_define_native_functions/jsonDecode.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ <h5>define_native_functions library</h5>
127127
<footer>
128128
<span class="no-break">
129129
oche_script
130-
1.1.0
130+
1.1.1
131131
</span>
132132

133133
</footer>

0 commit comments

Comments
 (0)