From af02ccd056754c60131d13d74b9fac0e23b2af31 Mon Sep 17 00:00:00 2001 From: nic-gaffney Date: Tue, 18 Apr 2023 10:42:45 -0500 Subject: Added more documentation in the native functions --- crates/sloth_vm/src/sloth_std/stdio.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'crates/sloth_vm/src/sloth_std/stdio.rs') diff --git a/crates/sloth_vm/src/sloth_std/stdio.rs b/crates/sloth_vm/src/sloth_std/stdio.rs index 160d012..f56b604 100644 --- a/crates/sloth_vm/src/sloth_std/stdio.rs +++ b/crates/sloth_vm/src/sloth_std/stdio.rs @@ -28,7 +28,10 @@ pub const WRITE_FUNCTION: NativeFunction = NativeFunction { function: write, arity: 1, returns_value: false, - doc: None, + doc: Some( + "NativeFunction write: \n\targs: string (str)\n\tdesc: Writes to the \ + terminal.\n\tExample: `write(\"I'm sleepy...\"); # Output: I'm sleepy...`", + ), }; fn writeln(vm: &mut VM, args: &[Primitive]) -> NativeFunctionResult { @@ -55,7 +58,11 @@ pub const WRITELN_FUNCTION: NativeFunction = NativeFunction { function: writeln, arity: 1, returns_value: false, - doc: None, + doc: Some( + "NativeFunction writeln: \n\targs: string (str)\n\tdesc: Writes to the terminal \ + and starts a new line.\n\tExample: `writeln(\"I'm sleepy...\"); # Output: I'm \ + sleepy...\n # This is a new line`", + ), }; fn read(vm: &mut VM, _args: &[Primitive]) -> NativeFunctionResult { @@ -76,5 +83,9 @@ pub const READ_FUNCTION: NativeFunction = NativeFunction { function: read, arity: 0, returns_value: true, - doc: None, + doc: Some( + "NativeFunction read:\n\tdesc: Reads input from the terminal and returns what was \ + read.\n\tExample: `var input = read(); # Hello World input = 'Hello \ + World'`", + ), }; -- cgit v1.2.3