Skip to content

Documentation generator for the Wren scripting lang

License

Notifications You must be signed in to change notification settings

dollerama/WrenDoc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

WrenDoc

A minimal documentation generator for the Wren scripting language.

Usage

Uses perl v5.30.3

perl WrenDoc.pl -out Doc.md -in Behaviour.wren -v

Flags

  • -i | in: comma separated .wren inputs
  • -o | out: .md output filename
  • -v | verbose: gives detailed information during script runtime

How To Use

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

Doc

Modules

Module behaviour

Classes

Class Behaviour

Inherits from Serializable

Behaviours allow for custom code to run on GameObjects during the game loop.

Constructors

Getters

Setters

Methods

Static Getter data

return Any

Global data for behaviours

Static Setter data = v: Any
Static Getter [i]: Num

return Num

Static Setter [i]: Any = v: Any
Getter frame

return Num

Setter frame = v: Num
Getter as_behaviour

return ComponentBehaviour

Constructor new(g: GameObject, c: ComponentBehaviour)

return Behaviour

Static Method start()

return null

Runs the frame after setup.

Static Method update()

return null

Run every frame.

Static Method onCollision(collision: Map)

return null

Runs every frame after start that the Behaviour has a collision given a Rigidbody and Transform is attached.

Method setup()

return null

Runs the first frame regardless of whether or not the Behaviour is attached.

Method start()

return null

Runs the second frame regardless of whether or not the Behaviour is attached.

Method update()

return null

Runs every frame after start regardless of whether or not the Behaviour is attached.

About

Documentation generator for the Wren scripting lang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages