Use //! for script docs.

This commit is contained in:
Stephen Chung 2022-07-24 23:03:35 +08:00
parent e8d6e3f57d
commit 45acb65f4f
28 changed files with 30 additions and 29 deletions

View File

@ -1,4 +1,4 @@
// Implementation of the Event Handler With State Pattern - JS Style
//! Implementation of the Event Handler With State Pattern - JS Style
/// Initialize user-provided state.
fn init() {

View File

@ -1,4 +1,4 @@
// Implementation of the Event Handler With State Pattern - Main Style
//! Implementation of the Event Handler With State Pattern - Main Style
/// Initialize user-provided state (shadows system-provided state, if any).
fn init() {

View File

@ -1,4 +1,4 @@
// Implementation of the Event Handler With State Pattern - Map Style
//! Implementation of the Event Handler With State Pattern - Map Style
/// Initialize user-provided state.
/// State is stored inside an object map bound to 'state'.

View File

@ -1,4 +1,4 @@
// This script contains a single assignment statement.
//! This script contains a single assignment statement.
let x = 78;

View File

@ -1,3 +1,5 @@
//! This script illustrates how to put doc-comments on functions.
/// The function `foo`, which prints `hello, world!` and a magic number,
/// accepts three parameters.
///

View File

@ -1,5 +1,5 @@
// This script calculates the n-th Fibonacci number using a really dumb algorithm
// to test the speed of the scripting engine.
//! This script calculates the n-th Fibonacci number using a really dumb algorithm
//! to test the speed of the scripting engine.
const TARGET = 28;
const REPEAT = 5;

View File

@ -1,4 +1,4 @@
// This script runs for-loops.
//! This script runs for-loops.
let arr = [1, true, 123.456, "hello", 3, 42];

View File

@ -1,4 +1,4 @@
// This script runs for-loops
//! This script runs for-loops
const MAX = 1_000_000;

View File

@ -1,4 +1,4 @@
// This script runs for-loops with closures.
//! This script runs for-loops with closures.
const MAX = 100;
const CHECK = ((MAX - 1) ** 2) * MAX;

View File

@ -1,4 +1,4 @@
// This script defines a function and calls it.
//! This script defines a function and calls it.
fn call_me() {
return 3;

View File

@ -1,4 +1,4 @@
// This script defines a function with two parameters and local variables.
//! This script defines a function with two parameters and local variables.
let a = 3;

View File

@ -1,5 +1,4 @@
// This script defines a function with many parameters.
//
//! This script defines a function with many parameters.
const KEY = 38;

View File

@ -1,4 +1,4 @@
// This script defines a function that acts as a method.
//! This script defines a function that acts as a method.
// Use 'this' to refer to the object of a method call
fn action(x, y) {

View File

@ -1,4 +1,4 @@
// This script runs if statements.
//! This script runs if statements.
let a = 42;
let b = 123;

View File

@ -1,4 +1,4 @@
// This script runs an if expression.
//! This script runs an if expression.
let a = 42;
let b = 123;

View File

@ -1,4 +1,4 @@
// This script runs an infinite loop, ending it with a break statement.
//! This script runs an infinite loop, ending it with a break statement.
let x = 10;

View File

@ -1,4 +1,4 @@
// This script simulates multi-dimensional matrix calculations.
//! This script simulates multi-dimensional matrix calculations.
const SIZE = 50;

View File

@ -1,4 +1,4 @@
// This script imports an external script as a module.
//! This script imports an external script as a module.
import "loop" as x;

View File

@ -1,4 +1,4 @@
// This script simulates object-oriented programming (OOP) techniques using closures.
//! This script simulates object-oriented programming (OOP) techniques using closures.
// External variable that will be captured.
let last_value = ();

View File

@ -1,4 +1,4 @@
// This script runs a single expression.
//! This script runs a single expression.
print("The result should be 46:");

View File

@ -1,4 +1,4 @@
// This script runs a complex expression.
//! This script runs a complex expression.
print("The result should be 182:");

View File

@ -1,4 +1,4 @@
// This script runs a complex expression.
//! This script runs a complex expression.
print("The result should be 230:");

View File

@ -1,4 +1,4 @@
// This script uses the Sieve of Eratosthenes to calculate prime numbers.
//! This script uses the Sieve of Eratosthenes to calculate prime numbers.
let now = timestamp();

View File

@ -1,4 +1,4 @@
// This script runs 1 million iterations to test the speed of the scripting engine.
//! This script runs 1 million iterations to test the speed of the scripting engine.
let now = timestamp();
let x = 1_000_000;

View File

@ -1,4 +1,4 @@
// This script tests string operations.
//! This script tests string operations.
print("hello");
print("this\nis \\ nice"); // escape sequences

View File

@ -1,4 +1,4 @@
// This script tests object maps and strings.
//! This script tests object maps and strings.
print("Ready... Go!");

View File

@ -1,4 +1,4 @@
// This script runs a switch statement in a for-loop.
//! This script runs a switch statement in a for-loop.
let arr = [42, 123.456, "hello", true, "hey", 'x', 999, 1, 2, 3, 4];

View File

@ -1,4 +1,4 @@
// This script runs a while loop.
//! This script runs a while loop.
let x = 10;