Documentation
¶
Overview ¶
Package scriptdoc generates the documentation of the two JavaScript environments of the engine into docs/scripts: the pre- and postscripts of module tasks (pkg/modules/compat), as typescript declarations, jsdoc and ace completer like smart-service-module-worker-lib did, and the scripts and expressions of BPMN models (pkg/script). A Markdown reference covers both. Methods and comments are read from the Go source, types and field names by reflection with the name mapping of the script runtime, so the documentation follows the code.
Index ¶
Constants ¶
const ( ModuleDeclarations = "modules/script-env.d.ts" ModuleJsDoc = "modules/jsdoc.js" ModuleAceCompleter = "modules/ace-code-completer.ts" EngineDeclarations = "engine/script-env.d.ts" Reference = "README.md" )
Variables ¶
var EngineGlobals = []Global{ { Name: "log", Signature: "log(...args: any[]): void", Declaration: "declare function log(...args: any[]): void;", Doc: []string{ "Writes the arguments, separated by spaces, to the history of the instance at the element", "that runs the script (DBG-11). Strings are written as they are, other values as JSON.", "At most 100 entries per evaluation are kept.", }, }, { Name: "console", Signature: "console.log(...args: any[]): void", Declaration: "interface Console {\n log(...args: any[]): void;\n}\ndeclare var console: Console;", Doc: []string{"console.log is the same function as log."}, }, { Name: "setVariable", Signature: "setVariable(name: string, value: any): void", Declaration: "declare function setVariable(name: string, value: any): void;", Doc: []string{ "Sets a variable: the local variable of the element if it has one of this name, otherwise", "the variable of the instance. The value has to be representable as JSON; it is also", "visible to the rest of the script under its name.", }, }, }
Functions ¶
Types ¶
type Global ¶
Global is a function or object the sandbox of pkg/script registers besides the variables; TestEngineGlobalsAreDocumented compares the list with the sandbox.
type Interface ¶
func Interfaces ¶
type Method ¶
type Method struct {
Namespace string
Name string
Params []Parameter
// example arguments, e.g. "id_as_string, limit_as_number"
ParamsStr string
Result *Parameter
Comment string
// from a paragraph of the comment that opens with "Deprecated", the Go convention; the
// paragraph is not part of Comment
Deprecated bool
DeprecationNote string
}
Method is a function of a script namespace, read from the Go source of the type behind it.
func Methods ¶
Methods reads the exported methods of the types behind the namespaces from the source in dir, sorted by namespace and name. An unexported method is not callable from a script.
func (Method) CommentLines ¶
CommentLines splits the comment for a block comment
type Namespace ¶
type Namespace struct {
Name string
Methods []TsMethod
// set if the typescript standard library declares the global already, e.g.
// "declare var console: Console" in lib.dom; a "declare const" would collide with it
Interface string
}