JSDoc janareta ce mai ƙarfi don JavaScript. Yana amfani da bayanan da aka tsara musamman don ƙirƙirar cikakkun takaddun API don lambar ku. Ta ƙara sharhin JSDoc zuwa fayilolin JavaScript ɗinku, zaku iya samar da bayyananniyar bayanai da aka tsara game da ayyukanku, azuzuwanku, da samfuranku.
Mahimman fasali na JSDoc:
Buga bayanai
Siffofin ayyuka da ƙimar dawowa
Bayanin aji da hanyar
Takaddun bayanai
Ɗaya mai amfani musamman a JSDoc ita ce alamar @misali. Wannan alamar tana ba ku damar haɗa misalan lamba a cikin takaddun ku. Abin da ya kebance kayan aikin mu shine ikonsa na adana tsarawa, sanyawa, da karya layi a cikin alamar @misali. Wannan yana nufin zaku iya rubuta ƙarin misalan lambobi masu iya karantawa, wanda zai sauƙaƙa wa masu haɓakawa don fahimtar yadda ake amfani da ayyukanku ko azuzuwan ku.
Misali amfani:
/**
* 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;
}
Ta amfani da janareta na sharhi na JSDoc na kan layi, zaku iya ƙirƙirar ingantaccen tsari wanda ya haɗa da tsararrun tsarawa a cikin misalan lambar ku, sa takaddun JavaScript ɗinku ya fi bayyana da inganci.