Src:Coffeedoc

apgwoz edited this page Feb 15, 2012 · 1 revision
Clone this wiki locally

coffeedoc.coffee

Functions

Functions

exports.documentModule(script, parser)

Given a module's source code and an AST parser, returns module information in the form:

{
    "docstring": "Module docstring",
    "classes": [class1, class1...],
    "functions": [func1, func2...]
}

AST parsers are defined in the parsers.coffee module

documentClass(cls)

Evaluates a class object as returned by the coffeescript parser, returning an object of the form:

{
    "name": "MyClass",
    "docstring": "First comment following the class definition"
    "parent": "MySuperClass",
    "methods": [method1, method2...]
}

documentFunction(func)

Evaluates a function object as returned by the coffeescript parser, returning an object of the form:

{
    "name": "myFunc",
    "docstring": "First comment following the function definition",
    "params": ["param1", "param2"...]
}

formatDocstring(str)

Given a string, returns it with leading whitespace removed but with indentation preserved. Replaces \# with # to allow for the use of multiple # characters in markup languages (e.g. Markdown headers)