cbou / markdox

Markdox is a documentation generator based on Dox and Markdown. It parse Javascript and even Coffeescript.
http://cbou.github.com/markdox
230 stars 27 forks source link

How to document callback parameters? #1

Closed esamattis closed 10 years ago

esamattis commented 12 years ago

For example I have a function called getDoc which takes two parameters, string for the document id and a function as a callback which itself must accept two parameters, an possible error object as first parameter and the document contents as second.

It's used like this to be clear:

getDoc("x932", function(err, doc) {
    if (err) throw err;
    console.log(doc);
});

Something like?

@param {String} document id
@param {Function} callback({Error/null} possible error object, {Document} json document)

Better ideas?

cbou commented 12 years ago

It's not very javadoc compliant and not supported by Markdox yet but maybe something like that could be nice:

@param {String} document id
@param {Function} callback the callback function
@callback {Error|null} A possible error
@callback {Document} The document

Then you just need to add a custom formatter function and a custom template (https://github.com/cbou/markdox#advanced-usage)