JSDoc isimba rezvinyorwa jenareta yeJavaScript. Iyo inoshandisa yakanyatso kurongwa makomendi kugadzira yakadzama API zvinyorwa zvekodhi yako. Nekuwedzera JSDoc makomendi kune ako JavaScript mafaera, unogona kupa yakajeka uye yakarongeka ruzivo nezve mabasa ako, makirasi, uye mamodule.
Zvinhu zvakakosha zveJSDoc:
Nyora ruzivo
Basa parameters uye kudzoka kukosha
Kirasi uye nzira tsananguro
Module zvinyorwa
Imwe inonyanya kukosha tag muJSDoc ndiyo @example tag. Iyi tegi inokutendera iwe kuti ubatanidze kodhi mienzaniso muzvinyorwa zvako. Chii chinosiyanisa chishandiso chedu kugona kwayo kuchengetedza fomati, indentation, uye mitsara inotsemuka mukati me @example tag. Izvi zvinoreva kuti iwe unogona kunyora inoverengeka uye yechokwadi kodhi mienzaniso, zvichiita kuti zvive nyore kune vanogadzira kuti vanzwisise mashandisiro aungaita mabasa ako kana makirasi.
Muenzaniso kushandiswa:
/**
* Calculates the sum of two numbers.
* @param {number} a - The first number.
* @param {number} b - The second number.
* @returns {number} The sum of a and b.
* @example
* // This example preserves formatting and line breaks
* const result = add(5, 3);
* console.log(result);
* // Output: 8
*/
function add(a, b) {
return a + b;
}