Code Comment Generator
Generate JSDoc, Python docstring and PHPDoc blocks from your function signatures.
/**
* Gets user by id.
*
* @param {*} id The unique identifier.
* @param {Object} [options={}] Configuration options.
* @returns {*} The user by id.
*/
export async function getUserById(id, options = {}) {
const res = await fetch(`/api/users/${id}`, options);
return res.json();
}
/**
* Checks if it is valid email.
*
* @param {*} email The email address.
* @returns {*} True if it does, otherwise false.
*/
const isValidEmail = (email) => /\S+@\S+\.\S+/.test(email);
class Cart {
/**
* Calculates total.
*
* @param {number} [taxRate=0.18] The tax rate.
* @param {*} ...discounts Additional discounts.
* @returns {*} The result.
*/
calculateTotal(taxRate = 0.18, ...discounts) {
return this.items.reduce((sum, item) => sum + item.price, 0) * (1 + taxRate);
}
}Descriptions are generated from names and signatures, so treat them as a starting point and add the details only you know.