필요에 따라 여러 객체를 프로토 타이핑 할 중첩 된 네임 스페이스를 구성한다고 가정 해 보겠습니다. 기본적으로 window.blah.foo 객체는 비어 있습니다. 그런 다음 모든 하위 객체와 함수를 하나의 프로토 타입으로 프로토 타입합니다. 우리가 아래에있는 것처럼 문서화 할 때 모든 내부 함수를 전역으로 표시합니다. 이제 같은 방법으로 수십 개의 파일을 만들었다 고 상상해보십시오. .bar1(), bar2() 및 bar3() 함수가 window.blah.foo 객체의 메소드이며, 특히 인스턴스화가이 파일 외부에서 여러 번 수행 될 때이를 어떻게 문서화 할 수 있을까요?프로토 타입 상속을 문서화하는 JSDoc
/**
* Blah - Our very own global Namespace
* @namespace
* @type {object}
* @global
* @public
*/
window.blah = window.blah || {};
/**
* Immediately-Invoked Function Expression (IIFE).
* @function
* @param {object} w - Global window object.
* @returns {Object} window.blah.foo
*/
(function (w) {
// strict JS
'use strict';
/**
* Create instance of w.blah.foo constructor
* @constructor
*/
w.blah.foo = function() {
};
/**
* Append properties and methods to an instance of window.blah.foo
* @constructor
*/
w.blah.foo.prototype = {
/**
* Dummy function to return the number 1.
* @method bar1
*/
bar1: function() {
console.log(1);
},
/**
* Dummy function to return the number 2.
* @method bar2
*/
bar2: function() {
console.log(2);
},
/**
* Dummy function to return the number 3.
* @method bar3
*/
bar3: function() {
console.log(3);
}
};
}(window));
감사합니다! 나는 어딘가에서 꼬리표를 놓쳤다는 것을 알았다. –