JSDoc ke jenereithara e matla ea litokomane bakeng sa JavaScript. E sebelisa maikutlo a hlophisitsoeng ka mokhoa o ikhethileng ho theha litokomane tse qaqileng tsa API bakeng sa khoutu ea hau. Ka ho kenyelletsa maikutlo a JSDoc lifaeleng tsa hau tsa JavaScript, o ka fana ka leseli le hlakileng le le hlophisehileng mabapi le mesebetsi ea hau, litlelase le limmojule.
Lintlha tsa bohlokoa tsa JSDoc:
Tlanya lintlha
Liparamente tsa ts'ebetso le litekanyetso tsa ho khutlisa
Litlhaloso tsa sehlopha le mekhoa
Litokomane tsa module
Tag e 'ngoe ea bohlokoa haholo ho JSDoc ke tag ea @example. Theke ena e u lumella ho kenyelletsa mehlala ea khoutu litokomaneng tsa hau. Se khethollang sesebelisoa sa rona ke bokhoni ba sona ba ho boloka fomete, indentation, le likheo tsa mela ka har'a tag ea @example. Sena se bolela hore o ka ngola mehlala ea likhoutu e baloang le ea 'nete, e nolofaletsa baetsi ho utloisisa mokhoa oa ho sebelisa mesebetsi kapa litlelase tsa hau.
Mohlala oa tšebeliso:
/**
* 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;
}
Ka ho sebelisa jenereithara ea rona ea ho fana ka maikutlo ea JSDoc e fumanehang marang-rang, u ka etsa litokomane tse hlophisitsoeng hantle tse kenyelletsang mokhoa o bolokiloeng mehlaleng ea khoutu ea hau, ho etsa hore litokomane tsa hau tsa JavaScript li hlaka le ho sebetsa.