A minimal documentation generator for the Wren scripting language.
Uses perl v5.30.3
perl WrenDoc.pl -out Doc.md -in Behaviour.wren -v
- -i | in: comma separated .wren inputs
- -o | out: .md output filename
- -v | verbose: gives detailed information during script runtime
To document your code just add documentation comments before a code symbol.
///(Arg Type A), (Arg Type B), ... -> (Return Type)
///Descriptions can be typed as well and will append to-
///the next available code symbol.
If no documentation comments are found no worries your code will still generate a document, however, there will not be any type annotations or descriptions. Any missing type annotation will appear as a _
When documenting multiple modules and classes WrenDoc will organize links for each module, class, and class components(methods, etc.) in their appropriate places.
Here's an example of some wren code that has been documented:
///Behaviours allow for custom code to run on GameObjects during the game loop.
class Behaviour is Serializable {
///_ -> Any
///Global data for behaviours
static data { __data }
///Any -> _
static data=(v) { __data = v }
///Num -> Num
static [i] {
return __data[i]
}
///Any, Any -> _
static [i] = (v) {
__data[i] = v
}
///_ -> Num
frame {
if(_frame == null) {
_frame = 0
}
return _frame
}
///Num -> _
frame=(v) {_frame=v}
///_ -> ComponentBehaviour
as_behaviour { _behaviour }
///GameObject, ComponentBehaviour -> Behaviour
construct new(g, c) {
if(__data == null) {
__data = {}
}
if(__data[g.uuid] == null) {
__data[g.uuid] = {}
}
if(__data[g.uuid]["%(c)"] == null) {
__data[g.uuid]["%(c)"] = {}
}
var b = ComponentBehaviour.new("%(c)")
_behaviour = b.as_component
__data[g.uuid]["%(c)"][b.uuid] = c.new()
}
///_ -> null
///Runs the frame after setup.
static start() {}
///_ -> null
///Run every frame.
static update() {}
///Map -> null
///Runs every frame after start that the Behaviour has a collision given a Rigidbody and Transform is attached.
static onCollision(collision) {}
///_ -> null
///Runs the first frame regardless of whether or not the Behaviour is attached.
setup() {}
///_ -> null
///Runs the second frame regardless of whether or not the Behaviour is attached.
start() {}
///_ -> null
///Runs every frame after start regardless of whether or not the Behaviour is attached.
update() {}
}
When run through WrenDoc we will get an output like this:
$ perl WrenDoc.pl -out Doc.md -in Behaviour.wren -v
WrenDoc: building Doc.md
WrenDoc: starting Behaviour.wren
WrenDoc Found: class
WrenDoc Found: static getter
WrenDoc Found: static setter
WrenDoc Found: static getter
WrenDoc Found: static setter
WrenDoc Found: getter
WrenDoc Found: setter
WrenDoc Found: getter
WrenDoc Found: constructor
WrenDoc Found: static method
WrenDoc Found: static method
WrenDoc Found: static method
WrenDoc Found: method
WrenDoc Found: method
WrenDoc Found: method
WrenDoc: built doc => Behaviour.wren
WrenDoc: Finished
Inherits from
Serializable
Behaviours allow for custom code to run on GameObjects during the game loop.
return Any
Global data for behaviours
return Num
return Num
return ComponentBehaviour
return Behaviour
return null
Runs the frame after setup.
return null
Run every frame.
return null
Runs every frame after start that the Behaviour has a collision given a Rigidbody and Transform is attached.
return null
Runs the first frame regardless of whether or not the Behaviour is attached.
return null
Runs the second frame regardless of whether or not the Behaviour is attached.
return null
Runs every frame after start regardless of whether or not the Behaviour is attached.