scriptdoc

package
v0.47.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

View Source
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

func ToTsType

func ToTsType(jsDocType string) string

ToTsType translates a jsdoc type; a go map reaches scripts as a plain object, not as a Map

Types

type Files

type Files map[string]string

Files maps the paths below docs/scripts to their content.

func Generate

func Generate(compatSource string) (Files, error)

Generate creates all files; compatSource is the directory of pkg/modules/compat, whose method comments become the descriptions.

type Global

type Global struct {
	Name        string
	Signature   string
	Declaration string
	Doc         []string
}

Global is a function or object the sandbox of pkg/script registers besides the variables; TestEngineGlobalsAreDocumented compares the list with the sandbox.

type Interface

type Interface struct {
	Name       string
	Properties []Property
}

func Interfaces

func Interfaces(typeDefs []TypeDef) (result []Interface)

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

func Methods(dir string, namespaces map[string]any) (result []Method, err error)

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

func (this Method) CommentLines() []string

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
}

func Namespaces

func Namespaces(methods []Method) (result []Namespace)

type Parameter

type Parameter struct {
	Name         string
	NameWithType string
	Type         string
}

Parameter has its type in jsdoc notation.

type Property

type Property struct {
	Name            string
	Type            string
	Deprecated      bool
	DeprecationNote string
}

type TsMethod

type TsMethod struct {
	Name            string
	Params          string
	Result          string
	Comment         []string
	Deprecated      bool
	DeprecationNote string
}

type TypeDef

type TypeDef struct {
	Name   string
	Fields []TypeDefField
}

func TypeDefOf

func TypeDefOf(value any) []TypeDef

TypeDefOf is the typedef of a struct value and of the structs its fields reference.

func TypeDefs

func TypeDefs() (result []TypeDef)

TypeDefs are the typedefs of all sources and the structs they reference, sorted by name.

type TypeDefField

type TypeDefField struct {
	Name string
	// jsdoc notation
	Type string
	// read from the Go comment of the declaring struct; the note may be empty
	Deprecated      bool
	DeprecationNote string
}

Directories

Path Synopsis
generate writes the script documentation to docs/scripts; run by go generate in pkg/scriptdoc.
generate writes the script documentation to docs/scripts; run by go generate in pkg/scriptdoc.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL