Given that in the future I will work with a larger team, I try to teach myself the basic principles of annotation and documentation for front-end languages. I am currently working on JS.
For the most part I use the Google Style Guide , but I still have some questions.
Say I have an ajax function like this:
function initFunction(src, wrapper) { $.getJSON(src, { format: "json" }).done(function(data) { var wrapper = $(wrapper), contents = callAnotherFunction($(data)[0]);
The function has two @param , src and wrapper. Here are a few questions.
callAnotherFunction (), then takes an Object as an argument and it should return some HTML.
- what type of src? Given this JSON,
{Object} ? - what type of wrapper? Given this value, such as
"#myId" , String? - what type of return function? This is a void function, but I donβt know what I would call it a return type. Does it return null?
- What type of HTML can be added to an element? Is this a
String ? - What is the JSDoc convention to display all of this? Something like that?
/** * This is a description of this function. It gets a JSON file, uses it as * a jQuery object, and then call another function with the new data. * @param {Object} src JSON file to parse. * @param {String} wrapper HTML element to use as a wrapper for the output. * @return {Null} */
source share